forked from robotframework/PythonRemoteServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·78 lines (62 loc) · 2.54 KB
/
Copy pathrun.py
File metadata and controls
executable file
·78 lines (62 loc) · 2.54 KB
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
#!/usr/bin/env python
"""Script for running the remote server tests using different interpreters.
Usage: run.py interpreter [arguments]
`interpreter` is the only required argument and specifies Python interpreter
to run the server with. The interpreter must be found from PATH or given as
an absolute path. Notice that on Windows you must use `jython.bat` not just
`jython`.
`arguments` are normal Robot Framework options and arguments. Test case files
are under `atest` directory.
If only the interpreter are given, all acceptance tests under `atest` directory
as well as unit tests under `utest` are executed. Unit tests are run first
and acceptance tests skipped if they fail. To run only unit tests, use
`utest/run.py` instead.
Examples:
run.py python # All unit and acceptance tests with Python
run.py jython.bat atest # All acceptance tests w/ Jython on Windows
run.py jython atest/logging.robot # One suite with Jython outside Windows
run.py ipy --test NoMessage atest # Specific test using IronPython
"""
import sys
import subprocess
from os.path import abspath, basename, dirname, exists, join, splitext
from os import mkdir
from shutil import rmtree
import robot
import robotstatuschecker
if len(sys.argv) == 1 or '-h' in sys.argv or '--help' in sys.argv:
sys.exit(__doc__)
curdir = dirname(abspath(__file__))
results = join(curdir, 'results')
output = join(results, 'output.xml')
interpreter = sys.argv[1]
arguments = sys.argv[2:]
if exists(results):
rmtree(results)
mkdir(results)
if not arguments:
print 'Running unit tests with %s.' % interpreter
rc = subprocess.call([interpreter, join(curdir, 'utest', 'run.py')])
print
if rc != 0:
print '%d unit test%s failed.' % (rc, 's' if rc != 1 else '')
sys.exit(rc)
arguments = [join(curdir, 'atest')]
command = ['python', '-m', 'robot.run',
'--variable', 'INTERPRETER:%s' % interpreter,
'--name', '%s Remote Server' % splitext(basename(interpreter))[0].title(),
'--metadata', 'Server_Interpreter:%s' % interpreter,
'--noncritical', 'skip',
'--output', output, '--log', 'NONE', '--report', 'NONE'] + arguments
print 'Running acceptance tests with command:\n%s' % ' '.join(command)
subprocess.call(command)
print
print 'Verifying results.'
robotstatuschecker.process_output(output)
rc = robot.rebot(output, outputdir=results, noncritical='skip')
print
if rc == 0:
print 'All tests passed.'
else:
print '%d acceptance test%s failed.' % (rc, 's' if rc != 1 else '')
sys.exit(rc)