From 0f597561e86e842d771cca861928afa4862dae8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Wed, 12 Nov 2025 18:20:39 +0100 Subject: [PATCH] hack/test/unit: Fix api and client module testing without replace rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Running sub-package tests from the root module without readding the replace rules wasn't running the tests from the local in-tree versions of these submodules. Fix by cd-ing into their directories before running tests. Signed-off-by: Paweł Gronowski --- hack/test/unit | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/hack/test/unit b/hack/test/unit index 569c6775cf..6cd3886c8a 100755 --- a/hack/test/unit +++ b/hack/test/unit @@ -38,14 +38,17 @@ if [ -n "${api_pkg_list}" ]; then # is not provided by any known module. # - `-mod=readonly` tells the go command to ignore the vendor directory # and to report an error if `go.mod` needs to be updated. - gotestsum --format=standard-quiet --jsonfile=bundles/api-go-test-report.json --junitfile=bundles/api-junit-report.xml -- \ - "${BUILDFLAGS[@]}" \ - -cover \ - -coverprofile=bundles/api-coverage.out \ - -covermode=atomic \ - -mod=readonly \ - ${TESTFLAGS} \ - ${api_pkg_list} + ( + cd api + gotestsum --format=standard-quiet --jsonfile=../bundles/api-go-test-report.json --junitfile=../bundles/api-junit-report.xml -- \ + "${BUILDFLAGS[@]}" \ + -cover \ + -coverprofile=../bundles/api-coverage.out \ + -covermode=atomic \ + -mod=readonly \ + ${TESTFLAGS} \ + ${api_pkg_list} || exit $? + ) fi case "$TESTDIRS" in @@ -65,14 +68,17 @@ if [ -n "${client_pkg_list}" ]; then # is not provided by any known module. # - `-mod=readonly` tells the go command to ignore the vendor directory # and to report an error if `go.mod` needs to be updated. - gotestsum --format=standard-quiet --jsonfile=bundles/client-go-test-report.json --junitfile=bundles/client-junit-report.xml -- \ - "${BUILDFLAGS[@]}" \ - -cover \ - -coverprofile=bundles/client-coverage.out \ - -covermode=atomic \ - -mod=readonly \ - ${TESTFLAGS} \ - ${client_pkg_list} + ( + cd client + gotestsum --format=standard-quiet --jsonfile=../bundles/client-go-test-report.json --junitfile=../bundles/client-junit-report.xml -- \ + "${BUILDFLAGS[@]}" \ + -cover \ + -coverprofile=../bundles/client-coverage.out \ + -covermode=atomic \ + -mod=readonly \ + ${TESTFLAGS} \ + ${client_pkg_list} || exit $? + ) fi case "$TESTDIRS" in