Skip to content

Commit

Permalink
locally address rogpeppe#190 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly authored Mar 29, 2023
1 parent 38528bb commit b2b184e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions testdata/negate_exec.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[!exec:false] skip

!exec false
!stderr '.+'
!stdout '.+'
12 changes: 8 additions & 4 deletions testscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:]
}
}

Expand Down

0 comments on commit b2b184e

Please sign in to comment.