Skip to content

Commit 5fd933e

Browse files
committedMar 5, 2017
[travis] Fold successful tests and some noise
1 parent 633c258 commit 5fd933e

File tree

4 files changed

+107
-55
lines changed

4 files changed

+107
-55
lines changed
 

‎.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ matrix:
3838
- txt2tags
3939
- xvfb
4040
- clang-3.8
41-
- grc
4241

4342

4443
- os: linux

‎ci/travis/linux/.grc.colors

Lines changed: 0 additions & 53 deletions
This file was deleted.

‎ci/travis/linux/script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ if [ "$CACHE_WARMING" = true ] ; then
3232
xvfb-run ctest -V -R NOTESTS -S ./qgis-test-travis.ctest --output-on-failure
3333
false
3434
else
35-
grc -c ${TRAVIS_BUILD_DIR}/ci/travis/linux/.grc.colors \
35+
python ${TRAVIS_BUILD_DIR}/ci/travis/scripts/ctest2travis.py \
3636
xvfb-run ctest -V -E "$(cat ${DIR}/blacklist.txt | sed -r '/^(#.*?)?$/d' | paste -sd '|' -)" -S ./qgis-test-travis.ctest --output-on-failure
3737
fi

‎ci/travis/scripts/ctest2travis.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
***************************************************************************
6+
ctest2travis.py
7+
---------------------
8+
Date : March 2017
9+
Copyright : (C) 2017 by Matthias Kuhn
10+
Email : matthias@opengis.ch
11+
***************************************************************************
12+
* *
13+
* This program is free software; you can redistribute it and/or modify *
14+
* it under the terms of the GNU General Public License as published by *
15+
* the Free Software Foundation; either version 2 of the License, or *
16+
* (at your option) any later version. *
17+
* *
18+
***************************************************************************
19+
"""
20+
21+
__author__ = 'Matthias Kuhn'
22+
__date__ = 'March 2017'
23+
__copyright__ = '(C) 2017, Matthias Kuhn'
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
__revision__ = '$Format:%H$'
26+
27+
# This script parses output from ctest and injects
28+
#
29+
# - Colors for failing unit tests and test cases
30+
#
31+
# - `travis_fold` control sequences to hide uninteresting output by default
32+
33+
import sys
34+
import re
35+
import shlex
36+
import subprocess
37+
from termcolor import colored
38+
39+
fold_stack = list()
40+
41+
42+
def start_fold(tag):
43+
sys.stdout.write('travis_fold:start:{}\n'.format(tag))
44+
fold_stack.append(tag)
45+
46+
47+
def end_fold():
48+
tag = fold_stack.pop()
49+
sys.stdout.write('travis_fold:end:{}\n'.format(tag))
50+
51+
52+
test_count = 0
53+
54+
55+
def start_test_fold():
56+
global test_count
57+
sys.stdout.write('Running tests')
58+
start_fold('test.{}'.format(test_count))
59+
test_count += 1
60+
61+
62+
in_failing_test = False
63+
in_failure = False
64+
65+
p = subprocess.Popen(sys.argv[1:], stdout=subprocess.PIPE)
66+
67+
for line in p.stdout:
68+
updated_line = line.decode('utf-8')
69+
if re.match('Run dashboard with model Experimental', updated_line):
70+
start_fold('build')
71+
updated_line = 'Compiling\n{}'.format(updated_line)
72+
73+
elif re.match('Test project /home/travis/build/qgis/QGIS/build', updated_line):
74+
end_fold() # tag=build
75+
start_test_fold()
76+
77+
if re.search('\*\*\*Failed', updated_line) or re.search('\*\*\*Timeout', updated_line):
78+
end_fold()
79+
updated_line = colored(updated_line, 'red')
80+
in_failing_test = True
81+
82+
if in_failing_test:
83+
if re.match(' Start', updated_line):
84+
start_test_fold()
85+
in_failing_test = False
86+
elif in_failure:
87+
if re.match('PASS', updated_line) or re.match('Ran', updated_line):
88+
in_failure = False
89+
else:
90+
updated_line = colored(updated_line, 'yellow')
91+
else:
92+
if re.match('FAIL[:\!].*', updated_line):
93+
updated_line = colored(updated_line, 'yellow')
94+
in_failure = True
95+
96+
if not in_failing_test and re.search('[0-9]+% tests passed, [0-9]+ tests failed out of', updated_line):
97+
end_fold()
98+
99+
if re.match('Submit files', updated_line):
100+
start_fold('submit')
101+
elif re.search('Test results submitted to', updated_line):
102+
end_fold()
103+
104+
sys.stdout.write(updated_line)
105+
106+
exit(p.wait())

0 commit comments

Comments
 (0)
Please sign in to comment.