diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-03-02 17:11:29 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-03-02 17:11:29 +0200 |
commit | 4745b07e9924ad5dd48d23766833be0ba5749a99 (patch) | |
tree | bdc273badfa411d9d17f0c424d110544b08d7b0b | |
parent | baa0782a22fea66bc7224464c6504f7746532cc7 (diff) | |
download | meson-4745b07e9924ad5dd48d23766833be0ba5749a99.zip meson-4745b07e9924ad5dd48d23766833be0ba5749a99.tar.gz meson-4745b07e9924ad5dd48d23766833be0ba5749a99.tar.bz2 |
And finally use argparse in meson_test. Closes #47.
-rwxr-xr-x | meson_test.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/meson_test.py b/meson_test.py index 556b32e..533cd87 100755 --- a/meson_test.py +++ b/meson_test.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2013-2014 The Meson development team +# Copyright 2013-2015 The Meson development team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,16 +16,19 @@ import sys, os, subprocess, time, datetime, pickle, multiprocessing, json import concurrent.futures as conc -from optparse import OptionParser +import argparse import platform tests_failed = False -parser = OptionParser() -parser.add_option('--wrapper', default=None, dest='wrapper', +parser = argparse.ArgumentParser() +parser.add_argument('--wrapper', default=None, dest='wrapper', help='wrapper to run tests with (e.g. valgrind)') -parser.add_option('--wd', default=None, dest='wd', +parser.add_argument('--wd', default=None, dest='wd', help='directory to cd into before running') +parser.add_argument('args', nargs='+') + + class TestRun(): def __init__(self, res, returncode, duration, stdo, stde, cmd): self.res = res @@ -162,13 +165,13 @@ def run_tests(options, datafilename): print('\nFull log written to %s.' % logfilename) if __name__ == '__main__': - (options, args) = parser.parse_args(sys.argv) - if len(args) != 2: + options = parser.parse_args() + if len(options.args) != 1: print('Test runner for Meson. Do not run on your own, mmm\'kay?') print('%s [data file]' % sys.argv[0]) if options.wd is not None: os.chdir(options.wd) - datafile = args[1] + datafile = options.args[0] run_tests(options, datafile) if tests_failed: sys.exit(1) |