100
100
_COLLECTING_COVERAGE = False
101
101
102
102
CI = os .environ .get ("CI" ) == "true"
103
- BUILD_NATIVE_IMAGE_WITH_ASSERTIONS = CI and sys .platform != "win32" # disable assertions on win32 until we properly support that platform
103
+ WIN32 = sys .platform == "win32"
104
+ BUILD_NATIVE_IMAGE_WITH_ASSERTIONS = CI and WIN32 # disable assertions on win32 until we properly support that platform
104
105
105
106
if CI and not os .environ .get ("GRAALPYTEST_FAIL_FAST" ):
106
107
os .environ ["GRAALPYTEST_FAIL_FAST" ] = "true"
@@ -273,7 +274,7 @@ def do_run_python(args, extra_vm_args=None, env=None, jdk=None, extra_dists=None
273
274
jdk = get_jdk ()
274
275
275
276
# default: assertion checking is enabled
276
- if extra_vm_args is None or '-da' not in extra_vm_args :
277
+ if not WIN32 and ( extra_vm_args is None or '-da' not in extra_vm_args ) :
277
278
vm_args += ['-ea' , '-esa' ]
278
279
279
280
if extra_vm_args :
@@ -726,7 +727,7 @@ def _graalvm_home(*, envfile, extra_dy=""):
726
727
def _join_bin (home , name ):
727
728
if sys .platform == "darwin" and not re .search ("Contents/Home/?$" , home ):
728
729
return os .path .join (home , "Contents" , "Home" , "bin" , name )
729
- elif sys . platform == "win32" :
730
+ elif WIN32 :
730
731
return os .path .join (home , "bin" , f"{ name } .cmd" )
731
732
else :
732
733
return os .path .join (home , "bin" , name )
@@ -868,8 +869,13 @@ def _list_graalpython_unittests(paths=None, exclude=None):
868
869
paths = paths or [_graalpytest_root ()]
869
870
def is_included (path ):
870
871
if path .endswith (".py" ):
872
+ path = path .replace ("\\ " , "/" )
871
873
basename = os .path .basename (path )
872
- return basename .startswith ("test_" ) and basename not in exclude
874
+ return (
875
+ basename .startswith ("test_" )
876
+ and basename not in exclude
877
+ and not any (fnmatch .fnmatch (path , pat ) for pat in exclude )
878
+ )
873
879
return False
874
880
875
881
testfiles = []
@@ -882,10 +888,10 @@ def is_included(path):
882
888
else :
883
889
for testfile in glob .glob (os .path .join (path , "**/test_*.py" )):
884
890
if is_included (testfile ):
885
- testfiles .append (testfile )
891
+ testfiles .append (testfile . replace ( " \\ " , "/" ) )
886
892
for testfile in glob .glob (os .path .join (path , "test_*.py" )):
887
893
if is_included (testfile ):
888
- testfiles .append (testfile )
894
+ testfiles .append (testfile . replace ( " \\ " , "/" ) )
889
895
return testfiles
890
896
891
897
@@ -926,13 +932,6 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Fa
926
932
else :
927
933
args += [_graalpytest_driver (), "-v" ]
928
934
929
- if report :
930
- reportfile = None
931
- t0 = time .time ()
932
- if not use_pytest :
933
- reportfile = os .path .abspath (tempfile .mktemp (prefix = "test-report-" , suffix = ".json" ))
934
- args += ["--report" , reportfile ]
935
-
936
935
result = 0
937
936
if is_collecting_coverage ():
938
937
env ['ENABLE_THREADED_GRAALPYTEST' ] = "false"
@@ -945,24 +944,38 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Fa
945
944
for testfile in testfiles :
946
945
mx .run ([python_binary ] + args + [testfile ], nonZeroIsFatal = nonZeroIsFatal , env = env , cwd = cwd , out = out , err = err , timeout = timeout )
947
946
else :
948
- if javaAsserts :
949
- args += ['-ea' ]
950
-
951
- args += testfiles
952
- mx .logv (" " .join ([python_binary ] + args ))
953
- if lock :
954
- lock .release ()
955
- result = mx .run ([python_binary ] + args , nonZeroIsFatal = nonZeroIsFatal , env = env , cwd = cwd , out = out , err = err , timeout = timeout )
956
-
957
- if report :
958
- if reportfile :
959
- mx_gate .make_test_report (reportfile , report .title )
947
+ if WIN32 :
948
+ size = 5
949
+ testfiles = [testfiles [i :i + size ] for i in range (0 , len (testfiles ), size )]
960
950
else :
961
- mx_gate .make_test_report ([{
962
- "name" : report .title ,
963
- "status" : "PASSED" if result == 0 else "FAILED" ,
964
- "duration" : int ((time .time () - t0 ) * 1000 )
965
- }], report .title )
951
+ testfiles = [testfiles ]
952
+
953
+ for testset in testfiles :
954
+ next_args = args [:]
955
+ if report :
956
+ reportfile = None
957
+ t0 = time .time ()
958
+ if not use_pytest :
959
+ reportfile = os .path .abspath (tempfile .mktemp (prefix = "test-report-" , suffix = ".json" ))
960
+ next_args += ["--report" , reportfile ]
961
+
962
+ next_args += testset
963
+ mx .logv (" " .join ([python_binary ] + next_args ))
964
+ if lock :
965
+ lock .release ()
966
+ result = result or mx .run ([python_binary ] + next_args , nonZeroIsFatal = nonZeroIsFatal , env = env , cwd = cwd , out = out , err = err , timeout = timeout )
967
+ if lock :
968
+ lock .acquire ()
969
+
970
+ if report :
971
+ if reportfile :
972
+ mx_gate .make_test_report (reportfile , report .title )
973
+ else :
974
+ mx_gate .make_test_report ([{
975
+ "name" : report .title ,
976
+ "status" : "PASSED" if result == 0 else "FAILED" ,
977
+ "duration" : int ((time .time () - t0 ) * 1000 )
978
+ }], report .title )
966
979
return result
967
980
968
981
@@ -1133,17 +1146,52 @@ def run_tagged_unittests(python_binary, env=None, cwd=None, javaAsserts=False, n
1133
1146
def graalpython_gate_runner (args , tasks ):
1134
1147
report = lambda : (not is_collecting_coverage ()) and task
1135
1148
nonZeroIsFatal = not is_collecting_coverage ()
1149
+ if WIN32 :
1150
+ excluded_tests = [
1151
+ "test_zipimport.py" , # sys.getwindowsversion
1152
+ "test_thread" , # sys.getwindowsversion
1153
+ "test_structseq" , # import posix
1154
+ "test_ssl" , # from_ssl import enum_certificates
1155
+ "test_posix" , # import posix
1156
+ "test_multiprocessing" , # import _winapi
1157
+ "test_mmap" , # sys.getwindowsversion
1158
+ "test_imports" , # import posix
1159
+ "test_ctypes_callbacks.py" , # ctypes error
1160
+ "test_code.py" , # forward slash in path problem
1161
+ "test_csv.py" , # module 'os' has no attribute 'O_TEMPORARY'
1162
+ "*/cpyext/*" ,
1163
+ ]
1164
+ else :
1165
+ excluded_tests = []
1136
1166
1137
1167
# JUnit tests
1138
1168
with Task ('GraalPython JUnit' , tasks , tags = [GraalPythonTags .junit ]) as task :
1139
1169
if task :
1140
- punittest (['--verbose' ], report = report ())
1170
+ if WIN32 :
1171
+ punittest (
1172
+ [
1173
+ "--verbose" ,
1174
+ "--no-leak-tests" ,
1175
+ "--regex" ,
1176
+ r'(com\.oracle\.truffle\.tck\.tests)|(graal\.python\.test\.(advance\.Benchmark|basic|builtin|decorator|generator|interop|util))'
1177
+ ],
1178
+ report = True
1179
+ )
1180
+ else :
1181
+ punittest (['--verbose' ], report = report ())
1141
1182
1142
1183
# Unittests on JVM
1143
1184
with Task ('GraalPython Python unittests' , tasks , tags = [GraalPythonTags .unittest ]) as task :
1144
1185
if task :
1145
- mx .run (["env" ])
1146
- run_python_unittests (python_gvm (), javaAsserts = True , nonZeroIsFatal = nonZeroIsFatal , report = report ())
1186
+ if not WIN32 :
1187
+ mx .run (["env" ])
1188
+ run_python_unittests (
1189
+ python_gvm (),
1190
+ javaAsserts = True ,
1191
+ exclude = excluded_tests ,
1192
+ nonZeroIsFatal = nonZeroIsFatal ,
1193
+ report = report ()
1194
+ )
1147
1195
1148
1196
with Task ('GraalPython Python unittests with CPython' , tasks , tags = [GraalPythonTags .unittest_cpython ]) as task :
1149
1197
if task :
@@ -1159,11 +1207,11 @@ def graalpython_gate_runner(args, tasks):
1159
1207
1160
1208
with Task ('GraalPython sandboxed tests' , tasks , tags = [GraalPythonTags .unittest_sandboxed ]) as task :
1161
1209
if task :
1162
- run_python_unittests (python_managed_gvm (), javaAsserts = True , report = report ())
1210
+ run_python_unittests (python_managed_gvm (), javaAsserts = True , exclude = excluded_tests , report = report ())
1163
1211
1164
1212
with Task ('GraalPython multi-context unittests' , tasks , tags = [GraalPythonTags .unittest_multi ]) as task :
1165
1213
if task :
1166
- run_python_unittests (python_gvm (), args = ["-multi-context" ], javaAsserts = True , nonZeroIsFatal = nonZeroIsFatal , report = report ())
1214
+ run_python_unittests (python_gvm (), args = ["-multi-context" ], javaAsserts = True , exclude = excluded_tests , nonZeroIsFatal = nonZeroIsFatal , report = report ())
1167
1215
1168
1216
with Task ('GraalPython Jython emulation tests' , tasks , tags = [GraalPythonTags .unittest_jython ]) as task :
1169
1217
if task :
@@ -1198,7 +1246,7 @@ def graalpython_gate_runner(args, tasks):
1198
1246
# Unittests on SVM
1199
1247
with Task ('GraalPython tests on SVM' , tasks , tags = [GraalPythonTags .svmunit ]) as task :
1200
1248
if task :
1201
- run_python_unittests (python_svm (), aot_compatible = True , report = report ())
1249
+ run_python_unittests (python_svm (), exclude = excluded_tests , aot_compatible = True , report = report ())
1202
1250
1203
1251
with Task ('GraalPython sandboxed tests on SVM' , tasks , tags = [GraalPythonTags .svmunit_sandboxed ]) as task :
1204
1252
if task :
@@ -1227,7 +1275,8 @@ def graalpython_gate_runner(args, tasks):
1227
1275
])
1228
1276
if success not in out .data :
1229
1277
mx .abort ('Output from generated SVM image "' + svm_image + '" did not match success pattern:\n ' + success )
1230
- assert "Using preinitialized context." in out .data
1278
+ if not WIN32 :
1279
+ assert "Using preinitialized context." in out .data
1231
1280
1232
1281
with Task ('GraalPython standalone build' , tasks , tags = [GraalPythonTags .svm , GraalPythonTags .graalvm , GraalPythonTags .embedding ], report = True ) as task :
1233
1282
if task :
0 commit comments