Backlog/lib/test-libs.py

55 lines
1.1 KiB
Python

import argparse
import shutil
import os
import sys
import subprocess
orig_dir = os.path.abspath(os.path.dirname(__file__))
dryRun = False
def run(cmd, cwd=None):
global dryRun
print(" ".join(cmd))
c = os.getcwd()
if cwd is not None:
c = cwd
if not dryRun:
print(subprocess.check_output(" ".join(cmd), shell=True, cwd=c).decode(), file=sys.stderr)
def launchTests():
run(['zig', 'env'])
dirs = list(filter(None, [x if os.path.isdir(x) else None for x in os.listdir(orig_dir)]))
results = {}
for d in dirs:
print(">>>>> testing " , d)
try:
run(['zig', 'build', 'test'], cwd=os.path.join(orig_dir, d))
results[d] = "success 🍆💦😏"
except:
results[d] = "test failed. ❌️🤡🍿🍦🎪🎈"
for e in results:
print(e, results[e])
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='run automation tasks for the repo')
parser.add_argument('--dry', action="store_true", help='dont run anything')
args = parser.parse_args()
if args.dry:
dryRun = True
launchTests()