Class: Megatest::Subprocess
- Inherits:
-
Object
- Object
- Megatest::Subprocess
- Defined in:
- lib/megatest/subprocess.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(read, write) ⇒ Subprocess
constructor
A new instance of Subprocess.
- #run(action) ⇒ Object
Constructor Details
#initialize(read, write) ⇒ Subprocess
Returns a new instance of Subprocess.
19 20 21 22 |
# File 'lib/megatest/subprocess.rb', line 19 def initialize(read, write) @read = read @write = write end |
Class Method Details
.spawn(read, write, action) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/megatest/subprocess.rb', line 6 def spawn(read, write, action) Process.spawn( RbConfig.ruby, File.("../subprocess/main.rb", __FILE__), read.fileno.to_s, write.fileno.to_s, action, read.fileno => read, write.fileno => write, ) end |
Instance Method Details
#run(action) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/megatest/subprocess.rb', line 24 def run(action) case action when "run_test" config = Marshal.load(@read) Megatest.init(config) test_path = Marshal.load(@read) test_cases = Megatest.load_tests(config, [test_path]) test_id = Marshal.load(@read) @read.close test_case = test_cases.find { |t| t.id == test_id } unless test_case exit!(1) # TODO: error end result = Runner.new(config).run(test_case) Marshal.dump(result, @write) @write.close else exit!(1) end exit!(0) end |