-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest.rb
executable file
·56 lines (49 loc) · 1.23 KB
/
test.rb
1
2
3
4
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
#!/usr/bin/env ruby
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: test.rb [options] test_case.rb"
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
opts.on("-h", "--help", "Print this help") do
puts(opts)
exit 1
end
end.parse!
verbose = options[:verbose]
def run_single_mri_test(fn, verbose:false)
basename = File.basename(fn,'.rb')
outname = "rb_test/sysrb_out/#{basename}.out"
puts "testing #{fn}" if verbose
system("ruby #{fn} > #{outname}")
system("./erruby #{fn} | diff #{outname} -")
end
def run_mri_tests(verbose:)
fail_case = []
if ARGV[0] && File.exist?(ARGV[0])
fn = ARGV[0]
basename = File.basename(fn,'.rb')
test_result = run_single_mri_test(fn, verbose: verbose)
fail_case << fn unless test_result
else
Dir.glob("rb_test/*.rb") do |fn|
basename = File.basename(fn,'.rb')
next if basename.start_with?("_")
unless run_single_mri_test(fn, verbose: verbose)
fail_case << fn
end
end
end
fail_case
end
fail_case = run_mri_tests(verbose: verbose)
if fail_case.empty?
puts "everything pass"
exit 0
else
fail_case.each do |fn|
puts "test #{fn} failed"
end
exit 1
end