forked from openmc-dev/openmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_results.py
executable file
·60 lines (48 loc) · 1.62 KB
/
update_results.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
#!/usr/bin/env python
from __future__ import print_function
import os
import re
from subprocess import Popen, call, STDOUT, PIPE
from glob import glob
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-R', '--tests-regex', dest='regex_tests',
help="Run tests matching regular expression. \
Test names are the directories present in tests folder.\
This uses standard regex syntax to select tests.")
(opts, args) = parser.parse_args()
cwd = os.getcwd()
# Terminal color configurations
OKGREEN = '\033[92m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
# Get a list of all test folders
folders = glob('test_*')
# Check to see if a subset of tests is specified on command line
if opts.regex_tests is not None:
folders = [item for item in folders if re.search(opts.regex_tests, item)]
# Loop around directories
for adir in sorted(folders):
# Go into that directory
os.chdir(adir)
pwd = os.path.abspath(os.path.dirname('settings.xml'))
os.putenv('PWD', pwd)
# Print status to screen
print(adir, end="")
sz = len(adir)
for i in range(35 - sz):
print('.', end="")
# Find the test executable
test_exec = glob('test_*.py')
assert len(test_exec) == 1, 'There must be only one test executable per ' \
'test directory'
# Update the test results
proc = Popen(['python', test_exec[0], '--update'])
returncode = proc.wait()
if returncode == 0:
print(BOLD + OKGREEN + "[OK]" + ENDC)
else:
print(BOLD + FAIL + "[FAILED]" + ENDC)
# Go back a directory
os.chdir('..')