-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathrun_tests.py
executable file
·69 lines (65 loc) · 2.39 KB
/
run_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
from __future__ import print_function
import sys
import os
import subprocess
import argparse
bin = sys.prefix + '/bin/'
# from: http://ascii.co.uk/art/batman
art = r'''
| | _.-7
|\.-.| ( ,(_
| a a| \\ \,
) ["|| _.--' \ \\
.-' '-''-..____.-' ___) )\
F _/-``-.__;-.-.--`--' . .' \_L_
| l {~~} ,_\ '.'. ` __.' )\
( -.;___,; | '- _ :__.'( /
| -.__ _/_.'.-' '-._ .' \\
| .' | -- _ '\,
| \ /--,--{ . '---.__. .' .'
J ;/ __;__]. '.-. .-' )_/
J (-. '\'. '. '-._.-.-'--._ /
| | '. .' | \'. '. ._ \
| \ T | \ '. '._ '-._ '.
F J | | '. . '._ '-,_.--`
F \ \ F . \ '. '. /
J \ | J \ '. '. '/
J '.L__| . \ ' |
| . \ | \ '. '. /
| ' '.| | ,-. (
F | ' ___ ',._ . / '. \
F (.'`|| (-._\ '. \- '-\
\ .-' ( L `._ '\ '._ (
snd /' | / '-._\ ''\
`-'
'''
parser = argparse.ArgumentParser(
description='run test. Full test requires nose and coverage packages')
parser.add_argument('-s', '--simple', action='store_true', help='quick run')
parser.add_argument(
'-c', '--with-coverage', action='store_true', help='coverage report')
parser.add_argument('-n', '--ncores', default=1, help='n_cores')
args = parser.parse_args()
print(bin)
print("start testing. Go to ./tests folder")
os.chdir("./tests/")
if args.simple:
print('running minimal test\n')
subprocess.check_call(
"{bin}/python ./run_simple_test.py".format(bin=bin), shell=True)
else:
print('running full test\n')
if args.with_coverage:
print('with coverage')
cm_list = "{bin}/pytest --cov=pytraj --cov-report=html -vs -rsx .".format(
bin=bin).split()
else:
print('without coverage\n')
cm_list = "{bin}/pytest -vs .".format(bin=bin).split()
if int(args.ncores) > 1:
cm_list.extend(['-n', args.ncores])
print("using {} cores".format(args.ncores))
subprocess.check_call(cm_list)
print('\nHAPPY COMPUTING')
print(art)