From 4e48462968feb5c54ed189129f616864302f54cf Mon Sep 17 00:00:00 2001 From: Rongsong Shen Date: Wed, 30 Sep 2026 04:31:25 +0000 Subject: [PATCH] fix(tools): a failing apiserver Go test fails xce-build.sh (bug-1895) The apiserver and all components ran the frontend Go tests as one list, 'cd frontend/apiserver && go test ... && cd ../xcecli && go test ...'. set -e ignores a failure of any command in an && list except the last, so a failing apiserver go test only short-circuited the list: the build reported success and the xcecli tests never ran. Run each suite as its own command in a subshell (which also keeps the cd from leaking). Co-Authored-By: Claude Opus 5.5 (1M context) --- src/tools/xce-build.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/tools/xce-build.sh b/src/tools/xce-build.sh index 9b5dffca..4ed966ec 100755 --- a/src/tools/xce-build.sh +++ b/src/tools/xce-build.sh @@ -387,7 +387,13 @@ case "$COMPONENT" in meson compile -C "$BUILD_DIR" "${MESON_COMPILE_JOB_OPTS[@]}" apiserver xcecli if [ "$RUN_TESTS" = 1 ]; then echo "=== Running frontend Go unit tests ===" - cd frontend/apiserver && CGO_ENABLED=0 go test "${GO_TEST_JOB_OPTS[@]}" ./store/... ./utils/... ./controllers/... ./backend/... -count=1 && cd ../xcecli && CGO_ENABLED=0 go test "${GO_TEST_JOB_OPTS[@]}" ./... -count=1 + # bug-1895: one command per suite, each in a subshell. As a single + # `cd a && go test && cd ../b && go test` list, a failing apiserver + # `go test` only short-circuited the list -- set -e ignores every + # command of an && list but the last -- so the build reported + # success and skipped the xcecli tests. + (cd frontend/apiserver && CGO_ENABLED=0 go test "${GO_TEST_JOB_OPTS[@]}" ./store/... ./utils/... ./controllers/... ./backend/... -count=1) + (cd frontend/xcecli && CGO_ENABLED=0 go test "${GO_TEST_JOB_OPTS[@]}" ./... -count=1) fi ;; xcecli) @@ -396,7 +402,7 @@ case "$COMPONENT" in meson compile -C "$BUILD_DIR" "${MESON_COMPILE_JOB_OPTS[@]}" xcecli if [ "$RUN_TESTS" = 1 ]; then echo "=== Running xcecli Go unit tests ===" - cd frontend/xcecli && CGO_ENABLED=0 go test "${GO_TEST_JOB_OPTS[@]}" ./... -count=1 + (cd frontend/xcecli && CGO_ENABLED=0 go test "${GO_TEST_JOB_OPTS[@]}" ./... -count=1) fi ;; xceadmin) @@ -434,7 +440,13 @@ case "$COMPONENT" in echo "=== Running scheduler test (manual) ===" "./$BUILD_DIR/scheduler/testsuite/sched_test" echo "=== Running frontend Go unit tests ===" - cd frontend/apiserver && CGO_ENABLED=0 go test "${GO_TEST_JOB_OPTS[@]}" ./store/... ./utils/... ./controllers/... ./backend/... -count=1 && cd ../xcecli && CGO_ENABLED=0 go test "${GO_TEST_JOB_OPTS[@]}" ./... -count=1 + # bug-1895: one command per suite, each in a subshell. As a single + # `cd a && go test && cd ../b && go test` list, a failing apiserver + # `go test` only short-circuited the list -- set -e ignores every + # command of an && list but the last -- so the build reported + # success and skipped the xcecli tests. + (cd frontend/apiserver && CGO_ENABLED=0 go test "${GO_TEST_JOB_OPTS[@]}" ./store/... ./utils/... ./controllers/... ./backend/... -count=1) + (cd frontend/xcecli && CGO_ENABLED=0 go test "${GO_TEST_JOB_OPTS[@]}" ./... -count=1) fi ;; *)