|
2 | 2 |
|
3 | 3 | """Script for running the remote server tests using different interpreters. |
4 | 4 |
|
5 | | -Usage: run.py interpreter [[options] datasources] |
| 5 | +Usage: run.py interpreter [arguments] |
6 | 6 |
|
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`. |
9 | 11 |
|
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 |
12 | 26 | """ |
13 | 27 |
|
14 | 28 | import sys |
|
28 | 42 | results = join(curdir, 'results') |
29 | 43 | output = join(results, 'output.xml') |
30 | 44 | interpreter = sys.argv[1] |
31 | | -arguments = sys.argv[2:] or [join(curdir, 'tests')] |
| 45 | +arguments = sys.argv[2:] |
32 | 46 |
|
33 | 47 | if exists(results): |
34 | 48 | rmtree(results) |
35 | 49 | mkdir(results) |
36 | 50 |
|
| 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 | + |
37 | 60 | command = ['python', '-m', 'robot.run', |
38 | 61 | '--variable', 'INTERPRETER:%s' % interpreter, |
39 | 62 | '--name', '%s Remote Server' % interpreter.title(), |
40 | 63 | '--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) |
42 | 65 | subprocess.call(command) |
43 | | - |
44 | 66 | print |
| 67 | + |
45 | 68 | robotstatuschecker.process_output(output) |
46 | 69 | rc = robot.rebot(output, outputdir=results) |
| 70 | +print |
47 | 71 | if rc == 0: |
48 | 72 | print 'All tests passed.' |
49 | 73 | 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