Class: TestRunner::Runner::ProcessSet
- Inherits:
-
Object
- Object
- TestRunner::Runner::ProcessSet
- Defined in:
- lib/test_runner/runner.rb
Defined Under Namespace
Classes: Process
Instance Method Summary collapse
- #<<(file) ⇒ Object
- #failed? ⇒ Boolean
- #finish ⇒ Object
-
#initialize ⇒ ProcessSet
constructor
A new instance of ProcessSet.
- #reap(reads) ⇒ Object
- #shutdown ⇒ Object
- #spawn_child(file) ⇒ Object
- #success? ⇒ Boolean
- #tick ⇒ Object
- #wait(max_count) ⇒ Object
Constructor Details
#initialize ⇒ ProcessSet
Returns a new instance of ProcessSet.
38 39 40 41 |
# File 'lib/test_runner/runner.rb', line 38 def initialize @set = [] @passed = true end |
Instance Method Details
#<<(file) ⇒ Object
43 44 45 46 |
# File 'lib/test_runner/runner.rb', line 43 def << file wait Config.child_count - 1 @set.<< spawn_child file end |
#failed? ⇒ Boolean
89 90 91 |
# File 'lib/test_runner/runner.rb', line 89 def failed? not success? end |
#finish ⇒ Object
48 49 50 51 |
# File 'lib/test_runner/runner.rb', line 48 def finish wait 0 @passed end |
#reap(reads) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/test_runner/runner.rb', line 70 def reap reads @set.delete_if do |process| next unless reads.include? process.fd Config.internal_logger.debug "Reaping #{process.file}:#{process.pid}" process.finish or @passed = false true end shutdown if failed? and Config.fail_fast end |
#shutdown ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/test_runner/runner.rb', line 81 def shutdown @set.each do |process| ::Process.kill "TERM", process.pid end ::Process.waitall exit 1 end |
#spawn_child(file) ⇒ Object
64 65 66 67 68 |
# File 'lib/test_runner/runner.rb', line 64 def spawn_child file process = Process.new file process.start process end |
#success? ⇒ Boolean
93 94 95 |
# File 'lib/test_runner/runner.rb', line 93 def success? @passed end |
#tick ⇒ Object
57 58 59 60 61 62 |
# File 'lib/test_runner/runner.rb', line 57 def tick loop do reads, _, _ = IO.select @set.map(&:fd), [], [], 1 return reap reads if reads end end |
#wait(max_count) ⇒ Object
53 54 55 |
# File 'lib/test_runner/runner.rb', line 53 def wait max_count tick while @set.size > max_count end |