From a262063819b6f249481f7a1d8ea2e88917609578 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 24 Mar 2020 09:26:57 +0100 Subject: [PATCH] tests: use go modules from ./vendor for running tests Running tests without `-mod=vendor` causes the tests to download the dependencies if these are not available in the standard go-module directories (parent directories of the project). All dependencies are already included in the ./vendor directory, so passing `-mod=vendor` prevents downloading the dependencies and speeds up testing a lot. Signed-off-by: Niels de Vos --- scripts/test-go.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/test-go.sh b/scripts/test-go.sh index 8cb1fb067..9a567c68d 100755 --- a/scripts/test-go.sh +++ b/scripts/test-go.sh @@ -1,12 +1,12 @@ #!/bin/bash -GOPACKAGES="$(go list ./... | grep -v vendor | grep -v e2e)" +GOPACKAGES="$(go list -mod=vendor ./... | grep -v -e vendor -e e2e)" COVERFILE="${GO_COVER_DIR}/profile.cov" # no special options, exec to go test w/ all pkgs if [[ ${TEST_EXITFIRST} != "yes" && -z ${TEST_COVERAGE} ]]; then # shellcheck disable=SC2086 - exec go test ${GOPACKAGES} + exec go test -mod=vendor -v ${GOPACKAGES} fi # our options are set so we need to handle each go package one @@ -20,7 +20,7 @@ failed=0 for gopackage in ${GOPACKAGES}; do echo "--- testing: ${gopackage} ---" # shellcheck disable=SC2086 - go test ${GOTESTOPTS} "${gopackage}" || ((failed += 1)) + go test -mod=vendor -v ${GOTESTOPTS} "${gopackage}" || ((failed += 1)) if [[ -f cover.out ]]; then # Append to coverfile grep -v "^mode: count" cover.out >>"${COVERFILE}"