diff --git a/testdata/negate_exec.txt b/testdata/negate_exec.txt new file mode 100644 index 00000000..12c8c448 --- /dev/null +++ b/testdata/negate_exec.txt @@ -0,0 +1,5 @@ +[!exec:false] skip + +!exec false +!stderr '.+' +!stdout '.+' diff --git a/testscript.go b/testscript.go index d68a19b6..e47cb3ba 100644 --- a/testscript.go +++ b/testscript.go @@ -643,11 +643,15 @@ func (ts *TestScript) runLine(line string) (runOK bool) { // Command prefix ! means negate the expectations about this command: // go command should fail, match should not be found, etc. neg := false - if args[0] == "!" { + if strings.HasPrefix(args[0], "!") { neg = true - args = args[1:] - if len(args) == 0 { - ts.Fatalf("! on line by itself") + if len(args[0]) == 1 { + args = args[1:] + if len(args) == 0 { + ts.Fatalf("! on line by itself") + } + } else { + args[0] = args[0][1:] } }