Class: FTest::Runner::ProcessSet::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/ftest/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Process

Returns a new instance of Process.



95
96
97
# File 'lib/ftest/runner.rb', line 95

def initialize file
  @file = file
end

Instance Attribute Details

#fdObject (readonly)

Returns the value of attribute fd.



91
92
93
# File 'lib/ftest/runner.rb', line 91

def fd
  @fd
end

#fileObject (readonly)

Returns the value of attribute file.



92
93
94
# File 'lib/ftest/runner.rb', line 92

def file
  @file
end

#pidObject (readonly)

Returns the value of attribute pid.



93
94
95
# File 'lib/ftest/runner.rb', line 93

def pid
  @pid
end

Instance Method Details

#finishObject



129
130
131
132
133
134
135
# File 'lib/ftest/runner.rb', line 129

def finish
  fd.read 1
  _, status = ::Process.wait2 pid
  status = status.exitstatus
  Config.logger.debug "finished script #{@file}; status=#{status.inspect}"
  status == 0
end


117
118
119
120
121
122
123
124
125
126
127
# File 'lib/ftest/runner.rb', line 117

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.message}"

  lines.reverse! if Config.reverse_backtraces
  Config.logger.error "Exception:\n#{lines * "\n"}"
end

#startObject



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/ftest/runner.rb', line 99

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