47 lines
2.5 KiB
Python
47 lines
2.5 KiB
Python
|
|
"""Run the core task format test using a completed qmake Release build.
|
||
|
|
Run from qt_client root: python tests/run_taskapi_test.py
|
||
|
|
No GUI, network, or device commands are issued.
|
||
|
|
"""
|
||
|
|
import os
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
import shutil
|
||
|
|
import subprocess
|
||
|
|
|
||
|
|
makefile = Path("Makefile.JointLimits.Release")
|
||
|
|
variables = {}
|
||
|
|
for line in makefile.read_text().splitlines():
|
||
|
|
if " = " in line:
|
||
|
|
key, value = line.split("=", 1)
|
||
|
|
variables[key.strip()] = value.strip()
|
||
|
|
compiler = shutil.which("g++")
|
||
|
|
if not compiler:
|
||
|
|
raise SystemExit("Add the selected Qt Kit MinGW bin directory to PATH first")
|
||
|
|
Path("build/tests").mkdir(parents=True, exist_ok=True)
|
||
|
|
test = sys.argv[1] if len(sys.argv) > 1 else "taskapi_test"
|
||
|
|
if test not in {"taskapi_test", "taskrpcrunner_test", "task_device_ui_test", "demosimulator_test",
|
||
|
|
"bioheadexpressionstore_test", "bioheadjointclient_test",
|
||
|
|
"bioheadwidget_test", "bioheadlocalexpressions_test"}:
|
||
|
|
raise SystemExit("Unknown test")
|
||
|
|
obj = "build/tests/" + test + ".o"
|
||
|
|
with Path("build/tests/taskapi-build.log").open("w") as log:
|
||
|
|
subprocess.run([compiler, "-c", "-O2", "-std=gnu++1z", "-mthreads", "-fexceptions",
|
||
|
|
*variables["DEFINES"].split(), *variables["INCPATH"].split(), "-Isrc",
|
||
|
|
"tests/" + test + ".cpp", "-o", obj], stdout=log, stderr=subprocess.STDOUT, check=True)
|
||
|
|
object_script = Path("object_script.CmvrControlStation.Release")
|
||
|
|
if not object_script.exists():
|
||
|
|
object_script = Path("object_script.CmvrControlStation_updated.Release")
|
||
|
|
objects = object_script.read_text().splitlines()
|
||
|
|
objects = [p for p in objects if p.strip() != "build/release/obj/main.o"] + [obj]
|
||
|
|
if test == "task_device_ui_test":
|
||
|
|
objects = [p for p in objects if p.strip() != "build/release/obj/taskorchestrationwidget.o"]
|
||
|
|
response_file = Path("build/tests/taskapi-objects")
|
||
|
|
response_file.write_text("\n".join(objects))
|
||
|
|
subprocess.run([compiler, "-mthreads", "-Wl,-subsystem,console", "-o", "build/tests/" + test + ".exe",
|
||
|
|
"@" + str(response_file), *variables["LIBS"].split()], stdout=log, stderr=subprocess.STDOUT, check=True)
|
||
|
|
env = os.environ.copy()
|
||
|
|
env["PATH"] = str(Path("bin/release").resolve()) + os.pathsep + env["PATH"]
|
||
|
|
env.setdefault("QT_QPA_PLATFORM", "windows")
|
||
|
|
env.setdefault("QT_QPA_PLATFORM_PLUGIN_PATH", str(Path("bin/release/platforms").resolve()))
|
||
|
|
raise SystemExit(subprocess.run(["build/tests/" + test + ".exe"], env=env, timeout=45).returncode)
|