Skip to content

Commit 8efd1da

Browse files
committed
Fix running MRI C extension and C-API tests in CI
* Improve naming and make it easy to run just C exts or just C API MRI tests. * Avoid duplication, and do not name it "exclude" when it's files we want to run.
1 parent 0089c8e commit 8efd1da

File tree

3 files changed

+28
-52
lines changed

3 files changed

+28
-52
lines changed

mx.truffleruby/mx_truffleruby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def ruby_testdownstream_sulong(args):
122122
jt('test', 'specs', ':capi')
123123
jt('test', 'specs', ':truffle_capi')
124124
jt('test', 'specs', ':library_cext')
125-
jt('test', 'mri', '--cext')
125+
jt('test', 'mri', '--all-sulong')
126126
jt('test', 'cexts')
127127
jt('test', 'bundle')
128128

test/mri/sulong.exclude renamed to test/mri/capi_tests.list

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -69,38 +69,4 @@ cext-ruby/wait_for_single_fd/test_wait_for_single_fd.rb
6969
cext-ruby/win32/test_console_attr.rb
7070
cext-ruby/win32/test_dln.rb
7171
cext-ruby/win32/test_fd_setsize.rb
72-
etc/test_etc.rb
73-
nkf/test_kconv.rb
74-
nkf/test_nkf.rb
75-
openssl/test_asn1.rb
76-
openssl/test_bn.rb
77-
openssl/test_buffering.rb
78-
openssl/test_cipher.rb
79-
openssl/test_config.rb
80-
openssl/test_digest.rb
81-
openssl/test_engine.rb
82-
openssl/test_fips.rb
83-
openssl/test_hmac.rb
84-
openssl/test_ns_spki.rb
85-
openssl/test_ocsp.rb
86-
openssl/test_pair.rb
87-
openssl/test_partial_record_read.rb
88-
openssl/test_pkcs12.rb
89-
openssl/test_pkcs5.rb
90-
openssl/test_pkcs7.rb
91-
openssl/test_pkey_dh.rb
92-
openssl/test_pkey_dsa.rb
93-
openssl/test_pkey_ec.rb
94-
openssl/test_pkey_rsa.rb
95-
openssl/test_ssl.rb
96-
openssl/test_ssl_session.rb
97-
openssl/test_x509cert.rb
98-
openssl/test_x509crl.rb
99-
openssl/test_x509ext.rb
100-
openssl/test_x509name.rb
101-
openssl/test_x509req.rb
102-
openssl/test_x509store.rb
10372
ruby/test_file_exhaustive.rb
104-
syslog/test_syslog_logger.rb
105-
test_syslog.rb
106-
zlib/test_zlib.rb

tool/jt.rb

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@
5252

5353
require "#{TRUFFLERUBY_DIR}/lib/truffle/truffle/openssl-prefix.rb"
5454

55+
# A list of MRI C API tests we can run. Files that do not load at all are in failing.exclude.
56+
MRI_TEST_CAPI_TESTS = File.readlines("#{TRUFFLERUBY_DIR}/test/mri/capi_tests.list").map { |line|
57+
"#{TRUFFLERUBY_DIR}/test/mri/tests/#{line.chomp}"
58+
}
59+
5560
MRI_TEST_MODULES = {
56-
'--no-sulong' => {
57-
help: 'exclude all tests requiring Sulong',
58-
exclude: "#{TRUFFLERUBY_DIR}/test/mri/sulong.exclude"
59-
},
6061
'--openssl' => {
6162
help: 'include only openssl tests',
62-
include: openssl = ["#{TRUFFLERUBY_DIR}/test/mri/tests/openssl/test_*.rb"],
63+
include: openssl = Dir["#{TRUFFLERUBY_DIR}/test/mri/tests/openssl/test_*.rb"].sort,
6364
},
6465
'--syslog' => {
6566
help: 'include only syslog tests',
@@ -68,14 +69,27 @@
6869
"#{TRUFFLERUBY_DIR}/test/mri/tests/syslog/test_syslog_logger.rb"
6970
]
7071
},
71-
'--cext' => {
72-
help: 'include only tests requiring Sulong',
73-
include: openssl + syslog + [
74-
"#{TRUFFLERUBY_DIR}/test/mri/tests/cext-ruby/**/test_*.rb",
72+
'--cexts' => {
73+
help: 'run all MRI tests testing C extensions',
74+
include: cexts = openssl + syslog + [
7575
"#{TRUFFLERUBY_DIR}/test/mri/tests/etc/test_etc.rb",
76+
"#{TRUFFLERUBY_DIR}/test/mri/tests/nkf/test_kconv.rb",
77+
"#{TRUFFLERUBY_DIR}/test/mri/tests/nkf/test_nkf.rb",
7678
"#{TRUFFLERUBY_DIR}/test/mri/tests/zlib/test_zlib.rb",
7779
]
78-
}
80+
},
81+
'--capi' => {
82+
help: 'run all C-API MRI tests',
83+
include: MRI_TEST_CAPI_TESTS,
84+
},
85+
'--all-sulong' => {
86+
help: 'run all tests requiring Sulong (C exts and C API)',
87+
include: all_sulong = cexts + MRI_TEST_CAPI_TESTS
88+
},
89+
'--no-sulong' => {
90+
help: 'exclude all tests requiring Sulong',
91+
exclude: all_sulong
92+
},
7993
}
8094

8195
SUBPROCESSES = []
@@ -972,14 +986,15 @@ def test_mri(*args)
972986

973987
mri_args = []
974988
prefix = "#{TRUFFLERUBY_DIR}/test/mri/tests/"
975-
exclusions = ["#{TRUFFLERUBY_DIR}/test/mri/failing.exclude"]
989+
excluded_files = File.readlines("#{TRUFFLERUBY_DIR}/test/mri/failing.exclude").
990+
map { |line| line.gsub(/#.*/, '').strip }.reject(&:empty?)
976991
patterns = []
977992

978993
args.each do |arg|
979994
test_module = MRI_TEST_MODULES[arg]
980995
if test_module
981996
patterns.push(*test_module[:include])
982-
exclusions.push(*test_module[:exclude])
997+
excluded_files.push(*test_module[:exclude])
983998
elsif arg.start_with?('-')
984999
mri_args.push arg
9851000
else
@@ -989,11 +1004,6 @@ def test_mri(*args)
9891004

9901005
patterns.push "#{TRUFFLERUBY_DIR}/test/mri/tests/**/test_*.rb" if patterns.empty?
9911006

992-
excluded_files = exclusions.
993-
flat_map { |f| File.readlines(f) }.
994-
map { |l| l.gsub(/#.*/, '').strip }.
995-
reject(&:empty?)
996-
9971007
files_to_run = patterns.flat_map do |pattern|
9981008
Dir.glob(pattern).map do |path|
9991009
expanded_path = File.expand_path path

0 commit comments

Comments
 (0)