bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6997.5.1
by Jelmer Vernooij
Support running against both python versions. |
1 |
#!/usr/bin/python
|
2 |
||
3 |
import argparse |
|
4 |
import subprocess |
|
|
6997.5.4
by Jelmer Vernooij
Fix test list handling. |
5 |
from subunit.v2 import StreamResultToBytes |
|
6997.5.1
by Jelmer Vernooij
Support running against both python versions. |
6 |
import sys |
|
6997.5.4
by Jelmer Vernooij
Fix test list handling. |
7 |
import tempfile |
8 |
from testrepository.testlist import parse_enumeration, parse_list, write_list |
|
9 |
||
10 |
||
|
6997.5.1
by Jelmer Vernooij
Support running against both python versions. |
11 |
parser = argparse.ArgumentParser( |
12 |
description="Test runner that supports both Python 2 and Python 3.") |
|
13 |
||
14 |
parser.add_argument( |
|
15 |
"--load-list", metavar="PATH", help="Path to read list of tests to run from.", |
|
16 |
type=str) |
|
17 |
parser.add_argument( |
|
18 |
"--list", help="List available tests.", action="store_true") |
|
19 |
||
20 |
args = parser.parse_args() |
|
21 |
||
22 |
if args.list: |
|
|
6997.5.5
by Jelmer Vernooij
Inline function. |
23 |
testids = [] |
|
6997.5.4
by Jelmer Vernooij
Fix test list handling. |
24 |
with subprocess.Popen(['python', './brz', 'selftest', '--subunit2', '--list'], |
25 |
stdout=subprocess.PIPE).stdout as f: |
|
26 |
for n in parse_enumeration(f.read()): |
|
|
6997.5.5
by Jelmer Vernooij
Inline function. |
27 |
testids.append('python2.' + n) |
|
6997.5.4
by Jelmer Vernooij
Fix test list handling. |
28 |
with subprocess.Popen(['python3', './brz', 'selftest', '--subunit2', '--list'], |
29 |
stdout=subprocess.PIPE).stdout as f: |
|
30 |
for n in parse_enumeration(f.read()): |
|
|
6997.5.5
by Jelmer Vernooij
Inline function. |
31 |
testids.append('python3.' + n) |
32 |
stream = StreamResultToBytes(sys.stdout) |
|
33 |
for testid in testids: |
|
34 |
stream.status(test_id=testid, test_status='exists') |
|
|
6997.5.1
by Jelmer Vernooij
Support running against both python versions. |
35 |
else: |
36 |
if args.load_list: |
|
|
6997.5.2
by Jelmer Vernooij
Read/Write subunit2 test files. |
37 |
py2_tests = [] |
38 |
py3_tests = [] |
|
39 |
with open(args.load_list, 'r') as f: |
|
40 |
all_tests = parse_list(f.read()) |
|
41 |
for testname in all_tests: |
|
42 |
if testname.startswith("python2."): |
|
43 |
py2_tests.append(testname[len('python2.'):].strip()) |
|
44 |
elif testname.startswith("python3."): |
|
45 |
py3_tests.append(testname[len('python3.'):].strip()) |
|
46 |
else: |
|
47 |
sys.stderr.write("unknown prefix %s\n" % testname) |
|
48 |
if py2_tests: |
|
|
6997.5.3
by Jelmer Vernooij
Fix test running. |
49 |
with tempfile.NamedTemporaryFile() as py2f: |
50 |
write_list(py2f, py2_tests) |
|
51 |
py2f.flush() |
|
52 |
subprocess.call( |
|
53 |
'python ./brz selftest --subunit2 --load-list=%s | subunit-filter -s --passthrough --rename "^" "python2."' % py2f.name, shell=True) |
|
|
6997.5.2
by Jelmer Vernooij
Read/Write subunit2 test files. |
54 |
|
55 |
if py3_tests: |
|
|
6997.5.3
by Jelmer Vernooij
Fix test running. |
56 |
with tempfile.NamedTemporaryFile() as py3f: |
57 |
write_list(py3f, py3_tests) |
|
58 |
py3f.flush() |
|
59 |
subprocess.call( |
|
|
6997.5.7
by Jelmer Vernooij
Run python3 tests with python3. |
60 |
'python3 ./brz selftest --subunit2 --load-list=%s | subunit-filter -s --passthrough --rename "^" "python3."' % py3f.name, shell=True) |
|
6997.5.2
by Jelmer Vernooij
Read/Write subunit2 test files. |
61 |
else: |
|
6997.5.3
by Jelmer Vernooij
Fix test running. |
62 |
subprocess.call( |
63 |
'python ./brz selftest --subunit2 | subunit-filter -s --passthrough --rename "^" "python2."', shell=True) |
|
64 |
subprocess.call( |
|
|
6997.5.6
by Jelmer Vernooij
Fix run. |
65 |
'python3 ./brz selftest --subunit2 | subunit-filter -s --passthrough --rename "^" "python3."', shell=True) |