5
from subunit.v2 import StreamResultToBytes
8
from testrepository.testlist import parse_enumeration, parse_list, write_list
11
parser = argparse.ArgumentParser(
12
description="Test runner that supports both Python 2 and Python 3.")
15
"--load-list", metavar="PATH", help="Path to read list of tests to run from.",
18
"--list", help="List available tests.", action="store_true")
20
args = parser.parse_args()
24
with subprocess.Popen(['python', './brz', 'selftest', '--subunit2', '--list'],
25
stdout=subprocess.PIPE).stdout as f:
26
for n in parse_enumeration(f.read()):
27
testids.append('python2.' + n)
28
with subprocess.Popen(['python3', './brz', 'selftest', '--subunit2', '--list'],
29
stdout=subprocess.PIPE).stdout as f:
30
for n in parse_enumeration(f.read()):
31
testids.append('python3.' + n)
32
stream = StreamResultToBytes(sys.stdout)
33
for testid in testids:
34
stream.status(test_id=testid, test_status='exists')
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())
47
sys.stderr.write("unknown prefix %s\n" % testname)
49
with tempfile.NamedTemporaryFile() as py2f:
50
write_list(py2f, py2_tests)
53
'python ./brz selftest --subunit2 --load-list=%s | subunit-filter -s --passthrough --rename "^" "python2."' % py2f.name, shell=True)
56
with tempfile.NamedTemporaryFile() as py3f:
57
write_list(py3f, py3_tests)
60
'python3 ./brz selftest --subunit2 --load-list=%s | subunit-filter -s --passthrough --rename "^" "python3."' % py3f.name, shell=True)
63
'python ./brz selftest --subunit2 | subunit-filter -s --passthrough --rename "^" "python2."', shell=True)
65
'python3 ./brz selftest --subunit2 | subunit-filter -s --passthrough --rename "^" "python3."', shell=True)