From 3d46eedbc97ddb25384307dea063021ba7b59c06 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 12 May 2023 15:04:21 -0400 Subject: cmd/dist: simplify work list functions There are no uses of addCmd, so delete it. The only use of bgDirCmd is dirCmd, so inline it. Now the only function that interacts with the work queue is registerTest and dist's "background commands" are used exclusively in goTest.bgCommand and registerTest (which calls goTest.bgCommand). For #37486. Change-Id: Iebbb24cf9dbee45f3975fe9504d858493e1cd947 Reviewed-on: https://go-review.googlesource.com/c/go/+/494956 Reviewed-by: Dmitri Shuralyov Run-TryBot: Austin Clements TryBot-Result: Gopher Robot Reviewed-by: Dmitri Shuralyov --- src/cmd/dist/test.go | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 81a4973b19..c17b2935e9 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -957,25 +957,17 @@ func (t *tester) registerTest(name, heading string, test *goTest, opts ...regist }) } -// bgDirCmd constructs a Cmd intended to be run in the background as -// part of the worklist. The worklist runner will buffer its output -// and replay it sequentially. The command will be run in dir. -func (t *tester) bgDirCmd(dir, bin string, args ...string) *exec.Cmd { +// dirCmd constructs a Cmd intended to be run in the foreground. +// The command will be run in dir, and Stdout and Stderr will go to os.Stdout +// and os.Stderr. +func (t *tester) dirCmd(dir string, cmdline ...interface{}) *exec.Cmd { + bin, args := flattenCmdline(cmdline) cmd := exec.Command(bin, args...) if filepath.IsAbs(dir) { setDir(cmd, dir) } else { setDir(cmd, filepath.Join(goroot, dir)) } - return cmd -} - -// dirCmd constructs a Cmd intended to be run in the foreground. -// The command will be run in dir, and Stdout and Stderr will go to os.Stdout -// and os.Stderr. -func (t *tester) dirCmd(dir string, cmdline ...interface{}) *exec.Cmd { - bin, args := flattenCmdline(cmdline) - cmd := t.bgDirCmd(dir, bin, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if vflag > 1 { @@ -995,7 +987,7 @@ func flattenCmdline(cmdline []interface{}) (bin string, args []string) { case []string: list = append(list, x...) default: - panic("invalid addCmd argument type: " + reflect.TypeOf(x).String()) + panic("invalid dirCmd argument type: " + reflect.TypeOf(x).String()) } } @@ -1006,19 +998,6 @@ func flattenCmdline(cmdline []interface{}) (bin string, args []string) { return bin, list[1:] } -// addCmd adds a command to the worklist. Commands can be run in -// parallel, but their output will be buffered and replayed in the -// order they were added to worklist. -func (t *tester) addCmd(dt *distTest, dir string, cmdline ...interface{}) *exec.Cmd { - bin, args := flattenCmdline(cmdline) - w := &work{ - dt: dt, - cmd: t.bgDirCmd(dir, bin, args...), - } - t.worklist = append(t.worklist, w) - return w.cmd -} - func (t *tester) iOS() bool { return goos == "ios" } -- cgit v1.2.1