forked from hpcugent/vsc-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qa.py
executable file
·95 lines (78 loc) · 2.79 KB
/
qa.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python
#
# Copyright 2013-2013 Ghent University
#
# This file is part of vsc-base,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en),
# the Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# http://github.com/hpcugent/vsc-base
#
# vsc-base is free software: you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# vsc-base is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with vsc-base. If not, see <http://www.gnu.org/licenses/>.
#
"""
Simple QA script
@author: Stijn De Weirdt (Ghent University)
"""
import os
from vsc.utils.run import run_qa, run_qalog, run_qastdout, run_async_to_stdout
from vsc.utils.generaloption import simple_option
go = simple_option(None)
SCRIPT_DIR = os.path.join(os.path.dirname(__file__), '..', 'test', 'runtests')
SCRIPT_QA = os.path.join(SCRIPT_DIR, 'qa.py')
def test_qa():
qa_dict = {
'Simple question:': 'simple answer',
}
ec, output = run_qa([SCRIPT_QA, 'simple'], qa=qa_dict)
return ec, output
def test_qalog():
qa_dict = {
'Simple question:': 'simple answer',
}
ec, output = run_qalog([SCRIPT_QA, 'simple'], qa=qa_dict)
return ec, output
def test_qastdout():
run_async_to_stdout([SCRIPT_QA, 'simple'])
qa_dict = {
'Simple question:': 'simple answer',
}
ec, output = run_qastdout([SCRIPT_QA, 'simple'], qa=qa_dict)
return ec, output
def test_std_regex():
qa_dict = {
r'\s(?P<time>\d+(?:\.\d+)?)\..*?What time is it\?': '%(time)s',
}
ec, output = run_qastdout([SCRIPT_QA, 'whattime'], qa_reg=qa_dict)
return ec, output
def test_qa_noqa():
qa_dict = {
'Now is the time.': 'OK',
}
no_qa = ['Wait for it \(\d+ seconds\)']
ec, output = run_qastdout([SCRIPT_QA, 'waitforit'], qa=qa_dict, no_qa=no_qa)
return ec, output
def test_qanoquestion():
ec, output = run_qalog([SCRIPT_QA, 'noquestion'])
return ec, output
if __name__ == '__main__':
test_qanoquestion()
test_qastdout()
test_qa()
test_qalog()
test_std_regex()
test_qa_noqa()