Sha256: e5c55113df8c713742fa0823f9176d4b0a26ebd26eb077d9ec3b083c3433fd1a

Contents?: true

Size: 1.41 KB

Versions: 10

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

# Case class:
# * play
# * play_in_parallel
# * play_in_sequence
# * fill_report
# * close_opened_sessions
class Case
  def play
    if skip?
      verbose "Skipping case <#{@config.get(:tt_members)}>\n"
      return false
    end
    # TODO: Delete old reports???
    start_time = Time.now
    play_in_sequence if get(:tt_sequence) == true # Play in sequence
    play_in_parallel if get(:tt_sequence) != true # Play in parallel
    fill_report(start_time, Time.now)
    close_opened_sessions
  end
  alias start play

  def close_opened_sessions
    @sessions.each_value do |s|
      s.close if s.class == Net::SSH::Connection::Session
    end
  end

  private

  def play_in_parallel
    @groups.each do |t|
      @action[:groupname] = t[:name]
      instance_eval(&t[:block])
    end
  end

  def play_in_sequence
    verboseln "Starting case <#{@config.get(:tt_members)}>"
    @groups.each do |t|
      verbose "* Processing <#{t[:name]}> "
      @action[:groupname] = t[:name]
      instance_eval(&t[:block])
      verbose "\n"
    end
    verboseln "\n"
  end

  def fill_report(start_time, finish_time)
    @report.head.merge! @config.global
    @report.head.merge! @config.local
    @report.head.merge! @config.running
    @report.tail[:case_id] = @id
    @report.tail[:start_time_] = start_time
    @report.tail[:finish_time] = finish_time
    @report.tail[:duration] = finish_time - start_time
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
teuton-2.1.8dev1 lib/teuton/case_manager/case/play.rb
teuton-2.1.7 lib/teuton/case_manager/case/play.rb
teuton-2.1.6 lib/teuton/case_manager/case/play.rb
teuton-2.1.5dev lib/teuton/case_manager/case/play.rb
teuton-2.1.4 lib/teuton/case_manager/case/play.rb
teuton-2.1.3 lib/teuton/case_manager/case/play.rb
teuton-2.1.2 lib/teuton/case_manager/case/play.rb
teuton-2.1.1 lib/teuton/case_manager/case/play.rb
teuton-2.1.0 lib/teuton/case_manager/case/play.rb
teuton-0.0.1 lib/teuton/case_manager/case/play.rb