mirror of
https://github.com/burrowers/garble.git
synced 2026-04-22 23:57:14 +08:00
all: use cmd.Environ rather than os.Environ
Added in Go 1.19, this keeps os/exec's default environment logic, such as ensuring that $PWD is always set.
This commit is contained in:
+5
-5
@@ -79,12 +79,12 @@ func BenchmarkBuild(b *testing.B) {
|
||||
garbleCache := filepath.Join(tdir, "garble-cache")
|
||||
qt.Assert(b, qt.IsNil(os.RemoveAll(garbleCache)))
|
||||
qt.Assert(b, qt.IsNil(os.Mkdir(garbleCache, 0o777)))
|
||||
env := append(os.Environ(),
|
||||
env := []string{
|
||||
"RUN_GARBLE_MAIN=true",
|
||||
"GOCACHE="+goCache,
|
||||
"GARBLE_CACHE="+garbleCache,
|
||||
"GOCACHE=" + goCache,
|
||||
"GARBLE_CACHE=" + garbleCache,
|
||||
"GARBLE_WRITE_ALLOCS=true",
|
||||
)
|
||||
}
|
||||
args := []string{"build", "-v", "-o=" + outputBin, sourceDir}
|
||||
|
||||
for _, cached := range []bool{false, true} {
|
||||
@@ -95,7 +95,7 @@ func BenchmarkBuild(b *testing.B) {
|
||||
}
|
||||
|
||||
cmd := exec.Command(os.Args[0], args...)
|
||||
cmd.Env = env
|
||||
cmd.Env = append(cmd.Environ(), env...)
|
||||
cmd.Dir = sourceDir
|
||||
|
||||
cachedStart := time.Now()
|
||||
|
||||
@@ -196,7 +196,7 @@ func buildLinker(workingDir string, overlay map[string]string, outputLinkPath st
|
||||
// go version -m ~/tip/pkg/tool/linux_amd64/link
|
||||
//
|
||||
// and which can be done from Go via debug/buildinfo.ReadFile.
|
||||
cmd.Env = append(os.Environ(),
|
||||
cmd.Env = append(cmd.Environ(),
|
||||
"GOENV=off", "GOOS=", "GOARCH=", "GOEXPERIMENT=", "GOFLAGS=",
|
||||
)
|
||||
// Building cmd/link is possible from anywhere, but to avoid any possible side effects build in a temp directory
|
||||
|
||||
@@ -142,7 +142,7 @@ func main() {
|
||||
garbleBin := buildTestGarble(tdir)
|
||||
args := append([]string{"-seed", garbleSeed, "-literals", "test", "-bench"}, os.Args[1:]...)
|
||||
cmd := exec.Command(garbleBin, args...)
|
||||
cmd.Env = append(os.Environ(),
|
||||
cmd.Env = append(cmd.Environ(),
|
||||
// Explicitly specify package for obfuscation to avoid affecting testing package.
|
||||
"GOGARBLE="+moduleName,
|
||||
"GARBLE_TEST_LITERALS_OBFUSCATOR_MAP="+strings.Join(packageToObfuscatorIndex, ","),
|
||||
|
||||
Reference in New Issue
Block a user