5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/spork/test_framework/test_unit.rb', line 5
def run_tests(argv, stderr, stdout)
if defined? MiniTest
stdout = Purdytest::IO.new(stdout) if defined? Purdytest MiniTest::Unit.output = stdout
argv.each_with_index do |arg, idx|
if arg =~ /-I(.*)/
if $1 == ''
include_path = argv[idx + 1]
argv[idx + 1] = nil else
include_path = $1
end
$LOAD_PATH << include_path
argv[idx] = nil
elsif arg =~ /-r(.*)/
if $1 == ''
require_file = argv[idx + 1]
argv[idx + 1] = nil else
require_file = $1
end
require require_file
argv[idx] = nil
elsif arg =~ /^-e$/
eval argv[idx + 1]
argv[idx] = argv[idx + 1] = nil
end
end
argv.compact!
require 'test/unit'
if defined? Turn
if argv.empty?
puts "Usage: testrb [options] tests..."
exit 1
end
runner = Turn::MiniRunner.new
config = Turn.config do |c|
c.tests = argv
c.framework = :minitest
end
controller = Turn::Controller.new(config)
controller.start
elsif Test::Unit.respond_to?(:setup_argv)
Test::Unit.setup_argv(argv) {|files|
if files.empty?
puts "Usage: testrb [options] tests..."
exit 1
end
if files.size == 1
$0 = File.basename(files[0])
else
$0 = files.to_s
end
files
}
MiniTest::Unit.new.run(argv)
else
tests = Test::Unit::AutoRunner.new(true)
tests.options.banner.sub!(/\[options\]/, '\& tests...')
unless tests.process_args(argv)
abort tests.options.banner
end
files = tests.to_run
$0 = files.size == 1 ? File.basename(files[0]) : files.to_s
tests.run
end
else
Object.send(:remove_const, :STDOUT); Object.send(:const_set, :STDOUT, stdout)
require 'test/unit/autorunner'
r = Test::Unit::AutoRunner.new(true)
exit(false) unless r.process_args(argv)
r.run
end
rescue => e
puts "-"*30
puts "Error executing #{argv.join(' ')}"
puts e.message
puts e.backtrace
puts "-"*30
end
|