util/lint/lint: Add -I option to invert test results
To test the linters, we want to invert the results so that any test that passes shows up as a failure. This will allow us to verify that all of the linters are working correctly. This will be tested nightly as well as on changes to the lint tools. Signed-off-by: Martin Roth <gaumless@gmail.com> Change-Id: Ia8024c6ab0c91fd9f630f37dc802ed3bc6b4608c Reviewed-on: https://review.coreboot.org/c/coreboot/+/67193 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Raul Rangel <rrangel@chromium.org>
This commit is contained in:
parent
8b570bd2a1
commit
38bbff47a7
|
@ -6,6 +6,7 @@
|
||||||
#set -x # uncomment for debug
|
#set -x # uncomment for debug
|
||||||
|
|
||||||
JUNIT=0
|
JUNIT=0
|
||||||
|
INVERT=0
|
||||||
|
|
||||||
usage () {
|
usage () {
|
||||||
printf "Usage: %s <sub-command> [Options]\n" "$0"
|
printf "Usage: %s <sub-command> [Options]\n" "$0"
|
||||||
|
@ -16,6 +17,7 @@ usage () {
|
||||||
|
|
||||||
printf " Options:\n"
|
printf " Options:\n"
|
||||||
printf " -h | --help : Show this help message\n"
|
printf " -h | --help : Show this help message\n"
|
||||||
|
printf " -I | --invert : Invert results - used for testing linters\n"
|
||||||
printf " -J | --junit : Send test output to a JUnit file\n"
|
printf " -J | --junit : Send test output to a JUnit file\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
}
|
}
|
||||||
|
@ -27,7 +29,7 @@ junit_write () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! cmd_args="$(getopt -l help,junit -o hJ -- "$@")"; then
|
if ! cmd_args="$(getopt -l help,junit,invert -o hIJ -- "$@")"; then
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -39,6 +41,9 @@ while true; do
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
-I | --invert)
|
||||||
|
INVERT=1
|
||||||
|
;;
|
||||||
-J | --junit)
|
-J | --junit)
|
||||||
echo "selected junit"
|
echo "selected junit"
|
||||||
JUNIT=1
|
JUNIT=1
|
||||||
|
@ -81,7 +86,10 @@ for script in "$(dirname "$0")/${1}-"*; do
|
||||||
$script | tee "$LINTLOG"
|
$script | tee "$LINTLOG"
|
||||||
|
|
||||||
#if the lint script gives any output, that's a failure
|
#if the lint script gives any output, that's a failure
|
||||||
if [ "$(wc -l < "$LINTLOG")" -eq 0 ]; then
|
if [ "${INVERT}" -eq 1 ] && [ "$(wc -l < "$LINTLOG")" -ne 0 ]; then
|
||||||
|
echo "success"
|
||||||
|
junit_write " <system-out><![CDATA[success]]></system-out>"
|
||||||
|
elif [ "${INVERT}" -eq 0 ] && [ "$(wc -l < "$LINTLOG")" -eq 0 ]; then
|
||||||
echo "success"
|
echo "success"
|
||||||
junit_write " <system-out><![CDATA[success]]></system-out>"
|
junit_write " <system-out><![CDATA[success]]></system-out>"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue