37a38
> import multiprocessing.pool
123,126c124,141
< for test in tests:
< if test.compile_only:
< continue
< args = [
---
> parser = argparse.ArgumentParser()
> parser.add_argument('--timeout', type=int, metavar='SECONDS',
> help='Time limit for each run in seconds.',
> default=0)
> parser.add_argument('-j', type=int, default=1,
> help='How many tests to run in parallel.')
> args = parser.parse_args(self.args)
>
> timeout_cmd = [
> 'timeout',
> '--kill-after', str(args.timeout * 2),
> str(args.timeout)
> ]
> def run_test(test):
> cmd = []
> if args.timeout:
> cmd.extend(timeout_cmd)
> cmd.extend([
131,132c146,147
< ]
< subprocess.check_call(args)
---
> ])
> subprocess.check_call(cmd)
133a149,157
> runnable = filter(lambda t: not t.compile_only, tests)
> if args.j == 1:
> map(run_test, runnable)
> else:
> tp = multiprocessing.pool.ThreadPool(args.j)
> map(lambda t: tp.apply_async(run_test, (t,)), runnable)
> tp.close()
> tp.join()
>