Class: Test::Unit::Runner::Worker
- Inherits:
-
Object
- Object
- Test::Unit::Runner::Worker
- Defined in:
- lib/test/unit.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#loadpath ⇒ Object
Returns the value of attribute loadpath.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#real_file ⇒ Object
Returns the value of attribute real_file.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #died(*additional) ⇒ Object
- #hook(id, &block) ⇒ Object
-
#initialize(io, pid, status) ⇒ Worker
constructor
A new instance of Worker.
- #puts(*args) ⇒ Object
- #read ⇒ Object
- #run(task, type) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(io, pid, status) ⇒ Worker
Returns a new instance of Worker.
246 247 248 249 250 251 252 253 254 |
# File 'lib/test/unit.rb', line 246 def initialize(io, pid, status) @io = io @pid = pid @status = status @file = nil @real_file = nil @loadpath = [] @hooks = {} end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file
308 309 310 |
# File 'lib/test/unit.rb', line 308 def file @file end |
#io ⇒ Object (readonly)
Returns the value of attribute io
307 308 309 |
# File 'lib/test/unit.rb', line 307 def io @io end |
#loadpath ⇒ Object
Returns the value of attribute loadpath
308 309 310 |
# File 'lib/test/unit.rb', line 308 def loadpath @loadpath end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid
307 308 309 |
# File 'lib/test/unit.rb', line 307 def pid @pid end |
#real_file ⇒ Object
Returns the value of attribute real_file
308 309 310 |
# File 'lib/test/unit.rb', line 308 def real_file @real_file end |
#status ⇒ Object
Returns the value of attribute status
308 309 310 |
# File 'lib/test/unit.rb', line 308 def status @status end |
Class Method Details
.launch(ruby, args = []) ⇒ Object
239 240 241 242 243 244 |
# File 'lib/test/unit.rb', line 239 def self.launch(ruby,args=[]) io = IO.popen([*ruby, "#{File.dirname(__FILE__)}/unit/parallel.rb", *args], "rb+") new(io, io.pid, :waiting) end |
Instance Method Details
#close ⇒ Object
287 288 289 290 |
# File 'lib/test/unit.rb', line 287 def close @io.close self end |
#died(*additional) ⇒ Object
292 293 294 295 296 297 |
# File 'lib/test/unit.rb', line 292 def died(*additional) @status = :quit @io.close call_hook(:dead,*additional) end |
#hook(id, &block) ⇒ Object
276 277 278 279 280 |
# File 'lib/test/unit.rb', line 276 def hook(id,&block) @hooks[id] ||= [] @hooks[id] << block self end |
#puts(*args) ⇒ Object
256 257 258 |
# File 'lib/test/unit.rb', line 256 def puts(*args) @io.puts(*args) end |
#read ⇒ Object
282 283 284 285 |
# File 'lib/test/unit.rb', line 282 def read res = (@status == :quit) ? @io.read : @io.gets res && res.chomp end |
#run(task, type) ⇒ Object
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/test/unit.rb', line 260 def run(task,type) @file = File.basename(task).gsub(/\.rb/,"") @real_file = task begin puts "loadpath #{[Marshal.dump($:-@loadpath)].pack("m").gsub("\n","")}" @loadpath = $:.dup puts "run #{task} #{type}" @status = :prepare rescue Errno::EPIPE died rescue IOError raise unless ["stream closed","closed stream"].include? $!. died end end |
#to_s ⇒ Object
299 300 301 302 303 304 305 |
# File 'lib/test/unit.rb', line 299 def to_s if @file "#{@pid}=#{@file}" else "#{@pid}:#{@status.to_s.ljust(7)}" end end |