Skip to content

Commit 56efda3

Browse files
committed
Add a zjit test runner to run against all tests
1 parent 38993ef commit 56efda3

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

zjit/test_runner.rb

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
require "pathname"
2+
3+
# Tests that are known to fail or cause issues with ZJIT
4+
excluded = [
5+
"test/ruby/bug-11928.rb",
6+
"test/ruby/namespace/call_toplevel.rb",
7+
"test/ruby/namespace/current.rb",
8+
"test/ruby/namespace/ns.rb",
9+
"test/ruby/namespace/raise.rb",
10+
"test/ruby/namespace/string_ext_calling.rb",
11+
"test/ruby/namespace/string_ext_eval_caller.rb",
12+
"test/ruby/test_alias.rb",
13+
"test/ruby/test_allocation.rb",
14+
"test/ruby/test_ast.rb",
15+
"test/ruby/test_autoload.rb",
16+
"test/ruby/test_backtrace.rb",
17+
"test/ruby/test_call.rb",
18+
"test/ruby/test_class.rb",
19+
"test/ruby/test_compile_prism.rb",
20+
"test/ruby/test_data.rb",
21+
"test/ruby/test_defined.rb",
22+
"test/ruby/test_dir_m17n.rb",
23+
"test/ruby/test_env.rb",
24+
"test/ruby/test_enumerator.rb",
25+
"test/ruby/test_fiber.rb",
26+
"test/ruby/test_file.rb",
27+
"test/ruby/test_file_exhaustive.rb",
28+
"test/ruby/test_float.rb",
29+
"test/ruby/test_gc.rb",
30+
"test/ruby/test_hash.rb",
31+
"test/ruby/test_io.rb",
32+
"test/ruby/test_iseq.rb",
33+
"test/ruby/test_keyword.rb",
34+
"test/ruby/test_lambda.rb",
35+
"test/ruby/test_literal.rb",
36+
"test/ruby/test_marshal.rb",
37+
"test/ruby/test_memory_view.rb",
38+
"test/ruby/test_method.rb",
39+
"test/ruby/test_module.rb",
40+
"test/ruby/test_namespace.rb",
41+
"test/ruby/test_object.rb",
42+
"test/ruby/test_object_id.rb",
43+
"test/ruby/test_objectspace.rb",
44+
"test/ruby/test_optimization.rb",
45+
"test/ruby/test_parse.rb",
46+
"test/ruby/test_proc.rb",
47+
"test/ruby/test_process.rb",
48+
"test/ruby/test_ractor.rb",
49+
"test/ruby/test_range.rb",
50+
"test/ruby/test_regexp.rb",
51+
"test/ruby/test_rubyoptions.rb",
52+
"test/ruby/test_set.rb",
53+
"test/ruby/test_settracefunc.rb",
54+
"test/ruby/test_string.rb",
55+
"test/ruby/test_struct.rb",
56+
"test/ruby/test_syntax.rb",
57+
"test/ruby/test_thread.rb",
58+
"test/ruby/test_time_tz.rb",
59+
"test/ruby/test_variable.rb",
60+
"test/ruby/test_vm_dump.rb",
61+
"test/ruby/test_yjit.rb",
62+
]
63+
64+
repo_root = ENV["CI"] ? "../src" : "."
65+
miniruby = Dir.exist?("#{repo_root}/build") ? "#{repo_root}/build/miniruby" : "#{repo_root}/miniruby"
66+
test_runner = "#{repo_root}/test/runner.rb"
67+
miniruby_opts = "-I#{repo_root}/lib -I. -I.ext/common --zjit-call-threshold=1"
68+
test_dir = "#{repo_root}/test/ruby"
69+
70+
total_test_files = Dir.glob("#{test_dir}/**/*.rb")
71+
72+
# Filter out excluded tests
73+
test_files = total_test_files.reject do |file|
74+
excluded.any? { |excluded_file| file.end_with?(excluded_file) }
75+
end
76+
77+
command = "RUST_BACKTRACE=1 ruby --disable=gems #{test_runner} --ruby=\"#{miniruby} #{miniruby_opts}\""
78+
79+
puts "Running #{test_files.length} (#{total_test_files.length} total) test files with ZJIT..."
80+
puts "Command: #{command}"
81+
82+
# Run each test
83+
test_files.each_with_index do |test_file, idx|
84+
relative_path = Pathname.new(test_file).relative_path_from(Pathname.new("."))
85+
print "[#{idx + 1}/#{test_files.length}] #{relative_path}... "
86+
87+
# Build command using the test runner framework
88+
cmd = %Q{#{command} #{test_file} 2>&1}
89+
90+
# Run test
91+
output = `#{cmd}`
92+
exit_code = $?.exitstatus
93+
94+
if exit_code == 0
95+
print "OK\n"
96+
else
97+
print "FAILED\n"
98+
puts output
99+
end
100+
end

0 commit comments

Comments
 (0)