run-ctest.py 836 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from __future__ import print_function
import sys
from os.path import join, exists
from subprocess import call

def main():
    # pass any extra arguments to the first ctest invocation
    if call(['ctest', '--output-on-failure'] + sys.argv[1:], shell=True) == 0:
        return 0

    # load the log file containing the failed tests and reformat
    # it in a way so that ctest can take it as input to rerun
    # the failing tests
    log = join('Testing', 'Temporary', 'LastTestsFailed.log')
    assert exists(log)

    failed = []
    for line in open(log):
        failed.append(line.split(':')[0])

    with open('FailedTests.log', 'w') as f:
        print(','.join(x + ',' + x for x in failed), file=f)

    return call(['ctest', '--output-on-failure', '-I', 'FailedTests.log'])


if __name__ == '__main__':
    sys.exit(main())