Skip to content

Commit

Permalink
run_pylint: Add fast-fail option
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Evich <[email protected]>
  • Loading branch information
cevich committed Jun 24, 2015
1 parent 52086c4 commit 5d6cace
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ script:
- SPHINXOPTS="-W" make
- ./run_checkdocs.py
- ./run_unittests.sh
- ./run_pylint.sh
- ./run_pylint.sh --FF

# TODO: Do we need notifications?
#notifications:
Expand Down
63 changes: 49 additions & 14 deletions run_pylint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/bash

# Optional fast-fail on first error encountered
if [ "$#" -gt "0" ] && [ "$1" == "--FF" ]
then
FF=1
shift
echo "Fast-failing on first error encountered"
else
FF=0
fi

TMPFILENAME="/tmp/run_pylint_$RANDOM"
PEP8=`which pep8`
PEP8IGNORE='E731'
Expand Down Expand Up @@ -62,7 +72,10 @@ check_dockertest() {
--rcfile=/dev/null \
--msg-template="$MSGFMT" "${WHAT}"
RET="$?"
if [ "$RET" -ne "0" ]
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
then
return $RET
elif [ "$RET" -ne "0" ]
then
record_return 1
else
Expand All @@ -77,7 +90,14 @@ check_dockertest() {
if [ -n "$PEP8" ]
then
$PEP8 --ignore=$PEP8IGNORE "$WHAT"
record_return $?
RET="$?"
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
then
return $RET
elif [ "$RET" -ne "0" ]
then
record_return 1
fi
fi
}

Expand All @@ -87,6 +107,11 @@ check_dockertests() {
while read LINE; do
trap "break" INT
check_dockertest "${LINE}"
RET="$?"
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
then
return $RET
fi
done
}

Expand All @@ -102,7 +127,10 @@ check_subtest() {
--rcfile=/dev/null \
--msg-template="$MSGFMT" "${WHAT}"
RET="$?"
if [ "$RET" -ne "0" ]
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
then
return $RET
elif [ "$RET" -ne "0" ]
then
record_return 1
else
Expand All @@ -117,7 +145,14 @@ check_subtest() {
if [ -n "$PEP8" ]
then
$PEP8 --ignore=$PEP8IGNORE "$WHAT"
record_return $?
RET="$?"
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
then
return $RET
elif [ "$RET" -ne "0" ]
then
record_return 1
fi
fi
}

Expand All @@ -129,32 +164,32 @@ check_subtests() {
find ${thing} -name '*.py' | while read LINE; do
trap "break" INT
check_subtest "${LINE}"
RET="$?"
if [ "$RET" -ne "0" ] && [ "$FF" -eq "1" ]
then
return $RET
fi
done
done
}

if [ "$#" -eq "0" ]
then
check_dockertests
[ "$?" -eq "0" ] || exit 1
check_subtests
[ "$?" -eq "0" ] || exit 1
else
for THING in $@
do
if echo "$THING" | grep -q 'dockertest'
then
check_dockertest "$THING"
elif echo "$THING" | grep -q 'subtests'
then
check_subtest "$THING"
elif echo "$THING" | grep -q 'pretests'
then
check_subtest "$THING"
elif echo "$THING" | grep -q 'intratests'
then
check_subtest "$THING"
elif echo "$THING" | grep -q 'posttests'
[ "$?" -eq "0" ] || exit 1
elif echo "$THING" | grep -q 'tests'
then
check_subtest "$THING"
[ "$?" -eq "0" ] || exit 1
else
echo "Ignoring $THING"
fi
Expand Down

0 comments on commit 5d6cace

Please sign in to comment.