Class: FTest::Runner::ProcessSet
- Inherits:
-
Object
- Object
- FTest::Runner::ProcessSet
- Defined in:
- lib/ftest/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.
31 32 33 34 |
# File 'lib/ftest/runner.rb', line 31 def initialize @set = [] @passed = true end |
Instance Method Details
#<<(file) ⇒ Object
36 37 38 39 |
# File 'lib/ftest/runner.rb', line 36 def << file wait Config.child_count - 1 @set.<< spawn_child file end |
#failed? ⇒ Boolean
82 83 84 |
# File 'lib/ftest/runner.rb', line 82 def failed? not success? end |
#finish ⇒ Object
41 42 43 44 |
# File 'lib/ftest/runner.rb', line 41 def finish wait 0 @passed end |
#reap(reads) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ftest/runner.rb', line 63 def reap reads @set.delete_if do |process| next unless reads.include? process.fd Config.logger.debug "Reaping #{process.file}:#{process.pid}" process.finish or @passed = false true end shutdown if failed? and Config.fail_fast end |
#shutdown ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/ftest/runner.rb', line 74 def shutdown @set.each do |process| ::Process.kill "TERM", process.pid end ::Process.waitall exit 1 end |
#spawn_child(file) ⇒ Object
57 58 59 60 61 |
# File 'lib/ftest/runner.rb', line 57 def spawn_child file process = Process.new file process.start process end |
#success? ⇒ Boolean
86 87 88 |
# File 'lib/ftest/runner.rb', line 86 def success? @passed end |
#tick ⇒ Object
50 51 52 53 54 55 |
# File 'lib/ftest/runner.rb', line 50 def tick loop do reads, _, _ = IO.select @set.map(&:fd), [], [], 1 return reap reads if reads end end |
#wait(max_count) ⇒ Object
46 47 48 |
# File 'lib/ftest/runner.rb', line 46 def wait max_count tick while @set.size > max_count end |