Skip to content

Commit 3d46eed

Browse files
committed
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 <[email protected]> Run-TryBot: Austin Clements <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 6a41be2 commit 3d46eed

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

src/cmd/dist/test.go

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -957,25 +957,17 @@ func (t *tester) registerTest(name, heading string, test *goTest, opts ...regist
957957
})
958958
}
959959

960-
// bgDirCmd constructs a Cmd intended to be run in the background as
961-
// part of the worklist. The worklist runner will buffer its output
962-
// and replay it sequentially. The command will be run in dir.
963-
func (t *tester) bgDirCmd(dir, bin string, args ...string) *exec.Cmd {
960+
// dirCmd constructs a Cmd intended to be run in the foreground.
961+
// The command will be run in dir, and Stdout and Stderr will go to os.Stdout
962+
// and os.Stderr.
963+
func (t *tester) dirCmd(dir string, cmdline ...interface{}) *exec.Cmd {
964+
bin, args := flattenCmdline(cmdline)
964965
cmd := exec.Command(bin, args...)
965966
if filepath.IsAbs(dir) {
966967
setDir(cmd, dir)
967968
} else {
968969
setDir(cmd, filepath.Join(goroot, dir))
969970
}
970-
return cmd
971-
}
972-
973-
// dirCmd constructs a Cmd intended to be run in the foreground.
974-
// The command will be run in dir, and Stdout and Stderr will go to os.Stdout
975-
// and os.Stderr.
976-
func (t *tester) dirCmd(dir string, cmdline ...interface{}) *exec.Cmd {
977-
bin, args := flattenCmdline(cmdline)
978-
cmd := t.bgDirCmd(dir, bin, args...)
979971
cmd.Stdout = os.Stdout
980972
cmd.Stderr = os.Stderr
981973
if vflag > 1 {
@@ -995,7 +987,7 @@ func flattenCmdline(cmdline []interface{}) (bin string, args []string) {
995987
case []string:
996988
list = append(list, x...)
997989
default:
998-
panic("invalid addCmd argument type: " + reflect.TypeOf(x).String())
990+
panic("invalid dirCmd argument type: " + reflect.TypeOf(x).String())
999991
}
1000992
}
1001993

@@ -1006,19 +998,6 @@ func flattenCmdline(cmdline []interface{}) (bin string, args []string) {
1006998
return bin, list[1:]
1007999
}
10081000

1009-
// addCmd adds a command to the worklist. Commands can be run in
1010-
// parallel, but their output will be buffered and replayed in the
1011-
// order they were added to worklist.
1012-
func (t *tester) addCmd(dt *distTest, dir string, cmdline ...interface{}) *exec.Cmd {
1013-
bin, args := flattenCmdline(cmdline)
1014-
w := &work{
1015-
dt: dt,
1016-
cmd: t.bgDirCmd(dir, bin, args...),
1017-
}
1018-
t.worklist = append(t.worklist, w)
1019-
return w.cmd
1020-
}
1021-
10221001
func (t *tester) iOS() bool {
10231002
return goos == "ios"
10241003
}

0 commit comments

Comments
 (0)