Repository navigation
fix(test): seed TestGuardOwedAbsoluteMeasuredCommand with CheckContext (#3008) - #3017
Conversation
Fixes Agent-Field#3008 TestGuardOwedAbsoluteMeasuredCommand hardcoded Context: make([]string, 8) on the inherited synthetic check while executing the portable rerun through the live bash check observer, which records the runner's checkContextNames (GOOS, GOARCH, GOFLAGS, CGO_ENABLED, GOWORK, GORACE, NODE_ENV, PYTEST_ADDOPTS). When any of those variables was set in the environment, the context mismatch kept the saved absolute failure owed even after a matching portable rerun. Export verification.CheckContext() (also reused by CoversUnrun), use it to seed the inherited check, and add TestGuardOwedAbsoluteMeasuredCommandContext to verify both matching non-empty context clearing and cross-context holding.
|
Hey, thanks for the PR. Could you sign the CLA when you get a chance so we can review it? |
|
I have signed the CLA.
|
AbirAbbas
left a comment
There was a problem hiding this comment.
Thanks for this, nice catch. I ran it against the base commit: with GOFLAGS (or GOOS/GOWORK) exported the old test fails exactly as in #3008, and with your change the TestGuard tests pass with GOFLAGS set, GOOS=linux, GOWORK=off, CGO_ENABLED=0 and a clean environment (several runs each). The assertion that a portable rerun clears the saved failure is untouched; only the seeded context now matches the run it is compared against, and the new test pins the other side (a different GOOS keeps the failure owed), so this tightens the check rather than loosening it. CLA is signed. Looks good to me from this side, I'll leave the merge to the maintainers.
AbirAbbas
left a comment
There was a problem hiding this comment.
Thanks, this is the right fix. The test now takes its context from the same helper the product uses, so an exported GOFLAGS on the host no longer trips it, and nothing about what it checks got weaker. Re-ran it here with GOFLAGS set and it passes.
Fixes #3008
What changed
TestGuardOwedAbsoluteMeasuredCommandpreviously seeded the inherited synthetic check (old) withContext: make([]string, 8)(all empty strings), while running the subsequentgo test ./...through the live bash observer (_codeaf_check), which populatesnext.ContextfromcheckContextNames(GOOS,GOARCH,GOFLAGS,CGO_ENABLED,GOWORK,GORACE,NODE_ENV,PYTEST_ADDOPTS). Whenever any of those variables was exported in the runner environment,next.identity != old.identitykept the saved absolute failure owed even after a matching portable rerun.verification.CheckContext()ininternal/factory/verification/receipts.go(and reused it inCoversUnrunininternal/factory/verification/go_requirements.goto avoid duplicating thecheckContextNamesloop), and seededold.ContextinTestGuardOwedAbsoluteMeasuredCommandwithverification.CheckContext().TestGuardOwedAbsoluteMeasuredCommandContextincmd/codeaf/factory_guard_stale_test.goto pin both sides of the contract witht.Setenv: a rerun under a differentGOOSkeeps the saved failure owed, while a portable rerun under the matching non-emptyGOOS+GOWORKcontext clears it.How it was checked
dev(a5499811) withGOOS=linuxandGOWORK=off:GOOS=linux go test -v -count=1 -run '^TestGuardOwedAbsoluteMeasuredCommand$' ./cmd/codeaf-> FAIL atfactory_guard_stale_test.go:270: portable rerun did not clear saved absolute failure: repair is incomplete; owed: 'go' 'test' './...' ...GOWORK=off go test -v -count=1 -run '^TestGuardOwedAbsoluteMeasuredCommand$' ./cmd/codeaf-> FAIL atfactory_guard_stale_test.go:270go test -v -count=1 -run '^TestGuard' ./cmd/codeaf-> PASS (1.144s, all 10TestGuard*tests)GOOS=linux go test -v -count=1 -run '^TestGuardOwedAbsoluteMeasuredCommand' ./cmd/codeaf-> PASS (0.252s)GOWORK=off go test -v -count=1 -run '^TestGuardOwedAbsoluteMeasuredCommand' ./cmd/codeaf-> PASS (0.191s)CGO_ENABLED=0 GOFLAGS=-v go test -v -count=1 -run '^TestGuardOwedAbsoluteMeasuredCommand' ./cmd/codeaf-> PASS (0.195s)go test -race -count=1 ./internal/factory/verification-> PASS (4.930s)go test -count=1 ./internal/namelaw ./cmd/codeaf-changes ./internal/factory/verification-> PASSgo vet ./internal/factory/verification ./cmd/codeaf-> clean (exit 0)gofmt -landgit diff --check-> clean-raceoncmd/codeafdue to container link time; addeddocs/changes/unreleased/3017-guard-owed-absolute-context.mdand validated viamake changelog-check.Checklist
git add -A.docs/changes/unreleased/3017-guard-owed-absolute-context.mdadded and validated withmake changelog-check.internal/manual/chat/unaffected).