feat(eliminate-frontend-makefile): task 1.1 - Meson backend CGO test target

Adds a new `test('apiserver backend', ...)` in apiserver/meson.build
reusing the existing apiserver_cgo_deps-derived CGO flags (resolving
their @CURRENT_SOURCE_DIR@/@BUILD_ROOT@ placeholder tokens via
Meson's own .replace(), since this target invokes go_compiler
directly rather than through tools/go_build). Adds timeout: 300
(matching the existing controller test's convention) since a
cold-cache CGO+ASAN build exceeds Meson's 30s default.

Verified cold and warm cache; confirmed CGO_ENABLED=1 selects the
real backend/ CGO path, not the //go:build !cgo stub.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYdtrEWWZfKRRGED7raEYg
This commit is contained in:
Rongsong Shen 2026-09-03 13:17:06 +00:00
parent 5f40c3fb32
commit 6c3ff2012b
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
2 changed files with 35 additions and 1 deletions

View file

@ -65,3 +65,37 @@ custom_target('apiserver',
depends: [libxce],
install: true,
install_dir: get_option('prefix') / 'bin')
# CGO-backed backend test suite, run directly via `go test` under Meson's
# test runner (not through tools/go_build, which only knows how to invoke
# `go build` once for a single output). This reuses apiserver_cgo_deps's
# already-computed cgo_cflags/cgo_ldflags (the same values the custom_target
# above uses) rather than deriving CGO flags a second time.
#
# cgo_cflags/cgo_ldflags still contain the literal @CURRENT_SOURCE_DIR@/
# @BUILD_ROOT@ placeholder tokens appended above -- normally resolved by
# go_build's own fix_env/fix_input_envs sed machinery at build time. Since
# this target bypasses go_build entirely, resolve those tokens ourselves at
# Meson-configure time via Meson's own string .replace().
resolved_cgo_cflags = cgo_cflags.replace('@CURRENT_SOURCE_DIR@', meson.current_source_dir()).replace('@BUILD_ROOT@', meson.project_build_root())
resolved_cgo_ldflags = cgo_ldflags.replace('@CURRENT_SOURCE_DIR@', meson.current_source_dir()).replace('@BUILD_ROOT@', meson.project_build_root())
test('apiserver backend', go_compiler,
args: ['test', './backend/...', '-count=1'],
workdir: meson.current_source_dir(),
env: {'CGO_ENABLED': '1',
'CGO_CFLAGS': resolved_cgo_cflags,
'CGO_LDFLAGS': resolved_cgo_ldflags,
'GOFLAGS': '-mod=vendor',
'GOPROXY': 'off',
'GOCACHE': meson.current_build_dir() / 'go-cache',
'GOPATH': meson.current_build_dir() / 'go-path'},
suite: 'apiserver',
# A cold GOCACHE/GOPATH (the normal case: both are freshly created
# under this build dir, see above) makes `go test` compile the whole
# CGO+ASAN dependency graph from scratch -- measured ~34s, already over
# Meson's 30s test() default. Matches the timeout the existing
# 'controller test' registration uses for the same reason (see
# controller/meson.build / steering build-deployment.md).
timeout: 300,
depends: [libxce])