Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test suite cleanup #283

Merged
merged 6 commits into from
Jul 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
62 changes: 36 additions & 26 deletions qcodes/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)))
Expand All @@ -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:
Expand Down