Skip to content

Commit 5d6cace

Browse files
committed
run_pylint: Add fast-fail option
Signed-off-by: Chris Evich <cevich@redhat.com>
1 parent 52086c4 commit 5d6cace

File tree

2 files changed

+50
-15
lines changed

2 files changed

+50
-15
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ script:
2727
- SPHINXOPTS="-W" make
2828
- ./run_checkdocs.py
2929
- ./run_unittests.sh
30-
- ./run_pylint.sh
30+
- ./run_pylint.sh --FF
3131

3232
# TODO: Do we need notifications?
3333
#notifications:

run_pylint.sh

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#!/bin/bash
22

3+
# Optional fast-fail on first error encountered
4+
if [ "$#" -gt "0" ] && [ "$1" == "--FF" ]
5+
then
6+
FF=1
7+
shift
8+
echo "Fast-failing on first error encountered"
9+
else
10+
FF=0
11+
fi
12+
313
TMPFILENAME="/tmp/run_pylint_$RANDOM"
414
PEP8=`which pep8`
515
PEP8IGNORE='E731'
@@ -62,7 +72,10 @@ check_dockertest() {
6272
--rcfile=/dev/null \
6373
--msg-template="$MSGFMT" "${WHAT}"
6474
RET="$?"
65-
if [ "$RET" -ne "0" ]
75+
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
76+
then
77+
return $RET
78+
elif [ "$RET" -ne "0" ]
6679
then
6780
record_return 1
6881
else
@@ -77,7 +90,14 @@ check_dockertest() {
7790
if [ -n "$PEP8" ]
7891
then
7992
$PEP8 --ignore=$PEP8IGNORE "$WHAT"
80-
record_return $?
93+
RET="$?"
94+
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
95+
then
96+
return $RET
97+
elif [ "$RET" -ne "0" ]
98+
then
99+
record_return 1
100+
fi
81101
fi
82102
}
83103

@@ -87,6 +107,11 @@ check_dockertests() {
87107
while read LINE; do
88108
trap "break" INT
89109
check_dockertest "${LINE}"
110+
RET="$?"
111+
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
112+
then
113+
return $RET
114+
fi
90115
done
91116
}
92117

@@ -102,7 +127,10 @@ check_subtest() {
102127
--rcfile=/dev/null \
103128
--msg-template="$MSGFMT" "${WHAT}"
104129
RET="$?"
105-
if [ "$RET" -ne "0" ]
130+
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
131+
then
132+
return $RET
133+
elif [ "$RET" -ne "0" ]
106134
then
107135
record_return 1
108136
else
@@ -117,7 +145,14 @@ check_subtest() {
117145
if [ -n "$PEP8" ]
118146
then
119147
$PEP8 --ignore=$PEP8IGNORE "$WHAT"
120-
record_return $?
148+
RET="$?"
149+
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
150+
then
151+
return $RET
152+
elif [ "$RET" -ne "0" ]
153+
then
154+
record_return 1
155+
fi
121156
fi
122157
}
123158

@@ -129,32 +164,32 @@ check_subtests() {
129164
find ${thing} -name '*.py' | while read LINE; do
130165
trap "break" INT
131166
check_subtest "${LINE}"
167+
RET="$?"
168+
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
169+
then
170+
return $RET
171+
fi
132172
done
133173
done
134174
}
135175

136176
if [ "$#" -eq "0" ]
137177
then
138178
check_dockertests
179+
[ "$?" -eq "0" ] || exit 1
139180
check_subtests
181+
[ "$?" -eq "0" ] || exit 1
140182
else
141183
for THING in $@
142184
do
143185
if echo "$THING" | grep -q 'dockertest'
144186
then
145187
check_dockertest "$THING"
146-
elif echo "$THING" | grep -q 'subtests'
147-
then
148-
check_subtest "$THING"
149-
elif echo "$THING" | grep -q 'pretests'
150-
then
151-
check_subtest "$THING"
152-
elif echo "$THING" | grep -q 'intratests'
153-
then
154-
check_subtest "$THING"
155-
elif echo "$THING" | grep -q 'posttests'
188+
[ "$?" -eq "0" ] || exit 1
189+
elif echo "$THING" | grep -q 'tests'
156190
then
157191
check_subtest "$THING"
192+
[ "$?" -eq "0" ] || exit 1
158193
else
159194
echo "Ignoring $THING"
160195
fi

0 commit comments

Comments
 (0)