From 68da404bd7c8ac00630f322fa779fbf4b92f6deb Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Wed, 5 Aug 2026 10:00:17 -0400 Subject: [PATCH] fix(make): don't let ambient RACE leak into raceEnabled test (#5152) The two "RACE is unset" cases only skipped the t.Setenv call, so they inherited whatever RACE was in the environment. Running `make test` with RACE=false exported job-wide flipped the CI-default case and failed. Signed-off-by: Alex Goodman Signed-off-by: Alex Goodman --- .make/main_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.make/main_test.go b/.make/main_test.go index 8be12632d..50c6769d6 100644 --- a/.make/main_test.go +++ b/.make/main_test.go @@ -1,6 +1,7 @@ package main import ( + "os" "testing" "github.com/anchore/go-make/config" @@ -23,8 +24,11 @@ func TestRaceEnabled(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if tt.env != "" { - t.Setenv("RACE", tt.env) + // always go through t.Setenv (it registers the restore) so an ambient + // RACE from the caller's environment can't leak into the unset cases + t.Setenv("RACE", tt.env) + if tt.env == "" { + os.Unsetenv("RACE") } orig := config.CI config.CI = tt.ci