/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/testr-run.py

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import argparse
 
4
import subprocess
 
5
import sys
 
6
from testrepository.testlist import parse_list, write_list
 
7
 
 
8
parser = argparse.ArgumentParser(
 
9
    description="Test runner that supports both Python 2 and Python 3.")
 
10
 
 
11
parser.add_argument(
 
12
    "--load-list", metavar="PATH", help="Path to read list of tests to run from.",
 
13
    type=str)
 
14
parser.add_argument(
 
15
    "--list", help="List available tests.", action="store_true")
 
16
 
 
17
args = parser.parse_args()
 
18
 
 
19
if args.list:
 
20
    subprocess.call(['python', './brz', 'selftest', '--subunit2', '--list'])
 
21
    subprocess.call(['python3', './brz', 'selftest', '--subunit2', '--list'])
 
22
else:
 
23
    if args.load_list:
 
24
        py2_tests = []
 
25
        py3_tests = []
 
26
        with open(args.load_list, 'r') as f:
 
27
            all_tests = parse_list(f.read())
 
28
        for testname in all_tests:
 
29
            if testname.startswith("python2."):
 
30
                py2_tests.append(testname[len('python2.'):].strip())
 
31
            elif testname.startswith("python3."):
 
32
                py3_tests.append(testname[len('python3.'):].strip())
 
33
            else:
 
34
                sys.stderr.write("unknown prefix %s\n" % testname)
 
35
        import tempfile
 
36
        if py2_tests:
 
37
            with tempfile.NamedTemporaryFile() as py2f:
 
38
                write_list(py2f, py2_tests)
 
39
                py2f.flush()
 
40
                subprocess.call(
 
41
                    'python ./brz selftest --subunit2 --load-list=%s | subunit-filter -s --passthrough --rename "^" "python2."' % py2f.name, shell=True)
 
42
 
 
43
        if py3_tests:
 
44
            with tempfile.NamedTemporaryFile() as py3f:
 
45
                write_list(py3f, py3_tests)
 
46
                py3f.flush()
 
47
                subprocess.call(
 
48
                    'python ./brz selftest --subunit2 --load-list=%s | subunit-filter -s --passthrough --rename "^" "python3."' % py3f.name, shell=True)
 
49
    else:
 
50
        subprocess.call(
 
51
            'python ./brz selftest --subunit2 | subunit-filter -s --passthrough --rename "^" "python2."', shell=True)
 
52
        subprocess.call(
 
53
            'python ./brz selftest --subunit2 | subunit-filter -s --passthrough --rename "^" "python3."', shell=True)