Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 148 lines (141 sloc) 4.437 kb
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
1 #!/usr/bin/ruby
2 # Preliminary test suite for the MacRuby VM.
3 # Aimed at testing critical features of the VM.
4 #
5 # Please do not contribute tests that cover any higher level features here,
6 # use the rubyspec directory instead.
7
8 $test_only = []
9 test_commands = []
10 ARGV.each do |arg|
11 if md = /--ruby=(.*)/.match(arg)
12 test_commands << md[1]
13 else
14 $test_only << arg
15 end
16 end
17 if test_commands.empty?
18 miniruby_path = File.join(Dir.pwd, 'miniruby')
9c2889d @takaokouji checked miniruby support i386 arch.
takaokouji authored
19 test_commands << "arch -i386 #{miniruby_path}" if system("arch -i386 #{miniruby_path} -e '' 2> /dev/null")
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
20 test_commands << "arch -x86_64 #{miniruby_path}" if system("arch -x86_64 #{miniruby_path} -e '' 2> /dev/null")
21 end
22 $test_archs = {}
23 test_commands.each do |command|
24 if md = /\barch -([^\s]+)/.match(command)
25 arch_name = md[1]
26 else
27 arch_name = 'default'
28 end
29 $test_archs[arch_name] ||= []
30 $test_archs[arch_name] << command
31 end
32 $problems = []
33 $problems_count = 0
314e73e @takaokouji supported show known problems.
takaokouji authored
34 $known_problems = []
35 $known_problems_count = 0
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
36 $assertions_count = 0
31aca7b @takaokouji import RDoc 3.5.3 and fix it for MacRuby.
takaokouji authored
37 $current_file = ""
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
38
39 def assert(expectation, code, options={})
40 if options[:archs]
41 archs = $test_archs.select {|arch, command| options[:archs].include?(arch) }
42 else
43 archs = $test_archs
44 end
45 archs.each do |arch, commands|
46 commands.each do |command|
47 output = nil
7df63c1 @vincentisambart Fixed a few test_vm tests that were incorrect (compared to 1.9)
vincentisambart authored
48 IO.popen("#{command} -I.", 'r+') do |io|
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
49 io.puts(code)
50 io.close_write
51 output = io.read
52 end
314e73e @takaokouji supported show known problems.
takaokouji authored
53 # results
54 # .: success
55 # F: failure
56 # E: error
57 # +: success but known bug (It's nice!!)
58 # f: failure but known bug
59 # e: error but known bug
60 result =
61 if $? and $?.exitstatus == 0
62 if output.chomp == expectation
63 options[:known_bug] ? '+' : '.'
64 else
65 options[:known_bug] ? 'f' : 'F'
66 end
67 else
68 output = "ERROR CODE #{$?.exitstatus}"
69 options[:known_bug] ? 'e' : 'E'
70 end
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
71 print result
72 $stdout.flush
314e73e @takaokouji supported show known problems.
takaokouji authored
73 case result
74 when '.', '+'
75 when 'F', 'E'
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
76 $problems_count += 1
31aca7b @takaokouji import RDoc 3.5.3 and fix it for MacRuby.
takaokouji authored
77 new_problem = [[$problems_count], code, expectation, [arch], command, output, $current_file]
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
78 previous_problem = $problems.last
79 if previous_problem and [1, 2, 5].all? {|i| previous_problem[i] == new_problem[i]}
80 previous_problem[0] << $problems_count
81 previous_problem[3] << arch
82 else
83 $problems << new_problem
84 end
314e73e @takaokouji supported show known problems.
takaokouji authored
85 when 'f', 'e'
86 $known_problems_count += 1
87 new_known_problem = [[$known_problems_count], code, expectation, [arch], command, output, $current_file]
88 previous_known_problem = $known_problems.last
89 if previous_known_problem and [1, 2, 5].all? {|i| previous_known_problem[i] == new_known_problem[i]}
90 previous_known_problem[0] << $known_problems_count
91 previous_known_problem[3] << arch
92 else
93 $known_problems << new_known_problem
94 end
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
95 end
96 $assertions_count += 1
97 end
98 end
99 end
100
187641c fixed the rakefile + launcher
Laurent Sansonetti authored
101 Dir.chdir("#{File.dirname(__FILE__)}/test_vm")
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
102 $tests = Dir.glob('*.rb').map {|filename| File.basename(filename, '.rb')}.sort
103
104 $test_only = $tests if $test_only.empty?
105 $test_only.each do |what|
31aca7b @takaokouji import RDoc 3.5.3 and fix it for MacRuby.
takaokouji authored
106 $current_file = "./#{what}.rb"
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
107 print "#{what} "
108 $stdout.flush
31aca7b @takaokouji import RDoc 3.5.3 and fix it for MacRuby.
takaokouji authored
109 load $current_file
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
110 puts
111 end
112
314e73e @takaokouji supported show known problems.
takaokouji authored
113 def print_problems(problems)
114 problems.each do |ids, code, expectation, archs, command, output, file|
115 puts ''
116 puts "Problem#{ids.length > 1 ? 's' : ''} #{ids.join(', ')}:"
117 puts "Code: #{code}"
118 puts "Arch#{archs.length > 1 ? 's' : ''}: #{archs.join(', ')}"
119 puts "Command: #{command}"
120 puts "Expectation: #{expectation}"
121 puts "Output: #{output}"
122 puts "File: #{file}"
123 end
124 end
125
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
126 at_exit do
314e73e @takaokouji supported show known problems.
takaokouji authored
127 exit_code = 0
128 if $problems.empty? && $known_problems.empty?
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
129 puts "Successfully passed all #{$assertions_count} assertions."
130 else
314e73e @takaokouji supported show known problems.
takaokouji authored
131 problems_count = $problems_count + $known_problems_count
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
132 puts ''
314e73e @takaokouji supported show known problems.
takaokouji authored
133 puts "#{problems_count} assertion#{problems_count > 1 ? 's' : ''} over #{$assertions_count} failed."
134 if $problems_count > 0
135 puts ''
136 puts "#{$problems_count} problem#{$problems_count > 1 ? 's' : ''} failed:"
137 print_problems($problems)
138 exit_code = 1
139 end
140 if $known_problems_count > 0
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
141 puts ''
314e73e @takaokouji supported show known problems.
takaokouji authored
142 puts "#{$known_problems_count} known problem#{$known_problems_count > 1 ? 's' : ''} failed: "
143 print_problems($known_problems)
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
144 end
145 end
314e73e @takaokouji supported show known problems.
takaokouji authored
146 exit(exit_code)
a13b22a @vincentisambart splitted test_roxor.rb in multiple files
vincentisambart authored
147 end
Something went wrong with that request. Please try again.