test: fix fmt pass and shorten suppression warnings

If gosimple or staticcheck had no output, it no other passes would be
applied because they were using `continue`. Similarly, the suppression
check never worked at all since it wasn't the result data into egrep.

Fixes #7685
This commit is contained in:
Anthony Romano 2017-04-06 21:24:39 -07:00
parent 25ed908c18
commit d31701bab5

41
test
View File

@ -250,16 +250,15 @@ function fmt_pass {
if which gosimple >/dev/null; then if which gosimple >/dev/null; then
echo "Checking gosimple..." echo "Checking gosimple..."
gosimpleResult=`gosimple ${STATIC_ANALYSIS_PATHS} 2>&1 || true` gosimpleResult=`gosimple ${STATIC_ANALYSIS_PATHS} 2>&1 || true`
if [ ! -n "${gosimpleResult}" ]; then if [ -n "${gosimpleResult}" ]; then
continue # TODO: resolve these after go1.8 migration
fi SIMPLE_CHECK_MASK="S(1024)"
# TODO: resolve these after go1.8 migration if echo "${gosimpleResult}" | egrep -v "$SIMPLE_CHECK_MASK"; then
SIMPLE_CHECK_MASK="S(1024)" echo -e "gosimple checking ${path} failed:\n${gosimpleResult}"
if egrep -v "$SIMPLE_CHECK_MASK" "${gosimpleResult}"; then exit 255
echo -e "gosimple checking ${path} failed:\n${gosimpleResult}" else
exit 255 echo -e "gosimple warning:\n${gosimpleResult}"
else fi
echo -e "gosimple warning:\n${gosimpleResult}"
fi fi
else else
echo "Skipping gosimple..." echo "Skipping gosimple..."
@ -279,17 +278,17 @@ function fmt_pass {
if which staticcheck >/dev/null; then if which staticcheck >/dev/null; then
echo "Checking staticcheck..." echo "Checking staticcheck..."
staticcheckResult=`staticcheck ${STATIC_ANALYSIS_PATHS} 2>&1 || true` staticcheckResult=`staticcheck ${STATIC_ANALYSIS_PATHS} 2>&1 || true`
if [ ! -n "${staticcheckResult}" ]; then if [ -n "${staticcheckResult}" ]; then
continue # TODO: resolve these after go1.8 migration
fi # See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck
# TODO: resolve these after go1.8 migration STATIC_CHECK_MASK="SA(1016|1019|2002)"
# See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck if echo "${staticcheckResult}" | egrep -v "$STATIC_CHECK_MASK"; then
STATIC_CHECK_MASK="SA(1016|1019|2002)" echo -e "staticcheck checking ${path} failed:\n${staticcheckResult}"
if egrep -v "$STATIC_CHECK_MASK" "${staticcheckResult}"; then exit 255
echo -e "staticcheck checking ${path} failed:\n${staticcheckResult}" else
exit 255 suppressed=`echo "${staticcheckResult}" | sed 's/ /\n/g' | grep "(SA" | sort | uniq -c`
else echo -e "staticcheck suppressed warnings:\n${suppressed}"
echo -e "staticcheck warning:\n${staticcheckResult}" fi
fi fi
else else
echo "Skipping staticcheck..." echo "Skipping staticcheck..."