From b6845765e6f5e3093bf12020fa1ce2ba4f4190c8 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Mon, 23 Apr 2018 22:05:55 +0200
Subject: [PATCH] Come up with runtest.py script.
The script runs a single test. Example usage:
./scripts/runtest.py ./test/unit/org/openstreetmap/josm/tools/GeometryTest.java
Compiling test
Running test
JUnit version 4.12
..System property josm.test.data is not set, using 'test/data'
.System property josm.test.data is not set, using 'test/data'
..System property josm.test.data is not set, using 'test/data'
Time: 1.063
OK (5 tests)
---
scripts/runtest.py | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100755 scripts/runtest.py
diff --git a/scripts/runtest.py b/scripts/runtest.py
new file mode 100755
index 000000000..7098f4ca8
-
|
+
|
|
| 1 | #!/usr/bin/env python3 |
| 2 | # License: CC0 |
| 3 | |
| 4 | """ |
| 5 | Helper script that runs a single test. |
| 6 | """ |
| 7 | |
| 8 | import argparse |
| 9 | import subprocess |
| 10 | |
| 11 | from itertools import * |
| 12 | |
| 13 | josm_env = '.:test/unit:test/functional:dist/josm-custom.jar:test/lib/commons-testing/*:test/lib/fest/*:test/lib/junit/*:test/lib/*:test/lib/unitils-core/*:tools/*:tools/spotbugs/*' |
| 14 | |
| 15 | def main(): |
| 16 | parser = argparse.ArgumentParser(description = 'Run single JOSM test') |
| 17 | parser.add_argument('testpath', |
| 18 | help = 'Relative path to test. Example: ./test/unit/org/openstreetmap/josm/tools/GeometryTest.java') |
| 19 | args = parser.parse_args() |
| 20 | |
| 21 | print('Compiling test') |
| 22 | subprocess.check_output('javac -cp %s %s' % (josm_env, args.testpath), shell = True) |
| 23 | |
| 24 | # parse parh to tests and start with 'org' folder |
| 25 | parts = list(dropwhile(lambda x: x != 'org', args.testpath.split('/'))) |
| 26 | parts[-1] = parts[-1].split('.')[0] |
| 27 | class_name = '.'.join(parts) |
| 28 | |
| 29 | print('Running test') |
| 30 | subprocess.run('java -cp %s org.junit.runner.JUnitCore %s' % (josm_env, class_name), shell = True) |
| 31 | |
| 32 | main() |