diff options
author | Vegard Sjonfjell <vegardsjo@gmail.com> | 2016-11-17 16:53:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-17 16:53:23 +0100 |
commit | 1d35e343945522a87a38fd96fee329025abf817f (patch) | |
tree | afeee9b9750e307aac79338791889bfb8fc0aee5 /cppunit-parallelize.py | |
parent | a7f8378614599b273c7562de47618c29f4a63e9d (diff) | |
parent | b79bb6fcd12dc55f3cd4b06c031fca62a6eb190d (diff) |
Merge pull request #1127 from yahoo/voffeloffevoff/split-valgrind-cmdline
Voffeloffevoff/split valgrind cmdline
Diffstat (limited to 'cppunit-parallelize.py')
-rwxr-xr-x | cppunit-parallelize.py | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/cppunit-parallelize.py b/cppunit-parallelize.py index 76d07fe253b..9da5adc41da 100755 --- a/cppunit-parallelize.py +++ b/cppunit-parallelize.py @@ -7,6 +7,7 @@ import copy import os import subprocess import time +import shlex def parse_arguments(): argparser = argparse.ArgumentParser(description="Run Vespa cppunit tests in parallell") @@ -28,6 +29,20 @@ def chunkify(lst, chunks): return result +def error_if_file_not_found(function): + def wrapper(*args, **kwargs): + try: + return function(*args, **kwargs) + except OSError as e: + if e.errno == os.errno.ENOENT: # "No such file or directory" + print >>sys.stderr, "Error: could not find testrunner or valgrind executable" + sys.exit(1) + return wrapper + +@error_if_file_not_found +def get_test_suites(testrunner): + return subprocess.check_output((testrunner, "--list")).strip().split("\n") + class Process: def __init__(self, cmd, group): self.group = group @@ -39,13 +54,14 @@ class Process: stderr=subprocess.STDOUT, preexec_fn=os.setpgrp) +@error_if_file_not_found def build_processes(test_groups): valgrind = os.getenv("VALGRIND") - testrunner = (valgrind, args.testrunner) if valgrind else (args.testrunner,) + testrunner = shlex.split(valgrind) + [args.testrunner] if valgrind else [args.testrunner] processes = [] for group in test_groups: - cmd = testrunner + tuple(group) + cmd = testrunner + group processes.append(Process(cmd, group)) return processes @@ -59,14 +75,7 @@ def cleanup_processes(processes): print >>sys.stderr, e.message args = parse_arguments() - -try: - test_suites = subprocess.check_output((args.testrunner, "--list")).strip().split("\n") -except OSError as e: - if e.errno == os.errno.ENOENT: # "No such file or directory" - print >>sys.stderr, "No such file or directory: %s" % args.testrunner - sys.exit(1) - +test_suites = get_test_suites(args.testrunner) test_suite_groups = chunkify(test_suites, args.chunks) processes = build_processes(test_suite_groups) @@ -88,7 +97,7 @@ while True: print "All test suites ran successfully" sys.exit(0) elif return_code is not None: - print "One of '%s' test suites failed:" % ", ".join(proc.group) + print "Error: one of '%s' test suites failed:" % ", ".join(proc.group) print >>sys.stderr, proc.output sys.exit(return_code) |