mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 11:00:25 +00:00
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 <ndevos@redhat.com>
This commit is contained in:
parent
79b0b8cfa6
commit
a262063819
@ -1,12 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/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"
|
COVERFILE="${GO_COVER_DIR}/profile.cov"
|
||||||
|
|
||||||
# no special options, exec to go test w/ all pkgs
|
# no special options, exec to go test w/ all pkgs
|
||||||
if [[ ${TEST_EXITFIRST} != "yes" && -z ${TEST_COVERAGE} ]]; then
|
if [[ ${TEST_EXITFIRST} != "yes" && -z ${TEST_COVERAGE} ]]; then
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
exec go test ${GOPACKAGES}
|
exec go test -mod=vendor -v ${GOPACKAGES}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# our options are set so we need to handle each go package one
|
# our options are set so we need to handle each go package one
|
||||||
@ -20,7 +20,7 @@ failed=0
|
|||||||
for gopackage in ${GOPACKAGES}; do
|
for gopackage in ${GOPACKAGES}; do
|
||||||
echo "--- testing: ${gopackage} ---"
|
echo "--- testing: ${gopackage} ---"
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
go test ${GOTESTOPTS} "${gopackage}" || ((failed += 1))
|
go test -mod=vendor -v ${GOTESTOPTS} "${gopackage}" || ((failed += 1))
|
||||||
if [[ -f cover.out ]]; then
|
if [[ -f cover.out ]]; then
|
||||||
# Append to coverfile
|
# Append to coverfile
|
||||||
grep -v "^mode: count" cover.out >>"${COVERFILE}"
|
grep -v "^mode: count" cover.out >>"${COVERFILE}"
|
||||||
|
Loading…
Reference in New Issue
Block a user