lib/parallel_tests/cli.rb in parallel_tests-2.27.0 vs lib/parallel_tests/cli.rb in parallel_tests-2.27.1

- old
+ new

@@ -38,20 +38,16 @@ end def execute_in_parallel(items, num_processes, options) Tempfile.open 'parallel_tests-lock' do |lock| ParallelTests.with_pid_file do - progress_indicator = simulate_output_for_ci if options[:serialize_stdout] - - Parallel.map(items, :in_threads => num_processes) do |item| - result = yield(item) - if progress_indicator && progress_indicator.alive? - progress_indicator.exit - puts + simulate_output_for_ci options[:serialize_stdout] do + Parallel.map(items, :in_threads => num_processes) do |item| + result = yield(item) + reprint_output(result, lock.path) if options[:serialize_stdout] + result end - reprint_output(result, lock.path) if options[:serialize_stdout] - result end end end end @@ -96,10 +92,11 @@ end end def reprint_output(result, lockfile) lock(lockfile) do + $stdout.puts $stdout.puts result[:stdout] $stdout.flush end end @@ -329,16 +326,23 @@ val = ENV["PARALLEL_TEST_FIRST_IS_1"] ['1', 'true'].include?(val) end # CI systems often fail when there is no output for a long time, so simulate some output - def simulate_output_for_ci - Thread.new do - interval = ENV.fetch('PARALLEL_TEST_HEARTBEAT_INTERVAL', 60).to_f - loop do - sleep interval - print '.' + def simulate_output_for_ci(simulate) + if simulate + progress_indicator = Thread.new do + interval = Float(ENV.fetch('PARALLEL_TEST_HEARTBEAT_INTERVAL', 60)) + loop do + sleep interval + print '.' + end end + test_results = yield + progress_indicator.exit + test_results + else + yield end end end end