mirror of
https://github.com/anchore/syft.git
synced 2026-08-19 16:48:27 +02:00
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 <alex.goodman@anchore.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
parent
35bf33bcf0
commit
68da404bd7
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/anchore/go-make/config"
|
"github.com/anchore/go-make/config"
|
||||||
@ -23,8 +24,11 @@ func TestRaceEnabled(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
if tt.env != "" {
|
// always go through t.Setenv (it registers the restore) so an ambient
|
||||||
t.Setenv("RACE", tt.env)
|
// 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
|
orig := config.CI
|
||||||
config.CI = tt.ci
|
config.CI = tt.ci
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user