Skip to content

Commit 606d753

Browse files
committed
test: compare extracted prefix values in cross-rig assertion
Address Copilot review feedback: env line ordering is non-deterministic due to Go map iteration in exec.Store.run(), so comparing raw env output could produce false negatives. Extract and compare GC_BEADS_PREFIX values directly instead.
1 parent d0da2f3 commit 606d753

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

cmd/gc/api_state_test.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,26 @@ func TestBuildStores_ExecProviderSetsPerRigEnv(t *testing.T) {
269269
// Cross-rig assertion: the two rigs must have received different prefixes.
270270
// This is the exact regression from #391 — before PR #421, both stores
271271
// got identical env, so the last rig's prefix silently won.
272-
alphaEnv, _ := os.ReadFile(filepath.Join(envDir, "alpha.env"))
273-
bravoEnv, _ := os.ReadFile(filepath.Join(envDir, "bravo.env"))
274-
if string(alphaEnv) == string(bravoEnv) {
275-
t.Errorf("regression: alpha and bravo exec stores received identical env — "+
276-
"store identity is not being propagated per rig:\n%s", string(alphaEnv))
272+
// Compare extracted GC_BEADS_PREFIX values (not raw env output, whose
273+
// line order is non-deterministic due to Go map iteration in exec.Store).
274+
extractPrefix := func(envFile string) string {
275+
data, err := os.ReadFile(envFile)
276+
if err != nil {
277+
return ""
278+
}
279+
for _, line := range strings.Split(string(data), "\n") {
280+
if strings.HasPrefix(line, "GC_BEADS_PREFIX=") {
281+
return strings.TrimPrefix(line, "GC_BEADS_PREFIX=")
282+
}
283+
}
284+
return ""
285+
}
286+
alphaPrefix := extractPrefix(filepath.Join(envDir, "alpha.env"))
287+
bravoPrefix := extractPrefix(filepath.Join(envDir, "bravo.env"))
288+
if alphaPrefix == bravoPrefix {
289+
t.Errorf("regression: alpha and bravo exec stores received the same "+
290+
"GC_BEADS_PREFIX=%q — store identity is not being propagated per rig",
291+
alphaPrefix)
277292
}
278293
}
279294

0 commit comments

Comments
 (0)