- macros work in the new way (the "right" way?) - added test.py script, with basic test cases. Need to fill out new test builtins.
110 lines
2 KiB
Python
Executable file
110 lines
2 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import time;
|
|
import glob;
|
|
import itertools;
|
|
import pickle;
|
|
import atexit;
|
|
import subprocess;
|
|
|
|
PICKLEFILE = ".test.db"
|
|
|
|
try:
|
|
with open(PICKLEFILE, "rb") as stream:
|
|
ftimes = pickle.load(stream);
|
|
except:
|
|
ftimes = dict();
|
|
|
|
def dumpftimes():
|
|
with open(PICKLEFILE, "wb") as stream:
|
|
pickle.dump(ftimes, stream);
|
|
|
|
atexit.register(dumpftimes);
|
|
|
|
all_test_paths = list();
|
|
|
|
all_test_paths.extend(glob.glob("test/**/*.txt", recursive = False));
|
|
|
|
all_test_paths.extend(glob.glob("test/**/*.py", recursive = False));
|
|
|
|
all_buildtypes = ("test", "test-asan", "test-ubsan");
|
|
|
|
all_tests = list(itertools.product(all_buildtypes, all_test_paths));
|
|
|
|
for test in all_tests:
|
|
if test not in ftimes:
|
|
ftimes[test] = time.time();
|
|
|
|
already_built = set();
|
|
|
|
for test in sorted(all_tests, key = lambda x: -ftimes[x]):
|
|
buildtype, path = test
|
|
|
|
if buildtype not in already_built:
|
|
print("\033[32m" f"$ make buildtype={buildtype}" "\033[0m");
|
|
|
|
result = subprocess.run(["make", f"buildtype={buildtype}"]);
|
|
|
|
if result.returncode:
|
|
ftimes[test] = time.time();
|
|
print("\033[31m" "test failed!" "\033[0m");
|
|
exit(1);
|
|
|
|
already_built.add(buildtype);
|
|
|
|
exe_path = f"bin/{buildtype}-buildtype/12"
|
|
|
|
if path.endswith(".txt"):
|
|
print("\033[32m" f"$ {exe_path} {path}" "\033[0m");
|
|
|
|
result = subprocess.run([exe_path, path]);
|
|
|
|
if result.returncode:
|
|
ftimes[test] = time.time();
|
|
print("\033[31m" "test failed!" "\033[0m");
|
|
exit(1);
|
|
elif path.endswith(".py"):
|
|
print("\033[32m" f"$ python3 {path} {exe_path}" "\033[0m");
|
|
|
|
result = subprocess.run(["python3", path, exe_path]);
|
|
|
|
if result.returncode:
|
|
ftimes[test] = time.time();
|
|
print("\033[31m" "test failed!" "\033[0m");
|
|
exit(1);
|
|
else:
|
|
assert(not "TODO");
|
|
|
|
print("\033[32m" f"all tests pass!" "\033[0m");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|