5
from subunit.v2 import StreamResultToBytes
8
from testrepository.testlist import parse_enumeration, parse_list, write_list
12
parser = argparse.ArgumentParser(
13
description="Test runner that supports both Python 2 and Python 3.")
16
"--load-list", metavar="PATH", help="Path to read list of tests to run from.",
19
"--list", help="List available tests.", action="store_true")
21
args = parser.parse_args()
25
output = subprocess.check_output(
26
['python2', './brz', 'selftest', '--subunit2', '--list'])
27
for n in parse_enumeration(output):
28
testids.append('python2.' + n)
30
output = subprocess.check_output(
31
['python3', './brz', 'selftest', '--subunit2', '--list'])
32
for n in parse_enumeration(output):
33
testids.append('python3.' + n)
34
stream = StreamResultToBytes(sys.stdout)
35
for testid in testids:
36
stream.status(test_id=testid, test_status='exists')
41
with open(args.load_list, 'rb') as f:
42
all_tests = parse_list(f.read())
43
for testname in all_tests:
44
if testname.startswith("python2."):
45
py2_tests.append(testname[len('python2.'):].strip())
46
elif testname.startswith("python3."):
47
py3_tests.append(testname[len('python3.'):].strip())
49
sys.stderr.write("unknown prefix %s\n" % testname)
51
with tempfile.NamedTemporaryFile() as py2f:
52
write_list(py2f, py2_tests)
55
'python2 ./brz selftest --subunit2 --load-list=%s | subunit-filter -s --passthrough --rename "^" "python2."' % py2f.name, shell=True)
58
with tempfile.NamedTemporaryFile() as py3f:
59
write_list(py3f, py3_tests)
62
'python3 ./brz selftest --subunit2 --load-list=%s | subunit-filter -s --passthrough --rename "^" "python3."' % py3f.name, shell=True)
65
'python2 ./brz selftest --subunit2 | subunit-filter -s --passthrough --rename "^" "python2."', shell=True)
67
'python3 ./brz selftest --subunit2 | subunit-filter -s --passthrough --rename "^" "python3."', shell=True)
70
if __name__ == '__main__':