mirror of
https://github.com/safing/portbase
synced 2025-09-04 03:29:59 +00:00
Update test script
This commit is contained in:
parent
f59ad0357a
commit
ea57310483
1 changed files with 10 additions and 32 deletions
42
test
42
test
|
@ -17,9 +17,9 @@ function help {
|
||||||
echo " install install deps for running tests"
|
echo " install install deps for running tests"
|
||||||
echo ""
|
echo ""
|
||||||
echo "options:"
|
echo "options:"
|
||||||
echo " --scripted dont jump console lines (still use colors)"
|
echo " --scripted don't jump console lines (still use colors)"
|
||||||
echo " --test-only skip linters and only run tests"
|
echo " --test-only run tests only, no linters"
|
||||||
echo " [package] run tests only on this package"
|
echo " [package] run only on this package"
|
||||||
}
|
}
|
||||||
|
|
||||||
function run {
|
function run {
|
||||||
|
@ -62,22 +62,6 @@ function run {
|
||||||
rm -f $tmpfile
|
rm -f $tmpfile
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkformat {
|
|
||||||
if [[ $scripted -eq 0 ]]; then
|
|
||||||
echo "[......] gofmt $1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
output=$(gofmt -l $GOPATH/src/$1/*.go)
|
|
||||||
if [[ $output == "" ]]; then
|
|
||||||
echo -e "${goUp}[\e[01;32m OK \e[00m] gofmt $*"
|
|
||||||
else
|
|
||||||
echo -e "${goUp}[\e[01;31m FAIL \e[00m] gofmt $*"
|
|
||||||
echo "The following files do not conform to gofmt:"
|
|
||||||
gofmt -l $GOPATH/src/$1/*.go # keeps format
|
|
||||||
errors=$((errors+1))
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# get and switch to script dir
|
# get and switch to script dir
|
||||||
baseDir="$( cd "$(dirname "$0")" && pwd )"
|
baseDir="$( cd "$(dirname "$0")" && pwd )"
|
||||||
cd "$baseDir"
|
cd "$baseDir"
|
||||||
|
@ -154,18 +138,14 @@ if [[ $testonly -eq 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# target selection
|
# target selection
|
||||||
if [[ "$1" == "" ]]; then
|
if [[ "$1" == "" ]]; then
|
||||||
# get all packages
|
# get all packages
|
||||||
packages=$(go list ./...)
|
packages=$(go list -e ./...)
|
||||||
else
|
else
|
||||||
# single package testing
|
# single package testing
|
||||||
packages=$(go list)/$1
|
packages=$(go list -e)/$1
|
||||||
if [[ ! -d "$GOPATH/src/$packages" ]]; then
|
|
||||||
echo "go package $packages does not exist"
|
|
||||||
help
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "note: only running tests for package $packages"
|
echo "note: only running tests for package $packages"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -175,16 +155,14 @@ echo "running tests for ${platformInfo//$'\n'/ }:"
|
||||||
|
|
||||||
# run vet/test on packages
|
# run vet/test on packages
|
||||||
for package in $packages; do
|
for package in $packages; do
|
||||||
package=${package#github.com/safing/portbase}
|
packagename=${package#github.com/safing/portbase} #TODO: could be queried with `go list .`
|
||||||
package=${package#/}
|
packagename=${packagename#/}
|
||||||
package=$PWD/$package
|
|
||||||
echo ""
|
echo ""
|
||||||
echo $package
|
echo $package
|
||||||
if [[ $testonly -eq 0 ]]; then
|
if [[ $testonly -eq 0 ]]; then
|
||||||
checkformat $package
|
|
||||||
run golint -set_exit_status -min_confidence 1.0 $package
|
run golint -set_exit_status -min_confidence 1.0 $package
|
||||||
run go vet $package
|
run go vet $package
|
||||||
run golangci-lint run $package
|
run golangci-lint run $packagename
|
||||||
fi
|
fi
|
||||||
run go test -cover $fullTestFlags $package
|
run go test -cover $fullTestFlags $package
|
||||||
done
|
done
|
||||||
|
@ -196,4 +174,4 @@ if [[ $errors -gt 0 ]]; then
|
||||||
else
|
else
|
||||||
echo "succeeded with $warnings warnings"
|
echo "succeeded with $warnings warnings"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue