Class: ParallelTests

Inherits:
Object
  • Object
show all
Defined in:
lib/openstudio-standards/btap/costing/parallel_tests.rb

Instance Method Summary collapse

Instance Method Details

#run(file_list) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/openstudio-standards/btap/costing/parallel_tests.rb', line 68

def run(file_list)
  did_all_tests_pass = true

  @full_file_list = nil
  FileUtils.rm_rf(TestOutputFolder)
  FileUtils.mkpath(TestOutputFolder)

  # load test files from file.
  @full_file_list = file_list.shuffle

  puts "Running #{@full_file_list.size} tests suites in parallel using #{ProcessorsUsed} of available cpus."
  puts "To increase or decrease the ProcessorsUsed, please edit the test/test_run_all_locally.rb file."
  timings_json = Hash.new()
  Parallel.each_with_index(@full_file_list, in_threads: (ProcessorsUsed), progress: "Progress :") do |test_file, index|
    file_name = test_file.gsub(/^.+(openstudio-standards\/test\/)/, '')
    timings_json[file_name.to_s] = {}
    timings_json[file_name.to_s]['start'] = Time.now.to_i
    did_all_tests_pass = false unless write_results(Open3.capture3("bundle exec ruby #{test_file}"), test_file)
    timings_json[file_name.to_s]['end'] = Time.now.to_i
    timings_json[file_name.to_s]['total'] = timings_json[file_name.to_s]['end'] - timings_json[file_name.to_s]['start']
  end

  return did_all_tests_pass
end