A platform for community discussion. Free, open, simple.
FIX: `TurboTests::Runner` not failing on errors.
Guo Xiang Tane3e7905d9ebd
diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rbindex 89ba1bdbed3..c0e90536643 100644--- a/lib/turbo_tests/runner.rb+++ b/lib/turbo_tests/runner.rb@@ -32,6 +32,7 @@ module TurboTests@messages = Queue.new@threads = []+ @error = falseenddef run@@ -43,6 +44,7 @@ module TurboTestsgroup_opts = {}if use_runtime_info+ FileUtils.rm("tmp/turbo_rspec_runtime.log", force: true)group_opts[:runtime_log] = "tmp/turbo_rspec_runtime.log"elsegroup_opts[:group_by] = :filesize@@ -73,7 +75,7 @@ module TurboTests@threads.each(&:join)- @reporter.failed_examples.empty?+ @reporter.failed_examples.empty? && !@errorendprotected@@ -86,12 +88,14 @@ module TurboTestsActiveRecord::Tasks::DatabaseTasks.migrations_paths = ['db/migrate', 'db/post_migrate']- conn = ActiveRecord::Base.establish_connection(config).connectionbegin+ conn = ActiveRecord::Base.establish_connection(config).connectionActiveRecord::Migration.check_pending!(conn)rescue ActiveRecord::PendingMigrationErrorputs "There are pending migrations, run rake parallel:migrate"exit 1+ ensure+ conn&.closeendend@@ -168,7 +172,8 @@ module TurboTestsSTDERR.puts "Process #{process_id}: #{command_str}"end- _stdin, stdout, stderr, _wait_thr = Open3.popen3(env, *command)+ stdin, stdout, stderr, wait_thr = Open3.popen3(env, *command)+ stdin.close@threads <<Thread.new do@@ -184,8 +189,16 @@ module TurboTests@messages << { type: 'exit', process_id: process_id }end- @threads << start_copy_thread(stdout, STDOUT)- @threads << start_copy_thread(stderr, STDERR)+ stdout_thread = start_copy_thread(stdout, STDOUT)+ stderr_thread = start_copy_thread(stderr, STDERR)+ @threads << stdout_thread+ @threads << stderr_thread++ @threads << Thread.new do+ if wait_thr.value.exitstatus != 0+ @messages << { type: 'error', record_runtime: record_runtime }+ end+ endendend@@ -195,6 +208,7 @@ module TurboTestsbeginmsg = src.readpartial(4096)rescue EOFError+ src.closebreakelsedst.write(msg)@@ -226,6 +240,13 @@ module TurboTestsendwhen 'seed'when 'close'+ when 'error'+ if message[:record_runtime]+ STDERR.puts File.read("tmp/turbo_rspec_runtime.log")+ end+ @threads.each(&:kill)+ @error = true+ breakwhen 'exit'exited += 1if exited == @num_processes + 1