Skip to content

Commit faf40c9

Browse files
committed
simplify unittest running
1 parent c8e6b8a commit faf40c9

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

docs/contributor/CONTRIBUTING.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,11 @@ implementation isn't quite ready, so you have to put the flags somewhere else to
167167
debug. You can see `-debug-java` and `--inspect` below, to debug in Java
168168
debugger or Chromium, respectively.
169169

170-
ENABLE_CPYTHON_TAGGED_UNITTESTS=true mx python3 \
171-
graalpython/com.oracle.graal.python.test/src/graalpytest.py \
172-
[-debug-java] [--inspect] \
173-
graalpython/com.oracle.graal.python.test/src/tests/test_tagged_unittests.py \
174-
-k NAME-OF-CPYTHON-UNITTEST
170+
mx python-run-cpython-unittest [-debug-java] [--inspect] NAME-OF-CPYTHON-UNITTEST
175171

176172
A tag file can be regenerated with
177173

178-
mx python graalpython/com.oracle.graal.python.test/src/tests/test_tagged_unittests.py \
179-
--retag NAME-OF-CPYTHON-UNITTEST
174+
mx python-retag-unittests NAME-OF-CPYTHON-UNITTEST
180175

181176
There's also multiple other gates that may fail with changes. One of these is
182177
our *style* gate, which checks formatting rules and copyrights. To auto-fix most

mx.graalpython/mx_graalpython.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,33 @@ def compare_unittests(args):
222222
mx.run([sys.executable, "graalpython/com.oracle.graal.python.test/src/compare_unittests.py", "-v"] + args)
223223

224224

225+
def run_cpython_test(args):
226+
import glob
227+
interp_args = []
228+
globs = []
229+
test_args = []
230+
for arg in args:
231+
if arg.startswith("-"):
232+
if not globs:
233+
interp_args.append(arg)
234+
else:
235+
test_args.append(arg)
236+
else:
237+
globs.append(arg)
238+
testfiles = []
239+
for g in globs:
240+
testfiles += glob.glob(os.path.join(SUITE.dir, "graalpython/lib-python/3/test", f"{g}*"))
241+
mx.run([python_gvm()] + interp_args + [
242+
os.path.join(SUITE.dir, "graalpython/com.oracle.graal.python.test/src/tests/run_cpython_test.py"),
243+
] + test_args + testfiles)
244+
245+
225246
def retag_unittests(args):
226247
"""run the cPython stdlib unittests"""
227248
parser = ArgumentParser('mx python-retag-unittests')
228249
parser.add_argument('--upload-results-to')
250+
parser.add_argument('--inspect', action='store_true')
251+
parser.add_argument('-debug-java', action='store_true')
229252
parsed_args, remaining_args = parser.parse_known_args(args)
230253
env = os.environ.copy()
231254
env.update(
@@ -235,9 +258,14 @@ def retag_unittests(args):
235258
args = [
236259
'--experimental-options=true',
237260
'--python.CatchAllExceptions=true',
238-
'--python.WithThread=true',
261+
'--python.WithThread=true']
262+
if parsed_args.inspect:
263+
args.append('--inspect')
264+
if parsed_args.debug_java:
265+
args.append('-debug-java')
266+
args += [
239267
'graalpython/com.oracle.graal.python.test/src/tests/test_tagged_unittests.py',
240-
'--retag',
268+
'--retag'
241269
]
242270
mx.run([python_gvm()] + args + remaining_args, env=env)
243271
if parsed_args.upload_results_to:
@@ -1757,6 +1785,7 @@ def python_clean(args):
17571785
'python-unittests': [python3_unittests, ''],
17581786
'python-compare-unittests': [compare_unittests, ''],
17591787
'python-retag-unittests': [retag_unittests, ''],
1788+
'python-run-cpython-unittest': [run_cpython_test, 'test-name'],
17601789
'python-update-unittest-tags': [update_unittest_tags, ''],
17611790
'python-import-for-graal': [checkout_find_version_for_graalvm, ''],
17621791
'nativebuild': [nativebuild, ''],

0 commit comments

Comments
 (0)