36
36
import shlex
37
37
import shutil
38
38
import sys
39
+ import time
39
40
from functools import wraps
40
41
41
42
HPY_IMPORT_ORPHAN_BRANCH_NAME = "hpy-import"
@@ -281,7 +282,7 @@ def _dev_pythonhome():
281
282
return os .path .join (SUITE .dir , "graalpython" )
282
283
283
284
284
- def punittest (ars ):
285
+ def punittest (ars , report = False ):
285
286
"""
286
287
Runs GraalPython junit tests and memory leak tests, which can be skipped using --no-leak-tests.
287
288
@@ -300,7 +301,7 @@ def punittest(ars):
300
301
args += ars
301
302
args2 += ars
302
303
with _pythonhome_context ():
303
- mx_unittest .unittest (args )
304
+ mx_unittest .unittest (args , test_report_tags = ({ "task" : "punittest" } if report else None ) )
304
305
if len (args2 ) > len (ars ):
305
306
mx_unittest .unittest (args2 )
306
307
@@ -854,7 +855,7 @@ def is_included(path):
854
855
855
856
856
857
def run_python_unittests (python_binary , args = None , paths = None , aot_compatible = False , exclude = None , env = None ,
857
- use_pytest = False , cwd = None , lock = None , out = None , err = None , nonZeroIsFatal = True , javaAsserts = False , timeout = None ):
858
+ use_pytest = False , cwd = None , lock = None , out = None , err = None , nonZeroIsFatal = True , javaAsserts = False , timeout = None , report = False ):
858
859
if lock :
859
860
lock .acquire ()
860
861
# ensure that the test distribution is up-to-date
@@ -888,6 +889,14 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Fa
888
889
else :
889
890
args += [_graalpytest_driver (), "-v" ]
890
891
892
+ if report :
893
+ reportfile = None
894
+ t0 = time .time ()
895
+ if not use_pytest :
896
+ reportfile = os .path .abspath (tempfile .mktemp (prefix = "test-report-" , suffix = ".json" ))
897
+ args += ["--report" , reportfile ]
898
+
899
+ result = 0
891
900
if is_collectiong_coverage ():
892
901
env ['ENABLE_THREADED_GRAALPYTEST' ] = "false"
893
902
if mx_gate .get_jacoco_agent_args ():
@@ -906,7 +915,18 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Fa
906
915
mx .logv (" " .join ([python_binary ] + args ))
907
916
if lock :
908
917
lock .release ()
909
- return mx .run ([python_binary ] + args , nonZeroIsFatal = nonZeroIsFatal , env = env , cwd = cwd , out = out , err = err , timeout = timeout )
918
+ result = mx .run ([python_binary ] + args , nonZeroIsFatal = nonZeroIsFatal , env = env , cwd = cwd , out = out , err = err , timeout = timeout )
919
+
920
+ if report :
921
+ if reportfile :
922
+ mx_gate .make_test_report (reportfile , report .title )
923
+ else :
924
+ mx_gate .make_test_report ([{
925
+ "name" : report .title ,
926
+ "status" : "PASSED" if result == 0 else "FAILED" ,
927
+ "duration" : int ((time .time () - t0 ) * 1000 )
928
+ }], report .title )
929
+ return result
910
930
911
931
912
932
def get_venv_env (env_dir ):
@@ -966,7 +986,7 @@ def patch_batch_launcher(launcher_path, jvm_args):
966
986
launcher .writelines (lines )
967
987
968
988
969
- def run_hpy_unittests (python_binary , args = None , include_native = True , env = None , nonZeroIsFatal = True , timeout = None ):
989
+ def run_hpy_unittests (python_binary , args = None , include_native = True , env = None , nonZeroIsFatal = True , timeout = None , report = False ):
970
990
args = [] if args is None else args
971
991
with tempfile .TemporaryDirectory (prefix = 'hpy-test-site-' ) as d :
972
992
env = env or os .environ .copy ()
@@ -997,7 +1017,7 @@ def run(self):
997
1017
try :
998
1018
self .result = run_python_unittests (python_binary , args = args , paths = [_hpy_test_root ()],
999
1019
env = tenv , use_pytest = True , lock = lock , nonZeroIsFatal = False ,
1000
- out = self .out , err = self .out , timeout = timeout )
1020
+ out = self .out , err = self .out , timeout = timeout , report = report )
1001
1021
except BaseException as e : # pylint: disable=broad-except;
1002
1022
self .result = e
1003
1023
else :
@@ -1010,7 +1030,7 @@ def __init__(self, name):
1010
1030
def start (self ):
1011
1031
self .result = run_python_unittests (python_binary , args = args , paths = [_hpy_test_root ()],
1012
1032
env = tenv , use_pytest = True , nonZeroIsFatal = nonZeroIsFatal ,
1013
- timeout = timeout )
1033
+ timeout = timeout , report = report )
1014
1034
1015
1035
def join (self , * args , ** kwargs ):
1016
1036
return
@@ -1045,7 +1065,7 @@ def is_alive(self):
1045
1065
1046
1066
1047
1067
def run_tagged_unittests (python_binary , env = None , cwd = None , javaAsserts = False , nonZeroIsFatal = True ,
1048
- checkIfWithGraalPythonEE = False ):
1068
+ checkIfWithGraalPythonEE = False , report = False ):
1049
1069
python_path = os .path .join (_dev_pythonhome (), 'lib-python/3' )
1050
1070
sub_env = dict (
1051
1071
ENABLE_THREADED_GRAALPYTEST = "true" ,
@@ -1068,20 +1088,24 @@ def run_tagged_unittests(python_binary, env=None, cwd=None, javaAsserts=False, n
1068
1088
cwd = cwd ,
1069
1089
javaAsserts = javaAsserts ,
1070
1090
nonZeroIsFatal = nonZeroIsFatal ,
1091
+ report = report ,
1071
1092
)
1072
1093
1073
1094
1074
1095
def graalpython_gate_runner (args , tasks ):
1096
+ report = lambda : (not is_collectiong_coverage ()) and task
1097
+ nonZeroIsFatal = not is_collectiong_coverage ()
1098
+
1075
1099
# JUnit tests
1076
1100
with Task ('GraalPython JUnit' , tasks , tags = [GraalPythonTags .junit ]) as task :
1077
1101
if task :
1078
- punittest (['--verbose' ])
1102
+ punittest (['--verbose' ], report = report () )
1079
1103
1080
1104
# Unittests on JVM
1081
1105
with Task ('GraalPython Python unittests' , tasks , tags = [GraalPythonTags .unittest ]) as task :
1082
1106
if task :
1083
1107
mx .run (["env" ])
1084
- run_python_unittests (python_gvm (), javaAsserts = True , nonZeroIsFatal = ( not is_collectiong_coverage () ))
1108
+ run_python_unittests (python_gvm (), javaAsserts = True , nonZeroIsFatal = nonZeroIsFatal , report = report ( ))
1085
1109
1086
1110
with Task ('GraalPython Python unittests with CPython' , tasks , tags = [GraalPythonTags .unittest_cpython ]) as task :
1087
1111
if task :
@@ -1097,64 +1121,64 @@ def graalpython_gate_runner(args, tasks):
1097
1121
1098
1122
with Task ('GraalPython sandboxed tests' , tasks , tags = [GraalPythonTags .unittest_sandboxed ]) as task :
1099
1123
if task :
1100
- run_python_unittests (python_managed_gvm (), javaAsserts = True )
1124
+ run_python_unittests (python_managed_gvm (), javaAsserts = True , report = report () )
1101
1125
1102
1126
with Task ('GraalPython multi-context unittests' , tasks , tags = [GraalPythonTags .unittest_multi ]) as task :
1103
1127
if task :
1104
- run_python_unittests (python_gvm (), args = ["-multi-context" ], javaAsserts = True , nonZeroIsFatal = ( not is_collectiong_coverage () ))
1128
+ run_python_unittests (python_gvm (), args = ["-multi-context" ], javaAsserts = True , nonZeroIsFatal = nonZeroIsFatal , report = report ( ))
1105
1129
1106
1130
with Task ('GraalPython Jython emulation tests' , tasks , tags = [GraalPythonTags .unittest_jython ]) as task :
1107
1131
if task :
1108
- run_python_unittests (python_gvm (), args = ["--python.EmulateJython" ], paths = ["test_interop.py" ], javaAsserts = True )
1132
+ run_python_unittests (python_gvm (), args = ["--python.EmulateJython" ], paths = ["test_interop.py" ], javaAsserts = True , report = report (), nonZeroIsFatal = nonZeroIsFatal )
1109
1133
1110
- with Task ('GraalPython ginstall' , tasks , tags = [GraalPythonTags .ginstall ]) as task :
1134
+ with Task ('GraalPython ginstall' , tasks , tags = [GraalPythonTags .ginstall ], report = True ) as task :
1111
1135
if task :
1112
1136
run_ginstall (python_gvm (), args = ["--quiet" ])
1113
1137
1114
1138
with Task ('GraalPython HPy tests' , tasks , tags = [GraalPythonTags .unittest_hpy ]) as task :
1115
1139
if task :
1116
- run_hpy_unittests (python_svm (), nonZeroIsFatal = ( not is_collectiong_coverage () ))
1140
+ run_hpy_unittests (python_svm (), nonZeroIsFatal = nonZeroIsFatal , report = report ( ))
1117
1141
1118
1142
with Task ('GraalPython HPy sandboxed tests' , tasks , tags = [GraalPythonTags .unittest_hpy_sandboxed ]) as task :
1119
1143
if task :
1120
- run_hpy_unittests (python_managed_svm (), include_native = False )
1144
+ run_hpy_unittests (python_managed_svm (), include_native = False , report = report () )
1121
1145
1122
1146
with Task ('GraalPython posix module tests' , tasks , tags = [GraalPythonTags .unittest_posix ]) as task :
1123
1147
if task :
1124
- run_python_unittests (python_gvm (), args = ["--PosixModuleBackend=native" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True )
1125
- run_python_unittests (python_gvm (), args = ["--PosixModuleBackend=java" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True )
1148
+ run_python_unittests (python_gvm (), args = ["--PosixModuleBackend=native" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True , report = report () )
1149
+ run_python_unittests (python_gvm (), args = ["--PosixModuleBackend=java" ], paths = ["test_posix.py" , "test_mmap.py" ], javaAsserts = True , report = report () )
1126
1150
1127
1151
with Task ('GraalPython Python tests' , tasks , tags = [GraalPythonTags .tagged ]) as task :
1128
1152
if task :
1129
1153
# don't fail this task if we're running with the jacoco agent, we know that some tests don't pass with it enabled
1130
- run_tagged_unittests (python_svm (), nonZeroIsFatal = (not is_collectiong_coverage ()))
1154
+ run_tagged_unittests (python_svm (), nonZeroIsFatal = (not is_collectiong_coverage ()), report = report () )
1131
1155
1132
1156
with Task ('GraalPython sandboxed Python tests' , tasks , tags = [GraalPythonTags .tagged_sandboxed ]) as task :
1133
1157
if task :
1134
- run_tagged_unittests (python_managed_gvm (), checkIfWithGraalPythonEE = True , cwd = SUITE .dir )
1158
+ run_tagged_unittests (python_managed_gvm (), checkIfWithGraalPythonEE = True , cwd = SUITE .dir , report = report () )
1135
1159
1136
1160
# Unittests on SVM
1137
1161
with Task ('GraalPython tests on SVM' , tasks , tags = [GraalPythonTags .svmunit ]) as task :
1138
1162
if task :
1139
- run_python_unittests (python_svm (), aot_compatible = True )
1163
+ run_python_unittests (python_svm (), aot_compatible = True , report = report () )
1140
1164
1141
1165
with Task ('GraalPython sandboxed tests on SVM' , tasks , tags = [GraalPythonTags .svmunit_sandboxed ]) as task :
1142
1166
if task :
1143
- run_python_unittests (python_managed_svm (), aot_compatible = True )
1167
+ run_python_unittests (python_managed_svm (), aot_compatible = True , report = report () )
1144
1168
1145
1169
with Task ('GraalPython license header update' , tasks , tags = [GraalPythonTags .license ]) as task :
1146
1170
if task :
1147
1171
python_checkcopyrights ([])
1148
1172
1149
- with Task ('GraalPython GraalVM shared-library build' , tasks , tags = [GraalPythonTags .shared_object , GraalPythonTags .graalvm ]) as task :
1173
+ with Task ('GraalPython GraalVM shared-library build' , tasks , tags = [GraalPythonTags .shared_object , GraalPythonTags .graalvm ], report = True ) as task :
1150
1174
if task :
1151
1175
run_shared_lib_test (python_so ())
1152
1176
1153
- with Task ('GraalPython GraalVM sandboxed shared-library build' , tasks , tags = [GraalPythonTags .shared_object_sandboxed , GraalPythonTags .graalvm_sandboxed ]) as task :
1177
+ with Task ('GraalPython GraalVM sandboxed shared-library build' , tasks , tags = [GraalPythonTags .shared_object_sandboxed , GraalPythonTags .graalvm_sandboxed ], report = True ) as task :
1154
1178
if task :
1155
1179
run_shared_lib_test (python_managed_so (), ("sandboxed" ,))
1156
1180
1157
- with Task ('GraalPython GraalVM build' , tasks , tags = [GraalPythonTags .svm , GraalPythonTags .graalvm ]) as task :
1181
+ with Task ('GraalPython GraalVM build' , tasks , tags = [GraalPythonTags .svm , GraalPythonTags .graalvm ], report = True ) as task :
1158
1182
if task :
1159
1183
svm_image = python_svm ()
1160
1184
benchmark = os .path .join (PATH_MESO , "image-magix.py" )
@@ -1169,7 +1193,7 @@ def graalpython_gate_runner(args, tasks):
1169
1193
1170
1194
with Task ('GraalPy win32 smoketests' , tasks , tags = [GraalPythonTags .windows ]) as task :
1171
1195
if task :
1172
- punittest (["--no-leak-tests" , "--regex" , r'(com\.oracle\.truffle\.tck\.tests)|(graal\.python\.test\.(advance\.Benchmark|basic|builtin|decorator|generator|interop|util))' ])
1196
+ punittest (["--no-leak-tests" , "--regex" , r'(com\.oracle\.truffle\.tck\.tests)|(graal\.python\.test\.(advance\.Benchmark|basic|builtin|decorator|generator|interop|util))' ], report = True )
1173
1197
svm_image = python_svm ()
1174
1198
out = mx .OutputCapture ()
1175
1199
mx .run ([svm_image , "-v" , "-S" , "--log.python.level=FINEST" , "-c" , "import sys; print(sys.platform)" ], nonZeroIsFatal = True , out = mx .TeeOutputCapture (out ), err = mx .TeeOutputCapture (out ))
@@ -1181,7 +1205,7 @@ def graalpython_gate_runner(args, tasks):
1181
1205
if success not in out .data :
1182
1206
mx .abort (f'Output from generated SVM image "{ svm_image } " did not match success pattern:\n Expected\n { success } \n Got\n { out .data } ' )
1183
1207
1184
- with Task ('Python SVM Truffle TCK' , tasks , tags = [GraalPythonTags .language_checker ]) as task :
1208
+ with Task ('Python SVM Truffle TCK' , tasks , tags = [GraalPythonTags .language_checker ], report = True ) as task :
1185
1209
if task :
1186
1210
mx .run_mx ([
1187
1211
"--dy" , "graalpython,/substratevm" ,
0 commit comments