Skip to content

Commit aacf7a1

Browse files
committed
test: avoid touching GOOS/GOARCH in codegen driver
This change modifies the codegen test harness driver so that it no longer modifies the environment GOOS/GOARCH, since that seems to cause flakiness in other concurrently-running tests. The change also enables the codegen tests in run.go. Fixes #24538 Change-Id: I997ac1eb38eb92054efff67fe5c4d3cccc86412b Reviewed-on: https://go-review.googlesource.com/103455 Run-TryBot: Alberto Donizetti <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 014a904 commit aacf7a1

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

test/run.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var (
5252

5353
// dirs are the directories to look for *.go files in.
5454
// TODO(bradfitz): just use all directories?
55-
dirs = []string{".", "ken", "chan", "interface", "syntax", "dwarf", "fixedbugs"}
55+
dirs = []string{".", "ken", "chan", "interface", "syntax", "dwarf", "fixedbugs", "codegen"}
5656

5757
// ratec controls the max number of tests running at a time.
5858
ratec chan bool
@@ -612,18 +612,20 @@ func (t *test) run() {
612612
case "asmcheck":
613613
ops, archs := t.wantedAsmOpcodes(long)
614614
for _, arch := range archs {
615-
os.Setenv("GOOS", "linux")
616-
os.Setenv("GOARCH", arch)
617-
618-
cmdline := []string{goTool(), "build", "-gcflags", "-S"}
615+
cmdline := []string{"build", "-gcflags", "-S"}
619616
cmdline = append(cmdline, flags...)
620617
cmdline = append(cmdline, long)
621-
out, err := runcmd(cmdline...)
622-
if err != nil {
618+
cmd := exec.Command(goTool(), cmdline...)
619+
cmd.Env = append(os.Environ(), "GOOS=linux", "GOARCH="+arch)
620+
621+
var buf bytes.Buffer
622+
cmd.Stdout, cmd.Stderr = &buf, &buf
623+
if err := cmd.Run(); err != nil {
623624
t.err = err
624625
return
625626
}
626-
t.err = t.asmCheck(string(out), long, arch, ops[arch])
627+
628+
t.err = t.asmCheck(buf.String(), long, arch, ops[arch])
627629
if t.err != nil {
628630
return
629631
}

0 commit comments

Comments
 (0)