torch-mlir/python/run_tests.py

56 lines
1.5 KiB
Python
Raw Normal View History

2020-04-27 06:50:23 +08:00
#!/usr/bin/env python3
import os
import subprocess
import sys
TEST_MODULES = (
"npcomp.mlir_ir_test",
2020-05-02 01:38:52 +08:00
"npcomp.dialect.Numpy",
2020-04-27 06:50:23 +08:00
"npcomp.edsc_test",
"npcomp.tracing.context",
"npcomp.tracing.mlir_trace",
"npcomp.types",
"npcomp.exporter",
"npcomp.exp.extractor",
)
# Compute PYTHONPATH for sub processes.
DIRSEP = ":" if os.path.sep == "/" else ";"
2020-04-27 07:32:10 +08:00
PYTHONPATH = os.path.abspath(os.path.dirname(__file__))
2020-04-27 06:50:23 +08:00
if "PYTHONPATH" in os.environ:
PYTHONPATH = PYTHONPATH + DIRSEP + os.environ["PYTHONPATH"]
CHILD_ENVIRON = dict(os.environ)
CHILD_ENVIRON["PYTHONPATH"] = PYTHONPATH
# Configure filecheck.
FILECHECK_BINARY = os.path.abspath(
os.path.join(
os.path.dirname(__file__),
"..", "..", "..", "bin", "FileCheck"))
if os.path.exists(FILECHECK_BINARY):
CHILD_ENVIRON["FILECHECK_BINARY"] = FILECHECK_BINARY
else:
print("WARNING! Built FileCheck not found. Leaving to path resolution")
passed = []
failed = []
for test_module in TEST_MODULES:
print("--------====== RUNNING %s ======--------" % test_module)
try:
subprocess.check_call([sys.executable, "-m", test_module],
env=CHILD_ENVIRON)
print("--------====== DONE %s ======--------\n" % test_module)
passed.append(test_module)
except subprocess.CalledProcessError:
print("!!!!!!!!====== ERROR %s ======!!!!!!!!\n" % test_module)
failed.append(test_module)
print("Done: %d passed, %d failed" % (len(passed), len(failed)))
if failed:
for test_module in failed:
print(" %s: FAILED" % test_module)
sys.exit(1)