diff --git a/spec/support/rspec_run_time.rb b/spec/support/rspec_run_time.rb index 68430626126f5f373e0b39b4b0aa0c80d5e52b37..71e2178f4db5bc6d868d9786eab4741de796d4c8 100644 --- a/spec/support/rspec_run_time.rb +++ b/spec/support/rspec_run_time.rb @@ -30,8 +30,8 @@ def example_group_finished(notification) duration = time_now - @start_time elapsed_time = time_now - @rspec_test_suite_start_time - output.puts "\nExample group #{notification.group.description} took #{readable_duration(duration)}." - output.puts "\nRSpec timer is at #{time_now}. RSpec elapsed time: #{readable_duration(elapsed_time)}.\n\n" + output.puts "\n# Example group #{notification.group.description} took #{readable_duration(duration)}." + output.puts "# RSpec elapsed time: #{readable_duration(elapsed_time)}.\n\n" end end end diff --git a/spec/tooling/lib/tooling/parallel_rspec_runner_spec.rb b/spec/tooling/lib/tooling/parallel_rspec_runner_spec.rb index f8b36b3c34f2f13738316bbc30729036baf829da..62de742e125d1634ba335869576a0e61bed69f18 100644 --- a/spec/tooling/lib/tooling/parallel_rspec_runner_spec.rb +++ b/spec/tooling/lib/tooling/parallel_rspec_runner_spec.rb @@ -19,7 +19,6 @@ before do allow(Knapsack::AllocatorBuilder).to receive(:new).and_return(allocator_builder) - allow(Knapsack.logger).to receive(:info) end after do @@ -36,6 +35,10 @@ shared_examples 'runs node tests' do let(:rspec_args) { nil } + before do + allow(Knapsack.logger).to receive(:info) + end + it 'runs rspec with tests allocated for this node' do expect(allocator_builder).to receive(:filter_tests=).with(filter_tests) expect_command(%W[bundle exec rspec#{rspec_args} --] + node_tests) @@ -124,10 +127,14 @@ end it 'does not parse expected rspec report' do - expect($stdout).not_to receive(:puts).with('Parsing expected rspec suite duration...') + expected_output = <<~MARKDOWN.chomp + Running command: bundle exec rspec -- 01_spec.rb 03_spec.rb + + MARKDOWN + expect(File).not_to receive(:write).with(expected_report_file_path, expected_report_content) - runner.run + expect { runner.run }.to output(expected_output).to_stdout end end @@ -141,6 +148,7 @@ Parsing expected rspec suite duration... 03_spec.rb not found in master report RSpec suite is expected to take 1 minute 5 seconds. + Running command: bundle exec rspec -- 01_spec.rb 03_spec.rb MARKDOWN diff --git a/tooling/lib/tooling/parallel_rspec_runner.rb b/tooling/lib/tooling/parallel_rspec_runner.rb index f8d3be3a59339d608836bcb2a2af8e68d71da259..22d84603318a6c4494450f6536d4ba7f6aef2d5d 100644 --- a/tooling/lib/tooling/parallel_rspec_runner.rb +++ b/tooling/lib/tooling/parallel_rspec_runner.rb @@ -110,7 +110,7 @@ def parse_expected_duration_from_master_report master_report = JSON.parse(File.read(ENV['KNAPSACK_RSPEC_SUITE_REPORT_PATH'])) return unless master_report - puts "Parsing expected rspec suite duration..." + Knapsack.logger.info "Parsing expected rspec suite duration..." duration_total = 0 expected_duration_report = {} @@ -120,11 +120,11 @@ def parse_expected_duration_from_master_report duration_total += master_report[file] expected_duration_report[file] = master_report[file] else - puts "#{file} not found in master report" + Knapsack.logger.info "#{file} not found in master report" end end - puts "RSpec suite is expected to take #{readable_duration(duration_total)}." + Knapsack.logger.info "RSpec suite is expected to take #{readable_duration(duration_total)}." expected_duration_report end