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:
parent
5f40c3fb32
commit
6c3ff2012b
2 changed files with 35 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
|||
# Implementation Plan
|
||||
|
||||
- [ ] 1. Core: CGO-backed backend test coverage via Meson
|
||||
- [ ] 1.1 (P) Add a Meson test target for the apiserver CGO-backed backend suite, reusing the existing CGO flag derivation
|
||||
- [x] 1.1 (P) Add a Meson test target for the apiserver CGO-backed backend suite, reusing the existing CGO flag derivation
|
||||
- Resolve the `@CURRENT_SOURCE_DIR@`/`@BUILD_ROOT@` placeholder tokens already present in `apiserver_cgo_deps`'s computed CGO flags at Meson-configure time (they are otherwise only resolved by `tools/go_build`'s own runtime sed machinery, which this new target does not go through)
|
||||
- Register the target with Meson's test runner (`suite: 'apiserver'`), scoped to the apiserver source directory, depending on `libxce` having already been built
|
||||
- Set the same offline/hermetic Go environment `tools/go_build` already uses (`GOFLAGS=-mod=vendor`, `GOPROXY=off`) plus an explicit, build-dir-scoped `GOCACHE`/`GOPATH` (this target invokes the Go toolchain directly, not through `go_build`, so it inherits none of `go_build`'s own internal exports)
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue