Update test script, config and workflow
This commit is contained in:
50
test
50
test
@@ -17,9 +17,9 @@ function help {
|
||||
echo " install install deps for running tests"
|
||||
echo ""
|
||||
echo "options:"
|
||||
echo " --scripted dont jump console lines (still use colors)"
|
||||
echo " --test-only don run linters only tests"
|
||||
echo " [package] run tests only on this package"
|
||||
echo " --scripted don't jump console lines (still use colors)"
|
||||
echo " --test-only run tests only, no linters"
|
||||
echo " [package] run only on this package"
|
||||
}
|
||||
|
||||
function run {
|
||||
@@ -62,22 +62,6 @@ function run {
|
||||
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
|
||||
baseDir="$( cd "$(dirname "$0")" && pwd )"
|
||||
cd "$baseDir"
|
||||
@@ -120,11 +104,9 @@ fi
|
||||
# install
|
||||
if [[ $install -eq 1 ]]; then
|
||||
echo "installing dependencies..."
|
||||
echo "$ go get -u golang.org/x/lint/golint"
|
||||
go get -u golang.org/x/lint/golint
|
||||
# TODO: update golangci-lint version regularly
|
||||
echo "$ curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0"
|
||||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0
|
||||
echo "$ curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.44.0"
|
||||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.44.0
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -138,12 +120,6 @@ if [[ $testonly -eq 0 ]]; then
|
||||
echo "gofmt command not found"
|
||||
exit 1
|
||||
fi
|
||||
if [[ $(which golint) == "" ]]; then
|
||||
echo "golint command not found"
|
||||
echo "install with: go get -u golang.org/x/lint/golint"
|
||||
echo "or run: ./test install"
|
||||
exit 1
|
||||
fi
|
||||
if [[ $(which golangci-lint) == "" ]]; then
|
||||
echo "golangci-lint command not found"
|
||||
echo "install with: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin vX.Y.Z"
|
||||
@@ -158,15 +134,10 @@ fi
|
||||
# target selection
|
||||
if [[ "$1" == "" ]]; then
|
||||
# get all packages
|
||||
packages=$(go list ./...)
|
||||
packages=$(go list -e ./...)
|
||||
else
|
||||
# single package testing
|
||||
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"
|
||||
fi
|
||||
|
||||
@@ -176,16 +147,13 @@ echo "running tests for ${platformInfo//$'\n'/ }:"
|
||||
|
||||
# run vet/test on packages
|
||||
for package in $packages; do
|
||||
package=${package#github.com/safing/portmaster}
|
||||
package=${package#/}
|
||||
package=$PWD/$package
|
||||
packagename=${package#github.com/safing/portmaster} #TODO: could be queried with `go list .`
|
||||
packagename=${packagename#/}
|
||||
echo ""
|
||||
echo $package
|
||||
if [[ $testonly -eq 0 ]]; then
|
||||
checkformat $package
|
||||
run golint -set_exit_status -min_confidence 1.0 $package
|
||||
run go vet $package
|
||||
run golangci-lint run $package
|
||||
run golangci-lint run $packagename
|
||||
fi
|
||||
run go test -cover $fullTestFlags $package
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user