Skip to content

Commit 2518ca1

Browse files
committed
[GR-11770] Generalize exported unittest function.
PullRequest: graalpython/208
2 parents cb7b3fd + 68d2ee8 commit 2518ca1

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_signal.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3838
# SOFTWARE.
3939

40-
41-
def test_alarm():
40+
def skip_test_alarm():
4241
# (tfel): this test is very brittle, because it is supposed to work with our
4342
# first, very primitive implementation of signal handlers, which does not
4443
# allow Python code to run in the handler. So we rely on a side-effect on an

mx.graalpython/mx_graalpython.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ def python3_unittests(args):
265265
# mx gate --tags pythontest
266266
# mx gate --tags fulltest
267267

268+
AOT_INCOMPATIBLE_TESTS = ["test_interop.py"]
268269

269270
class GraalPythonTags(object):
270271
junit = 'python-junit'
@@ -348,20 +349,18 @@ def gate_unittests(args=[], subdir=""):
348349
mx.run(["python3"] + test_args, nonZeroIsFatal=True)
349350

350351

351-
def _python_svm_unittest(svm_image):
352-
suite_dir = _suite.dir
353-
llvm_home = mx_subst.path_substitutions.substitute('--native.Dllvm.home=<path:SULONG_LIBS>')
354-
352+
def run_python_unittests(python_binary, args=[], aot_compatible=True, exclude=[]):
355353
# tests root directory
356-
tests_folder = os.path.join(suite_dir, "graalpython", "com.oracle.graal.python.test", "src", "tests")
354+
tests_folder = os.path.join(_suite.dir, "graalpython", "com.oracle.graal.python.test", "src", "tests")
357355

358356
# list of excluded tests
359-
excluded = ["test_interop.py"]
357+
if aot_compatible:
358+
exclude += AOT_INCOMPATIBLE_TESTS
360359

361360
def is_included(path):
362361
if path.endswith(".py"):
363362
basename = os.path.basename(path)
364-
return basename.startswith("test_") and basename not in excluded
363+
return basename.startswith("test_") and basename not in exclude
365364
return False
366365

367366
# list all 1st-level tests and exclude the SVM-incompatible ones
@@ -378,13 +377,9 @@ def is_included(path):
378377
except OSError:
379378
pass
380379

381-
args = ["--python.CoreHome=%s" % os.path.join(suite_dir, "graalpython", "lib-graalpython"),
382-
"--python.StdLibHome=%s" % os.path.join(suite_dir, "graalpython", "lib-python/3"),
383-
llvm_home,
384-
os.path.join(suite_dir, "graalpython", "com.oracle.graal.python.test", "src", "graalpytest.py"),
385-
"-v"]
380+
args += [os.path.join(_suite.dir, "graalpython", "com.oracle.graal.python.test", "src", "graalpytest.py"), "-v"]
386381
args += testfiles
387-
return mx.run([svm_image] + args, nonZeroIsFatal=True)
382+
return mx.run([python_binary] + args, nonZeroIsFatal=True)
388383

389384

390385
def graalpython_gate_runner(args, tasks):
@@ -414,7 +409,11 @@ def graalpython_gate_runner(args, tasks):
414409
if not os.path.exists(svm_image_name):
415410
python_svm(["-h"])
416411
else:
417-
_python_svm_unittest(svm_image_name)
412+
llvm_home = mx_subst.path_substitutions.substitute('--native.Dllvm.home=<path:SULONG_LIBS>')
413+
args = ["--python.CoreHome=%s" % os.path.join(_suite.dir, "graalpython", "lib-graalpython"),
414+
"--python.StdLibHome=%s" % os.path.join(_suite.dir, "graalpython", "lib-python/3"),
415+
llvm_home]
416+
run_python_unittests(svm_image_name, args)
418417

419418
with Task('GraalPython apptests', tasks, tags=[GraalPythonTags.apptests]) as task:
420419
if task:

0 commit comments

Comments
 (0)