Skip to content

Commit 4f6ae6e

Browse files
committed
run some of our default gates also on windows
1 parent 7149675 commit 4f6ae6e

File tree

2 files changed

+89
-38
lines changed

2 files changed

+89
-38
lines changed

graalpython/com.oracle.graal.python.test/src/graalpytest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,11 +700,12 @@ def find_conftest(test_module_path):
700700
return None
701701

702702
def load_module(self, path):
703+
path = path.replace("\\", "/")
703704
name = path.rpartition("/")[2].partition(".")[0].replace('.py', '')
704705
directory = path.rpartition("/")[0]
705706
pkg = []
706707
while directory and any(f.endswith("__init__.py") for f in os.listdir(directory)):
707-
directory, slash, postfix = directory.rpartition("/")
708+
directory, slash, postfix = directory.replace("\\", "/").rpartition("/")
708709
pkg.insert(0, postfix)
709710
if pkg:
710711
sys.path.insert(0, directory)
@@ -864,6 +865,7 @@ class TestSuite:
864865
else:
865866
verbose = False
866867
paths = argv[1:]
868+
paths = [p.replace("\\", "/") for p in paths]
867869

868870
python_paths = set()
869871
for pth in paths:

mx.graalpython/mx_graalpython.py

Lines changed: 86 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
_COLLECTING_COVERAGE = False
101101

102102
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
104105

105106
if CI and not os.environ.get("GRAALPYTEST_FAIL_FAST"):
106107
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
273274
jdk = get_jdk()
274275

275276
# 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):
277278
vm_args += ['-ea', '-esa']
278279

279280
if extra_vm_args:
@@ -726,7 +727,7 @@ def _graalvm_home(*, envfile, extra_dy=""):
726727
def _join_bin(home, name):
727728
if sys.platform == "darwin" and not re.search("Contents/Home/?$", home):
728729
return os.path.join(home, "Contents", "Home", "bin", name)
729-
elif sys.platform == "win32":
730+
elif WIN32:
730731
return os.path.join(home, "bin", f"{name}.cmd")
731732
else:
732733
return os.path.join(home, "bin", name)
@@ -868,8 +869,13 @@ def _list_graalpython_unittests(paths=None, exclude=None):
868869
paths = paths or [_graalpytest_root()]
869870
def is_included(path):
870871
if path.endswith(".py"):
872+
path = path.replace("\\", "/")
871873
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+
)
873879
return False
874880

875881
testfiles = []
@@ -882,10 +888,10 @@ def is_included(path):
882888
else:
883889
for testfile in glob.glob(os.path.join(path, "**/test_*.py")):
884890
if is_included(testfile):
885-
testfiles.append(testfile)
891+
testfiles.append(testfile.replace("\\", "/"))
886892
for testfile in glob.glob(os.path.join(path, "test_*.py")):
887893
if is_included(testfile):
888-
testfiles.append(testfile)
894+
testfiles.append(testfile.replace("\\", "/"))
889895
return testfiles
890896

891897

@@ -926,13 +932,6 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Fa
926932
else:
927933
args += [_graalpytest_driver(), "-v"]
928934

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-
936935
result = 0
937936
if is_collecting_coverage():
938937
env['ENABLE_THREADED_GRAALPYTEST'] = "false"
@@ -945,24 +944,38 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Fa
945944
for testfile in testfiles:
946945
mx.run([python_binary] + args + [testfile], nonZeroIsFatal=nonZeroIsFatal, env=env, cwd=cwd, out=out, err=err, timeout=timeout)
947946
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)]
960950
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)
966979
return result
967980

968981

@@ -1133,17 +1146,52 @@ def run_tagged_unittests(python_binary, env=None, cwd=None, javaAsserts=False, n
11331146
def graalpython_gate_runner(args, tasks):
11341147
report = lambda: (not is_collecting_coverage()) and task
11351148
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 = []
11361166

11371167
# JUnit tests
11381168
with Task('GraalPython JUnit', tasks, tags=[GraalPythonTags.junit]) as task:
11391169
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())
11411182

11421183
# Unittests on JVM
11431184
with Task('GraalPython Python unittests', tasks, tags=[GraalPythonTags.unittest]) as task:
11441185
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+
)
11471195

11481196
with Task('GraalPython Python unittests with CPython', tasks, tags=[GraalPythonTags.unittest_cpython]) as task:
11491197
if task:
@@ -1159,11 +1207,11 @@ def graalpython_gate_runner(args, tasks):
11591207

11601208
with Task('GraalPython sandboxed tests', tasks, tags=[GraalPythonTags.unittest_sandboxed]) as task:
11611209
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())
11631211

11641212
with Task('GraalPython multi-context unittests', tasks, tags=[GraalPythonTags.unittest_multi]) as task:
11651213
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())
11671215

11681216
with Task('GraalPython Jython emulation tests', tasks, tags=[GraalPythonTags.unittest_jython]) as task:
11691217
if task:
@@ -1198,7 +1246,7 @@ def graalpython_gate_runner(args, tasks):
11981246
# Unittests on SVM
11991247
with Task('GraalPython tests on SVM', tasks, tags=[GraalPythonTags.svmunit]) as task:
12001248
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())
12021250

12031251
with Task('GraalPython sandboxed tests on SVM', tasks, tags=[GraalPythonTags.svmunit_sandboxed]) as task:
12041252
if task:
@@ -1227,7 +1275,8 @@ def graalpython_gate_runner(args, tasks):
12271275
])
12281276
if success not in out.data:
12291277
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
12311280

12321281
with Task('GraalPython standalone build', tasks, tags=[GraalPythonTags.svm, GraalPythonTags.graalvm, GraalPythonTags.embedding], report=True) as task:
12331282
if task:

0 commit comments

Comments
 (0)