tstest/deptest: add DepChecker.ExtraEnv option for callers to set
For tests (in another repo) that use cgo, we'd like to set CGO_ENABLED=1 explicitly when evaluating cross-compiled deps with "go list". Updates tailscale/corp#26717 Updates tailscale/corp#26737 Change-Id: Ic21a54379ae91688d2456985068a47e73d04a645 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
f5997b3c57
commit
781c1e9624
@ -27,6 +27,7 @@ type DepChecker struct {
|
||||
BadDeps map[string]string // package => why
|
||||
WantDeps set.Set[string] // packages expected
|
||||
Tags string // comma-separated
|
||||
ExtraEnv []string // extra environment for "go list" (e.g. CGO_ENABLED=1)
|
||||
}
|
||||
|
||||
func (c DepChecker) Check(t *testing.T) {
|
||||
@ -43,6 +44,7 @@ func (c DepChecker) Check(t *testing.T) {
|
||||
if c.GOARCH != "" {
|
||||
extraEnv = append(extraEnv, "GOARCH="+c.GOARCH)
|
||||
}
|
||||
extraEnv = append(extraEnv, c.ExtraEnv...)
|
||||
cmd.Env = append(os.Environ(), extraEnv...)
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user