Module: CheckCasesExtension

Included in:
CaseManager
Defined in:
lib/teuton/case_manager/ext/check_cases.rb,
lib/teuton/case_manager/ext/hall_of_fame.rb

Defined Under Namespace

Classes: HallOfFame

Instance Method Summary collapse

Instance Method Details

#check_cases!Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/teuton/case_manager/ext/check_cases.rb', line 8

def check_cases!
  # Start checking every single case
  app = Project.value
  # Load configurations from config file
  configdata = ConfigFileReader.call(Project.value[:config_path])
  app[:ialias] = configdata[:alias]
  app[:global] = configdata[:global]
  app[:global][:tt_testname] = app[:global][:tt_testname] || app[:test_name]
  app[:global][:tt_sequence] = false if app[:global][:tt_sequence].nil?

  # Create out dir
  outdir = app[:global][:tt_outdir] || File.join("var", app[:global][:tt_testname])
  FileUtils.mkdir_p(outdir) unless Dir.exist?(outdir)
  @report.output_dir = outdir

  # Fill report head
  open_main_report(app[:config_path])

  # create cases and run
  configdata[:cases].each { |config| @cases << Case.new(config) }
  start_time = run_all_cases # run cases

  # TODO: merge these 2 methdos
  # TODO: CloseManager.call ???
  uniques = collect_uniques_for_all_cases
  close_reports_for_all_cases(uniques)
  close_main_report(start_time)
end

#close_reports_for_all_cases(uniques) ⇒ Object

1) Reevaluate every case with collected unique values 2) Close all case reports 3) And order to build hall of fame



74
75
76
77
78
79
80
# File 'lib/teuton/case_manager/ext/check_cases.rb', line 74

def close_reports_for_all_cases(uniques)
  threads = []
  @cases.each { |c| threads << Thread.new { c.close uniques } }
  threads.each(&:join)

  HallOfFame.new(@cases).call
end

#collect_uniques_for_all_casesObject

Collect uniques values for all cases



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/teuton/case_manager/ext/check_cases.rb', line 56

def collect_uniques_for_all_cases
  uniques = {} # Collect "unique" values from all cases
  @cases.each do |c|
    c.uniques.each do |key|
      if uniques[key].nil?
        uniques[key] = [c.id]
      else
        uniques[key] << c.id
      end
    end
  end
  uniques
end

#run_all_casesObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/teuton/case_manager/ext/check_cases.rb', line 37

def run_all_cases
  start_time = Time.now
  verboseln Rainbow("-" * 36).green
  verboseln Rainbow("Started at #{start_time}").green
  # if Application.instance.global[:tt_sequence] == true
  if Project.value[:global][:tt_sequence] == true
    # Run every case in sequence
    @cases.each(&:play)
  else
    # Run all cases in parallel
    threads = []
    @cases.each { |c| threads << Thread.new { c.play } }
    threads.each(&:join)
  end
  start_time
end