2020-04-27 06:50:23 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
TEST_MODULES = (
|
2020-05-01 08:14:03 +08:00
|
|
|
"npcomp.mlir_ir_test",
|
2020-06-03 16:29:59 +08:00
|
|
|
"npcomp.mlir_pass_test",
|
2020-05-07 10:07:50 +08:00
|
|
|
"npcomp.dialect.Basicpy",
|
2020-05-02 01:38:52 +08:00
|
|
|
"npcomp.dialect.Numpy",
|
2020-04-27 06:50:23 +08:00
|
|
|
"npcomp.tracing.context",
|
|
|
|
"npcomp.tracing.mlir_trace",
|
|
|
|
"npcomp.types",
|
|
|
|
"npcomp.exporter",
|
2020-05-03 10:52:21 +08:00
|
|
|
"npcomp.tracing.mlir_trace_test",
|
2020-04-27 06:50:23 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# Compute PYTHONPATH for sub processes.
|
2020-05-07 13:44:12 +08:00
|
|
|
DIRSEP = os.path.pathsep
|
|
|
|
LOCAL_PYTHONPATH_COMPONENTS = [
|
|
|
|
# This directory.
|
|
|
|
os.path.abspath(os.path.dirname(__file__)),
|
|
|
|
# The parallel python_native directory (assuming in the build tree).
|
|
|
|
os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "python_native"))
|
|
|
|
]
|
|
|
|
PYTHONPATH = DIRSEP.join(LOCAL_PYTHONPATH_COMPONENTS)
|
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:
|
2020-05-07 09:48:12 +08:00
|
|
|
subprocess.check_call([sys.executable, "-Wignore", "-m", test_module],
|
2020-04-27 06:50:23 +08:00
|
|
|
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)
|