21
21
require 'pathname'
22
22
23
23
TRUFFLERUBY_DIR = File . expand_path ( '../..' , File . realpath ( __FILE__ ) )
24
- MRI_TEST_CEXT_DIR = "#{ TRUFFLERUBY_DIR } /test/mri/tests/cext-c"
25
- MRI_TEST_CEXT_LIB_DIR = "#{ TRUFFLERUBY_DIR } /.ext/c"
26
24
PROFILES_DIR = "#{ TRUFFLERUBY_DIR } /profiles"
27
25
28
26
TRUFFLERUBY_GEM_TEST_PACK_VERSION = "8b57f6022f0fa17ace7c8d2a3af730357715e0a2"
52
50
53
51
require "#{ TRUFFLERUBY_DIR } /lib/truffle/truffle/openssl-prefix.rb"
54
52
53
+ MRI_TEST_RELATIVE_PREFIX = "test/mri/tests"
54
+ MRI_TEST_PREFIX = "#{ TRUFFLERUBY_DIR } /#{ MRI_TEST_RELATIVE_PREFIX } "
55
+ MRI_TEST_CEXT_DIR = "#{ MRI_TEST_PREFIX } /cext-c"
56
+ MRI_TEST_CEXT_LIB_DIR = "#{ TRUFFLERUBY_DIR } /.ext/c"
57
+
58
+ # A list of MRI C API tests we can load. Tests that do not load at all are in failing.exclude.
59
+ MRI_TEST_CAPI_TESTS = File . readlines ( "#{ TRUFFLERUBY_DIR } /test/mri/capi_tests.list" ) . map ( &:chomp )
60
+
55
61
MRI_TEST_MODULES = {
56
- '--no-sulong' => {
57
- help : 'exclude all tests requiring Sulong' ,
58
- exclude : "#{ TRUFFLERUBY_DIR } /test/mri/sulong.exclude"
59
- } ,
60
62
'--openssl' => {
61
63
help : 'include only openssl tests' ,
62
- include : openssl = [ "#{ TRUFFLERUBY_DIR } /test/mri/tests/ openssl/test_*.rb" ] ,
64
+ include : openssl = [ "openssl/test_*.rb" ] ,
63
65
} ,
64
66
'--syslog' => {
65
67
help : 'include only syslog tests' ,
66
68
include : syslog = [
67
- "#{ TRUFFLERUBY_DIR } /test/mri/tests/ test_syslog.rb" ,
68
- "#{ TRUFFLERUBY_DIR } /test/mri/tests/ syslog/test_syslog_logger.rb"
69
+ "test_syslog.rb" ,
70
+ "syslog/test_syslog_logger.rb"
69
71
]
70
72
} ,
71
- '--cext' => {
72
- help : 'include only tests requiring Sulong' ,
73
- include : openssl + syslog + [
74
- "#{ TRUFFLERUBY_DIR } /test/mri/tests/cext-ruby/**/test_*.rb" ,
75
- "#{ TRUFFLERUBY_DIR } /test/mri/tests/etc/test_etc.rb" ,
73
+ '--cexts' => {
74
+ help : 'run all MRI tests testing C extensions' ,
75
+ include : cexts = openssl + syslog + [
76
+ "etc/test_etc.rb" ,
77
+ "nkf/test_kconv.rb" ,
78
+ "nkf/test_nkf.rb" ,
79
+ "zlib/test_zlib.rb" ,
76
80
]
77
- }
81
+ } ,
82
+ '--capi' => {
83
+ help : 'run all C-API MRI tests' ,
84
+ include : capi = MRI_TEST_CAPI_TESTS ,
85
+ } ,
86
+ '--all-sulong' => {
87
+ help : 'run all tests requiring Sulong (C exts and C API)' ,
88
+ include : all_sulong = cexts + capi
89
+ } ,
90
+ '--no-sulong' => {
91
+ help : 'exclude all tests requiring Sulong' ,
92
+ exclude : all_sulong
93
+ } ,
78
94
}
79
95
80
96
SUBPROCESSES = [ ]
@@ -970,55 +986,55 @@ def test_mri(*args)
970
986
end
971
987
972
988
mri_args = [ ]
973
- prefix = "#{ TRUFFLERUBY_DIR } /test/mri/tests/"
974
- 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? )
975
991
patterns = [ ]
976
992
977
993
args . each do |arg |
978
994
test_module = MRI_TEST_MODULES [ arg ]
979
995
if test_module
980
996
patterns . push ( *test_module [ :include ] )
981
- exclusions . push ( *test_module [ :exclude ] )
997
+ excluded_files . push ( *test_module [ :exclude ] )
982
998
elsif arg . start_with? ( '-' )
983
999
mri_args . push arg
984
1000
else
985
1001
patterns . push arg
986
1002
end
987
1003
end
988
1004
989
- patterns . push "#{ TRUFFLERUBY_DIR } /test/mri/tests/**/test_*.rb" if patterns . empty?
990
-
991
- excluded_files = exclusions .
992
- flat_map { |f | File . readlines ( f ) } .
993
- map { |l | l . gsub ( /#.*/ , '' ) . strip } .
994
- reject ( &:empty? )
1005
+ patterns . push "#{ MRI_TEST_PREFIX } /**/test_*.rb" if patterns . empty?
995
1006
996
1007
files_to_run = patterns . flat_map do |pattern |
997
- Dir . glob ( pattern ) . map do |path |
998
- expanded_path = File . expand_path path
999
- raise 'pattern does not match test files' unless expanded_path . start_with? ( prefix )
1000
- expanded_path [ prefix . size ..-1 ]
1001
- end . reject do |path |
1002
- path . empty?
1008
+ if pattern . start_with? ( MRI_TEST_RELATIVE_PREFIX )
1009
+ pattern = "#{ TRUFFLERUBY_DIR } /#{ pattern } "
1010
+ elsif !pattern . start_with? ( MRI_TEST_PREFIX )
1011
+ pattern = "#{ MRI_TEST_PREFIX } /#{ pattern } "
1003
1012
end
1004
- end . sort - excluded_files
1013
+ glob = Dir . glob ( pattern )
1014
+ abort "pattern #{ pattern } matched no files" if glob . empty?
1015
+ glob . map { |path | mri_test_name ( path ) }
1016
+ end . sort
1017
+ files_to_run -= excluded_files
1005
1018
1006
1019
run_mri_tests ( mri_args , files_to_run , runner_args , use_exec : true )
1007
1020
end
1008
1021
private :test_mri
1009
1022
1023
+ def mri_test_name ( test )
1024
+ prefix = "#{ MRI_TEST_RELATIVE_PREFIX } /"
1025
+ abs_prefix = "#{ MRI_TEST_PREFIX } /"
1026
+ if test . start_with? ( prefix )
1027
+ test [ prefix . size ..-1 ]
1028
+ elsif test . start_with? ( abs_prefix )
1029
+ test [ abs_prefix . size ..-1 ]
1030
+ else
1031
+ test
1032
+ end
1033
+ end
1034
+ private :mri_test_name
1035
+
1010
1036
def run_mri_tests ( extra_args , test_files , runner_args , run_options )
1011
- prefix = "test/mri/tests/"
1012
- abs_prefix = "#{ TRUFFLERUBY_DIR } /#{ prefix } "
1013
- test_files = test_files . map { |file |
1014
- if file . start_with? ( prefix )
1015
- file [ prefix . size ..-1 ]
1016
- elsif file . start_with? ( abs_prefix )
1017
- file [ abs_prefix . size ..-1 ]
1018
- else
1019
- file
1020
- end
1021
- }
1037
+ test_files = test_files . map { |file | mri_test_name ( file ) }
1022
1038
1023
1039
truffle_args = [ ]
1024
1040
if !extra_args . include? ( '--native' )
@@ -1027,7 +1043,7 @@ def run_mri_tests(extra_args, test_files, runner_args, run_options)
1027
1043
1028
1044
env_vars = {
1029
1045
"EXCLUDES" => "test/mri/excludes" ,
1030
- "RUBYGEMS_TEST_PATH" => " #{ TRUFFLERUBY_DIR } /test/mri/tests" ,
1046
+ "RUBYGEMS_TEST_PATH" => MRI_TEST_PREFIX ,
1031
1047
"RUBYOPT" => [ *ENV [ 'RUBYOPT' ] , '--disable-gems' ] . join ( ' ' ) ,
1032
1048
"TRUFFLERUBY_RESILIENT_GEM_HOME" => nil ,
1033
1049
}
@@ -1043,7 +1059,7 @@ def run_mri_tests(extra_args, test_files, runner_args, run_options)
1043
1059
cext_tests . each do |test |
1044
1060
puts
1045
1061
puts test
1046
- test_path = "#{ TRUFFLERUBY_DIR } /test/mri/tests /#{ test } "
1062
+ test_path = "#{ MRI_TEST_PREFIX } /#{ test } "
1047
1063
match = File . read ( test_path ) . match ( /\b require ['"]c\/ (.*?)["']/ )
1048
1064
if match
1049
1065
cext_name = match [ 1 ]
@@ -1935,6 +1951,8 @@ def install_graal(*options)
1935
1951
end
1936
1952
1937
1953
def build_graalvm ( *options )
1954
+ mx ( '-p' , TRUFFLERUBY_DIR , 'sforceimports' ) unless ci?
1955
+
1938
1956
java_home = ci? ? nil : ENV [ "JVMCI_HOME" ] || install_jvmci
1939
1957
mx_args = [ '-p' , TRUFFLERUBY_DIR , '--dynamicimports' , '/vm' ]
1940
1958
0 commit comments