10
alias orig_run_suite _run_suite
15
def increment_io(orig)
16
*rest, io = 32.times.inject([orig.dup]){|ios, | ios << ios.last.dup }
21
def _run_suites(suites, type)
23
_run_suite(suite, type)
27
def _run_suite(suite, type)
29
orig_testout = MiniTest::Unit.output
32
MiniTest::Unit.output = o
33
orig_stdin, orig_stdout = $stdin, $stdout
37
while buf = (self.verbose ? i.gets : i.read(5))
38
@stdout.puts "p #{[buf].pack("m").gsub("\n","")}"
45
e, f, s = @errors, @failures, @skips
48
result = orig_run_suite(suite, type)
54
MiniTest::Unit.output = orig_testout
62
raise unless ["stream closed","closed stream"].include? $!.message
66
result << (report - r)
67
result << [@errors-e,@failures-f,@skips-s]
68
result << ($: - @old_loadpath)
72
@stdout.puts "done #{[Marshal.dump(result)].pack("m").gsub("\n","")}"
73
rescue Errno::EPIPE; end
76
MiniTest::Unit.output = orig_stdout
79
o.close if o && !o.closed?
80
i.close if i && !i.closed?
85
@@stop_auto_run = true
91
@stdout = increment_io(STDOUT)
92
@stdin = increment_io(STDIN)
95
while buf = @stdin.gets
97
when /^loadpath (.+?)$/
98
@old_loadpath = $:.dup
99
$:.push(*Marshal.load($1.unpack("m")[0].force_encoding("ASCII-8BIT"))).uniq!
100
when /^run (.+?) (.+?)$/
104
suites = MiniTest::Unit::TestCase.test_suites
109
@stdout.puts "after #{[Marshal.dump([$1, $!])].pack("m").gsub("\n","")}"
113
_run_suites MiniTest::Unit::TestCase.test_suites-suites, $2.to_sym
118
rescue Errno::EPIPE; end
126
rescue Errno::EPIPE; end
131
rescue Exception => e
133
@stdout.puts "bye #{[Marshal.dump(e)].pack("m").gsub("\n","")}"
134
rescue Errno::EPIPE;end
148
class TestCase < MiniTest::Unit::TestCase
149
def on_parallel_worker?
156
Test::Unit::Worker.new.run(ARGV)