Module: Minitest::ParalleForkFailFast
- Defined in:
- lib/minitest/parallel_fork/fail_fast.rb
Instance Method Summary collapse
- #parallel_fork_child_data(data) ⇒ Object
- #parallel_fork_data_from_marshal(data) ⇒ Object
- #parallel_fork_data_to_marshal ⇒ Object
- #parallel_fork_run_test_suite(suite, reporter, options) ⇒ Object
- #parallel_fork_run_test_suites(suites, reporter, options) ⇒ Object
- #run_after_parallel_fork_hook(i) ⇒ Object
Instance Method Details
#parallel_fork_child_data(data) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/minitest/parallel_fork/fail_fast.rb', line 41 def parallel_fork_child_data(data) threads = {} data.each{|pid, read| threads[pid] = Thread.new(read, &:read)} results = [] while sleep(0.01) && !threads.empty? threads.to_a.each do |pid, thread| unless thread.alive? threads.delete(pid) results << parallel_fork_data_from_marshal(thread.value) if @parallel_fork_stop # If any child failed fast, signal other children to fail fast threads.each_key do |pid| Process.kill(:USR1, pid) end # Set a flag indicating that all child processes have been signaled @parallel_fork_stop = :FINISHED end end end end results end |
#parallel_fork_data_from_marshal(data) ⇒ Object
15 16 17 18 19 |
# File 'lib/minitest/parallel_fork/fail_fast.rb', line 15 def parallel_fork_data_from_marshal(data) data = Marshal.load(data) @parallel_fork_stop = true if data.pop data end |
#parallel_fork_data_to_marshal ⇒ Object
11 12 13 |
# File 'lib/minitest/parallel_fork/fail_fast.rb', line 11 def parallel_fork_data_to_marshal super << @parallel_fork_stop end |
#parallel_fork_run_test_suite(suite, reporter, options) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/minitest/parallel_fork/fail_fast.rb', line 31 def parallel_fork_run_test_suite(suite, reporter, ) super if parallel_fork_stat_reporter.results.any?{|r| !r.failure.is_a?(Minitest::Skip)} # At least one failure or error, mark as failing fast @parallel_fork_stop = true end end |
#parallel_fork_run_test_suites(suites, reporter, options) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/minitest/parallel_fork/fail_fast.rb', line 21 def parallel_fork_run_test_suites(suites, reporter, ) suites.each do |suite| parallel_fork_run_test_suite(suite, reporter, ) # Fail fast if this child process had a failure, # Or the USR1 signal was received indicating other child processes had a failure. break if @parallel_fork_stop end end |
#run_after_parallel_fork_hook(i) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/minitest/parallel_fork/fail_fast.rb', line 4 def run_after_parallel_fork_hook(i) super Signal.trap(:USR1) do @parallel_fork_stop = true end end |