diff --git a/.travis.yml b/.travis.yml index 6002718484e..f3036ea8829 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,8 @@ install: - python setup.py develop # command to run tests script: - - python qcodes/test.py -c + - python qcodes/test.py --skip-coverage + - python qcodes/test.py --mp-spawn after_success: # codecov - cd qcodes diff --git a/qcodes/test.py b/qcodes/test.py index 3b02cf5949a..b04c412b06a 100644 --- a/qcodes/test.py +++ b/qcodes/test.py @@ -57,11 +57,14 @@ def test_part(name): if __name__ == '__main__': import argparse - import coverage import os import multiprocessing as mp - import sys - mp.set_start_method('spawn') + + try: + import coverage + coverage_missing = False + except ImportError: + coverage_missing = True # make sure coverage looks for .coveragerc in the right place os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -70,39 +73,46 @@ def test_part(name): description=('Core test suite for Qcodes, ' 'covering everything except instrument drivers')) - parser.add_argument('-v', '--verbose', nargs='?', dest='verbosity', - const=2, default=1, type=int, - help=('increase verbosity. default 1, ' - '-v is the same as -v 2')) + parser.add_argument('-v', '--verbose', action='store_true', + help='increase verbosity') + + parser.add_argument('-q', '--quiet', action='store_true', + help='reduce verbosity (opposite of --verbose)') + + parser.add_argument('-s', '--skip-coverage', action='store_true', + help='skip coverage reporting') - parser.add_argument('-c', '--coverage', nargs='?', dest='show_coverage', - const=1, default=1, type=int, - help=('show coverage. default is True ' - '-c is the same as -c 1')) + parser.add_argument('-t', '--test_pattern', type=str, default='test*.py', + help=('regexp for test name to match, ' + 'default "test*.py"')) - parser.add_argument('-t', '--test_pattern', nargs='?', dest='test_pattern', - const=1, default='test*.py', type=str, - help=('regexp for test name to match')) + parser.add_argument('-f', '--failfast', action='store_true', + help='halt on first error/failure') - parser.add_argument('-f', '--failfast', nargs='?', dest='failfast', - const=1, default=0, type=int, - help=('halt on first error/failure? default 0 ' - '(false), -f is the same as -f 1 (true)')) + parser.add_argument('-m', '--mp-spawn', action='store_true', + help=('force "spawn" method of starting child ' + 'processes to emulate Win behavior on Unix')) args = parser.parse_args() - cov = coverage.Coverage(source=['qcodes']) - cov.start() + if args.mp_spawn: + mp.set_start_method('spawn') - success = _test_core(verbosity=args.verbosity, - failfast=bool(args.failfast), + args.skip_coverage |= coverage_missing + + if not args.skip_coverage: + cov = coverage.Coverage(source=['qcodes']) + cov.start() + + success = _test_core(verbosity=(1 + args.verbose - args.quiet), + failfast=args.failfast, test_pattern=args.test_pattern) - cov.stop() - # save coverage anyway since we computed it - cov.save() - if success and args.show_coverage: + if not args.skip_coverage: + cov.stop() + cov.save() cov.report() + # restore unix-y behavior # exit status 1 on fail if not success: