mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
64 lines
1.2 KiB
Bash
Executable file
64 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
warnings=0
|
|
errors=0
|
|
|
|
function run {
|
|
echo "[......] $*"
|
|
|
|
# create tmpfile
|
|
tmpfile=$(mktemp)
|
|
# execute
|
|
$* >$tmpfile 2>&1
|
|
rc=$?
|
|
output=$(cat $tmpfile)
|
|
|
|
# check return code
|
|
if [[ $rc -eq 0 ]]; then
|
|
if [[ $output == *"[no test files]"* ]]; then
|
|
echo -e "\e[1A[\e[01;33mNOTEST\e[00m] $*"
|
|
warnings=$((warnings+1))
|
|
else
|
|
echo -ne "\e[1A[\e[01;32m OK \e[00m] "
|
|
if [[ $2 == "test" ]]; then
|
|
echo -n $*
|
|
echo -n ": "
|
|
echo $output | cut -f "3-" -d " "
|
|
else
|
|
echo $*
|
|
fi
|
|
fi
|
|
else
|
|
if [[ $output == *"build constraints exclude all Go files"* ]]; then
|
|
echo -e "\e[1A[\e[01;33mNOTEST\e[00m] $*"
|
|
warnings=$((warnings+1))
|
|
else
|
|
echo -e "\e[1A[\e[01;31m FAIL \e[00m] $*" >/dev/stderr
|
|
cat $tmpfile >/dev/stderr
|
|
errors=$((errors+1))
|
|
fi
|
|
fi
|
|
|
|
rm -f $tmpfile
|
|
}
|
|
|
|
# get and switch to script dir
|
|
baseDir="$( cd "$(dirname "$0")" && pwd )"
|
|
cd "$baseDir"
|
|
|
|
# get all packages
|
|
packages=$(go list ./...)
|
|
|
|
for package in $packages; do
|
|
run go vet $package
|
|
run go test -cover $package
|
|
done
|
|
|
|
echo ""
|
|
if [[ $errors -gt 0 ]]; then
|
|
echo "failed with $errors errors and $warnings warnings"
|
|
exit 1
|
|
else
|
|
echo "succeeded with $warnings warnings"
|
|
exit 0
|
|
fi
|