Files
kustomize/hack/testUnitKustomizePlugins.sh
Li Zhijian 054f18701a Makefile/scripts: check and use GOBIN environment variable first
'go get/install' will install binaries into GOBIN when it's set which is not
always same with GOPATH/bin

Fix below error:
$ hack/testExamplesAgainstKustomize.sh HEAD
Installing kustomize HEAD
On linux, and not on remote CI.  Running expensive tests.
make: Nothing to be done for '/home/lizj/gosrc/bin/helm'.
Removing kustomize HEAD
rm: cannot remove '/home/lizj/gosrc/bin/kustomize': No such file or directory

Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
2021-02-10 14:06:00 +08:00

70 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
# Run this script with no arguments from the repo root
# to test all the plugins.
# Want this to keep going even if one test fails,
# to see how many pass, so do not errexit.
set -o nounset
# set -o errexit
set -o pipefail
rcAccumulator=0
MYGOBIN=$(go env GOBIN)
MYGOBIN="${MYGOBIN:-$(go env GOPATH)/bin}"
# All hack scripts should run from top level.
. hack/shellHelpers.sh
function runTest {
local file=$1
local code=0
if grep -q "// +build notravis" "$file"; then
if onLinuxAndNotOnRemoteCI; then
go test -v -tags=notravis $file
code=$?
else
# TODO: make work for non-linux
echo "Not on linux or on remote CI; skipping $file"
fi
else
go test -v $file
code=$?
fi
rcAccumulator=$((rcAccumulator || $code))
if [ $code -ne 0 ]; then
echo "**** FAILURE in $d"
fi
}
function scanDir {
pushd $1 >& /dev/null
echo "Testing $1"
for t in $(find . -name '*_test.go'); do
runTest $t
done
popd >& /dev/null
}
if onLinuxAndNotOnRemoteCI; then
# Some of these tests have special deps.
make $MYGOBIN/helmV2
make $MYGOBIN/helmV3
make $MYGOBIN/helm
make $MYGOBIN/kubeval
fi
for goMod in $(find ./plugin -name 'go.mod' -not -path "./plugin/untested/*"); do
d=$(dirname "${goMod}")
scanDir $d
done
if [ $rcAccumulator -ne 0 ]; then
echo "FAIL; exit code $rcAccumulator"
exit 1
fi