@@ -280,7 +280,7 @@ def run_cpython_test(args):
280
280
testfiles = []
281
281
for g in globs :
282
282
testfiles += glob .glob (os .path .join (SUITE .dir , "graalpython/lib-python/3/test" , "%s*" % g ))
283
- mx .run ([python_gvm ()] + interp_args + [
283
+ mx .run ([python_gvm_with_assertions ()] + interp_args + [
284
284
os .path .join (SUITE .dir , "graalpython/com.oracle.graal.python.test/src/tests/run_cpython_test.py" ),
285
285
] + test_args + testfiles )
286
286
@@ -309,7 +309,7 @@ def retag_unittests(args):
309
309
'graalpython/com.oracle.graal.python.test/src/tests/test_tagged_unittests.py' ,
310
310
'--retag'
311
311
]
312
- mx .run ([python_gvm ()] + args + remaining_args , env = env )
312
+ mx .run ([python_gvm_with_assertions ()] + args + remaining_args , env = env )
313
313
if parsed_args .upload_results_to :
314
314
with tempfile .TemporaryDirectory (prefix = 'graalpython-retagger-' ) as d :
315
315
filename = os .path .join (d , 'unittest-tags-{}.tar.bz2' .format (sys .platform ))
@@ -484,6 +484,12 @@ def python_gvm(args=None, **kwargs):
484
484
return _python_graalvm_launcher (args or [], ** kwargs )
485
485
486
486
487
+ def python_gvm_with_assertions (args = None , ** kwargs ):
488
+ launcher = python_gvm (args , ** kwargs )
489
+ patch_batch_launcher (launcher , '-ea' )
490
+ return launcher
491
+
492
+
487
493
def python_svm (args = None , ** kwargs ):
488
494
"Build and run the native graalpython image"
489
495
with set_env (FORCE_BASH_LAUNCHERS = "true" , NATIVE_IMAGES = "graalpython" , DISABLE_LIBPOLYGLOT = "true" , DISABLE_POLYGLOT = "true" ):
@@ -621,12 +627,7 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Fa
621
627
launcher_path_bak = launcher_path + ".bak"
622
628
shutil .copy (launcher_path , launcher_path_bak )
623
629
try :
624
- with open (launcher_path , 'r' , encoding = 'ascii' , errors = 'ignore' ) as launcher :
625
- lines = launcher .readlines ()
626
- assert re .match (r'^#!.*bash' , lines [0 ]), "jacoco needs a bash launcher"
627
- lines .insert (- 1 , 'jvm_args+=(%s)\n ' % agent_args )
628
- with open (launcher_path , 'w' ) as launcher :
629
- launcher .writelines (lines )
630
+ patch_batch_launcher (launcher_path , agent_args )
630
631
# jacoco only dumps the data on exit, and when we run all our unittests
631
632
# at once it generates so much data we run out of heap space
632
633
for testfile in testfiles :
@@ -639,6 +640,15 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Fa
639
640
return mx .run ([python_binary ] + args , nonZeroIsFatal = True , env = env )
640
641
641
642
643
+ def patch_batch_launcher (launcher_path , jvm_args ):
644
+ with open (launcher_path , 'r' , encoding = 'ascii' , errors = 'ignore' ) as launcher :
645
+ lines = launcher .readlines ()
646
+ assert re .match (r'^#!.*bash' , lines [0 ]), "expected a bash launcher"
647
+ lines .insert (- 1 , 'jvm_args+=(%s)\n ' % jvm_args )
648
+ with open (launcher_path , 'w' ) as launcher :
649
+ launcher .writelines (lines )
650
+
651
+
642
652
def run_hpy_unittests (python_binary , args = None ):
643
653
args = [] if args is None else args
644
654
with tempfile .TemporaryDirectory (prefix = 'hpy-test-site-' ) as d :
@@ -690,36 +700,36 @@ def graalpython_gate_runner(args, tasks):
690
700
test_args = [exe , _graalpytest_driver (), "-v" , _graalpytest_root ()]
691
701
mx .run (test_args , nonZeroIsFatal = True , env = env )
692
702
mx .run (["env" ])
693
- run_python_unittests (python_gvm ())
703
+ run_python_unittests (python_gvm_with_assertions ())
694
704
695
705
with Task ('GraalPython sandboxed tests' , tasks , tags = [GraalPythonTags .unittest_sandboxed ]) as task :
696
706
if task :
697
- run_python_unittests (python_gvm (["sandboxed" ]))
707
+ run_python_unittests (python_gvm_with_assertions (["sandboxed" ]))
698
708
699
709
with Task ('GraalPython multi-context unittests' , tasks , tags = [GraalPythonTags .unittest_multi ]) as task :
700
710
if task :
701
- run_python_unittests (python_gvm (), args = ["-multi-context" ])
711
+ run_python_unittests (python_gvm_with_assertions (), args = ["-multi-context" ])
702
712
703
713
with Task ('GraalPython Jython emulation tests' , tasks , tags = [GraalPythonTags .unittest_jython ]) as task :
704
714
if task :
705
- run_python_unittests (python_gvm (), args = ["--python.EmulateJython" ], paths = ["test_interop.py" ])
715
+ run_python_unittests (python_gvm_with_assertions (), args = ["--python.EmulateJython" ], paths = ["test_interop.py" ])
706
716
707
717
with Task ('GraalPython HPy tests' , tasks , tags = [GraalPythonTags .unittest_hpy ]) as task :
708
718
if task :
709
- run_hpy_unittests (python_gvm ())
719
+ run_hpy_unittests (python_gvm_with_assertions ())
710
720
711
721
with Task ('GraalPython HPy sandboxed tests' , tasks , tags = [GraalPythonTags .unittest_hpy_sandboxed ]) as task :
712
722
if task :
713
- run_hpy_unittests (python_gvm (["sandboxed" ]))
723
+ run_hpy_unittests (python_gvm_with_assertions (["sandboxed" ]))
714
724
715
725
with Task ('GraalPython posix module tests' , tasks , tags = [GraalPythonTags .unittest_posix ]) as task :
716
726
if task :
717
- run_python_unittests (python_gvm (), args = ["--PosixModuleBackend=native" ], paths = ["test_posix.py" , "test_mmap.py" ])
718
- run_python_unittests (python_gvm (), args = ["--PosixModuleBackend=java" ], paths = ["test_posix.py" , "test_mmap.py" ])
727
+ run_python_unittests (python_gvm_with_assertions (), args = ["--PosixModuleBackend=native" ], paths = ["test_posix.py" , "test_mmap.py" ])
728
+ run_python_unittests (python_gvm_with_assertions (), args = ["--PosixModuleBackend=java" ], paths = ["test_posix.py" , "test_mmap.py" ])
719
729
720
730
with Task ('GraalPython Python tests' , tasks , tags = [GraalPythonTags .tagged ]) as task :
721
731
if task :
722
- run_tagged_unittests (python_gvm ())
732
+ run_tagged_unittests (python_gvm_with_assertions ())
723
733
724
734
# Unittests on SVM
725
735
with Task ('GraalPython tests on SVM' , tasks , tags = [GraalPythonTags .svmunit ]) as task :
@@ -1621,7 +1631,7 @@ def python_coverage(args):
1621
1631
'coverage-upload' ,
1622
1632
])
1623
1633
if args .truffle :
1624
- executable = python_gvm ()
1634
+ executable = python_gvm_with_assertions ()
1625
1635
variants = [
1626
1636
{"args" : []},
1627
1637
{"args" : ["--python.EmulateJython" ], "paths" : ["test_interop.py" ]},
0 commit comments