Skip to content

Commit c7f3471

Browse files
committed
support running unit and acceptance tests together
1 parent 361ba2f commit c7f3471

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

atest/run.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,27 @@
22

33
"""Script for running the remote server tests using different interpreters.
44
5-
Usage: run.py interpreter [[options] datasources]
5+
Usage: run.py interpreter [arguments]
66
7-
`interpreter` is the only required argument and specifies the Python
8-
interpreter to run the server with.
7+
`interpreter` is the only required argument and specifies Python interpreter
8+
to run the server with. The interpreter must be found from PATH or given as
9+
an absolute path. Notice that on Windows you must use `jython.bat` not just
10+
`jython`.
911
10-
By default all tests under `tests` directory are executed. This can be
11-
changed by giving data sources and options explicitly.
12+
`arguments` are normal Robot Framework options and arguments. Test case files
13+
are under `atest` directory.
14+
15+
If only the interpreter are given, all acceptance tests under `atest` directory
16+
as well as unit tests under `utest` are executed. Unit tests are run first
17+
and acceptance tests skipped if they fail. To run only unit tests, use
18+
`utest/run.py` instead.
19+
20+
Examples:
21+
22+
run.py python # All unit and acceptance tests with Python
23+
run.py jython.bat atest # All acceptance tests w/ Jython on Windows
24+
run.py jython atest/logging.robot # One suite with Jython outside Windows
25+
run.py ipy --test NoMessage atest # Specific test using IronPython
1226
"""
1327

1428
import sys
@@ -28,23 +42,34 @@
2842
results = join(curdir, 'results')
2943
output = join(results, 'output.xml')
3044
interpreter = sys.argv[1]
31-
arguments = sys.argv[2:] or [join(curdir, 'tests')]
45+
arguments = sys.argv[2:]
3246

3347
if exists(results):
3448
rmtree(results)
3549
mkdir(results)
3650

51+
if not arguments:
52+
print 'Running unit tests with %s.' % interpreter
53+
rc = subprocess.call([interpreter, join(curdir, 'utest', 'run.py')])
54+
print
55+
if rc != 0:
56+
print '%d unit test%s failed.' % (rc, 's' if rc != 1 else '')
57+
sys.exit(rc)
58+
arguments = [join(curdir, 'atest')]
59+
3760
command = ['python', '-m', 'robot.run',
3861
'--variable', 'INTERPRETER:%s' % interpreter,
3962
'--name', '%s Remote Server' % interpreter.title(),
4063
'--output', output, '--log', 'NONE', '--report', 'NONE'] + arguments
41-
print 'Running tests with command:\n%s' % ' '.join(command)
64+
print 'Running acceptance tests with command:\n%s' % ' '.join(command)
4265
subprocess.call(command)
43-
4466
print
67+
4568
robotstatuschecker.process_output(output)
4669
rc = robot.rebot(output, outputdir=results)
70+
print
4771
if rc == 0:
4872
print 'All tests passed.'
4973
else:
50-
print '%d test%s failed.' % (rc, 's' if rc != 1 else '')
74+
print '%d acceptance test%s failed.' % (rc, 's' if rc != 1 else '')
75+
sys.exit(rc)

0 commit comments

Comments
 (0)