summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2023-05-12 15:04:21 -0400
committerAustin Clements <austin@google.com>2023-05-17 18:18:33 +0000
commit3d46eedbc97ddb25384307dea063021ba7b59c06 (patch)
tree51ab4a3848f566d7146c5ee4db14a55b2a61c41a
parent6a41be228e1f59dae6001e058fd1b27c79592777 (diff)
downloadgo-git-3d46eedbc97ddb25384307dea063021ba7b59c06.tar.gz
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 <dmitshur@golang.org> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
-rw-r--r--src/cmd/dist/test.go33
1 files 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"
}