Class: TestmetricsRspec::ParallelTests
- Inherits:
-
Object
- Object
- TestmetricsRspec::ParallelTests
- Extended by:
- Shared
- Defined in:
- lib/testmetrics_rspec/parallel_tests.rb
Overview
This is a wrapper around running RSpec with the ‘parallel_tests` gem
Constant Summary
Constants included from Shared
Shared::BRANCH_VARS, Shared::SHA_VARS
Class Method Summary collapse
Methods included from Shared
ci_platform, correct_var, format, git_branch, git_sha, post, results, run_time_in_microseconds, start, starting_results, travis_branch
Class Method Details
.combined(results) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/testmetrics_rspec/parallel_tests.rb', line 28 def combined(results) start = results.pop results.each_with_object(start) do |result, acc| acc['tests'] = acc['tests'] + result['tests'] acc['total_run_time'] = acc['total_run_time'] + result['total_run_time'] end end |
.run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/testmetrics_rspec/parallel_tests.rb', line 7 def run key = ENV['TESTMETRICS_PROJECT_KEY'] post(starting_results) unless key.nil? ENV['PARALLEL_FORMAT'] = 'true' system("parallel_rspec #{ARGV[1..-1].join(' ')}") ENV['PARALLEL_FORMAT'] = nil send_end_results unless key.nil? end |
.send_end_results ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/testmetrics_rspec/parallel_tests.rb', line 19 def send_end_results results = Dir.glob('results*.json').each_with_object([]) do |path, acc| acc << JSON.parse(IO.read(path)) FileUtils.rm(path) end post(combined(results)) end |