Methods
C
D
H
L
N
P
R
T
Attributes
[RW] file
[R] io
[RW] loadpath
[R] pid
[RW] real_file
[RW] status
Class Public methods
launch(ruby,args=[])
# File ../ruby/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
new(io, pid, status)
# File ../ruby/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 Public methods
close()
# File ../ruby/lib/test/unit.rb, line 287
def close
  @io.close
  self
end
died(*additional)
# File ../ruby/lib/test/unit.rb, line 292
def died(*additional)
  @status = :quit
  @io.close

  call_hook(:dead,*additional)
end
hook(id,&block)
# File ../ruby/lib/test/unit.rb, line 276
def hook(id,&block)
  @hooks[id] ||= []
  @hooks[id] << block
  self
end
puts(*args)
# File ../ruby/lib/test/unit.rb, line 256
def puts(*args)
  @io.puts(*args)
end
read()
# File ../ruby/lib/test/unit.rb, line 282
def read
  res = (@status == :quit) ? @io.read : @io.gets
  res && res.chomp
end
run(task,type)
# File ../ruby/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? $!.message
    died
  end
end
to_s()
# File ../ruby/lib/test/unit.rb, line 299
def to_s
  if @file
    "#{@pid}=#{@file}"
  else
    "#{@pid}:#{@status.to_s.ljust(7)}"
  end
end
Instance Private methods
call_hook(id,*additional)
# File ../ruby/lib/test/unit.rb, line 312
def call_hook(id,*additional)
  @hooks[id] ||= []
  @hooks[id].each{|hook| hook[self,additional] }
  self
end