lib/parallel_tests/cli.rb in parallel_tests-2.6.0 vs lib/parallel_tests/cli.rb in parallel_tests-2.7.0

- old
+ new

@@ -24,12 +24,18 @@ private def execute_in_parallel(items, num_processes, options) Tempfile.open 'parallel_tests-lock' do |lock| - return Parallel.map(items, :in_threads => num_processes) do |item| + 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 + end reprint_output(result, lock.path) if options[:serialize_stdout] result end end end @@ -291,8 +297,19 @@ end def first_is_1? 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 '.' + end + end end end end