Skip to content

Commit bb36173

Browse files
committed
testscript: fix RequireExplicitExec error messages
They used args[0], which is the first argument to the command, rather than the command name itself: > gofumpt foo.go FAIL: [...] use 'exec foo.go' rather than 'foo.go' (because RequireExplicitExec is enabled) I believe I introduced this regression when refactoring the pull request due to Roger's review, as I moved the code out of TestMain, where args[0] was still the name of the command to be run. Note that I can't easily add a regression test here, because the testscript command being used in the tests is not a top-level command run as a separate process, so it does not produce stdout nor stderr. The change seems easy enough to review manually, and our tests don't strictly check all error messages anyway. While here, remove the unnecessary use of -verbose.
1 parent 2431384 commit bb36173

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

testscript/exe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func RunMain(m TestingM, commands map[string]func() int) (exitCode int) {
122122
}
123123
scriptCmds[name] = func(ts *TestScript, neg bool, args []string) {
124124
if ts.params.RequireExplicitExec {
125-
ts.Fatalf("use 'exec %s' rather than '%s' (because RequireExplicitExec is enabled)", args[0], args[0])
125+
ts.Fatalf("use 'exec %s' rather than '%s' (because RequireExplicitExec is enabled)", name, name)
126126
}
127127
ts.cmdExec(neg, append([]string{name}, args...))
128128
}

testscript/testdata/testscript_explicit_exec.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ unquote scripts-explicit/testscript.txt
99
testscript scripts-implicit
1010
testscript scripts-explicit
1111

12-
! testscript -verbose -explicit-exec scripts-implicit
13-
testscript -verbose -explicit-exec scripts-explicit
12+
! testscript -explicit-exec scripts-implicit
13+
testscript -explicit-exec scripts-explicit
1414

1515
-- scripts-implicit/testscript.txt --
1616
>fprintargs stdout right

0 commit comments

Comments
 (0)