Class: FTest::Runner::ProcessSet::Process
- Inherits:
-
Object
- Object
- FTest::Runner::ProcessSet::Process
- Defined in:
- lib/ftest/runner.rb
Instance Attribute Summary collapse
-
#fd ⇒ Object
readonly
Returns the value of attribute fd.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(file) ⇒ Process
constructor
A new instance of Process.
- #print_stacktrace(error) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(file) ⇒ Process
Returns a new instance of Process.
102 103 104 |
# File 'lib/ftest/runner.rb', line 102 def initialize file @file = file end |
Instance Attribute Details
#fd ⇒ Object (readonly)
Returns the value of attribute fd.
98 99 100 |
# File 'lib/ftest/runner.rb', line 98 def fd @fd end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
99 100 101 |
# File 'lib/ftest/runner.rb', line 99 def file @file end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
100 101 102 |
# File 'lib/ftest/runner.rb', line 100 def pid @pid end |
Instance Method Details
#finish ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/ftest/runner.rb', line 136 def finish fd.read 1 _, status = ::Process.wait2 pid status = status.exitstatus Config.internal_logger.debug "finished script #{@file}; status=#{status.inspect}" status == 0 end |
#print_stacktrace(error) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/ftest/runner.rb', line 124 def print_stacktrace error locations = error.backtrace final_location = locations.shift locations = FTest::BacktraceFilter.(locations) lines = locations.map do |loc| "\tfrom #{loc}" end lines.unshift "#{final_location}: #{error.} (#{error.class.name})" lines.reverse! if Config.reverse_backtraces Config.logger.error "Exception:\n#{lines * "\n"}" end |
#start ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ftest/runner.rb', line 106 def start @fd, wr = IO.pipe @pid = fork do @fd.close begin load file rescue => error print_stacktrace error exit 1 ensure wr.write "\x00" end end freeze end |