From 824d27935c6f4e76d748de107fdaca70b652887d Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Nov 30 2017 21:23:22 +0000 Subject: runtests script --- diff --git a/Makefile b/Makefile index 51e9e95..5e29a3c 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ test3: tests/test_lib tests/test_cli coverage report coverage html - @echo Full coverage report in htmlcov/index.html + @echo Full coverage report at file://${PWD}/htmlcov/index.html test-tarball: @rm -rf .koji-$(VERSION) diff --git a/runtests b/runtests new file mode 100755 index 0000000..940bdf4 --- /dev/null +++ b/runtests @@ -0,0 +1,44 @@ +#!/usr/bin/python + +from multiprocessing import Pool +import subprocess +import tempfile + + +def explode_ref(ref, dest): + """Write contents from ref to dest dir""" + p1 = subprocess.Popen(['git', 'archive', ref], stdout=subprocess.PIPE) + p2 = subprocess.Popen(['tar', '-x'], cwd=dest, stdin=p1.stdout) + p1.stdout.close() + p2.communicate() + + +def checkout_run(cmd, ref='HEAD'): + """Run command in a fresh checkout of ref and return output""" + tempdir = tempfile.mkdtemp() + explode_ref(ref, tempdir) + output = subprocess.check_output(cmd, cwd=tempdir, + stderr=subprocess.STDOUT) + return output + + +def run_test(): + return checkout_run(['make', 'test']) + + +def run_test3(): + return checkout_run(['make', 'test3']) + + +def main(): + """Run our test targets in parallel using fresh checkouts of HEAD""" + print("Running tests...") + p = Pool(2) + results = [p.apply_async(f) for f in [run_test, run_test3]] + for r in results: + print(r.get().decode('utf-8')) + p.close() + + +if __name__ == '__main__': + main()