-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/testscript: add a -continue flag to not stop at the first error
This helps with writing and running bug reproducers using testscript. Since they are often meant to represent the desired behavior, and not the current behavior, they are designed to fail. However, some reproducers consist of multiple commands, and cmd/testscript would stop at the first command to error. When running a reproducer which is designed to fail, we want to run the entire script and see all failures. Add a `-continue` flag which does just that. With it, `T.FailNow` still marks the test as failed, but does not stop its execution via a panic. We also make two small changes to behave correctly when we reach the end of a script but `T.Failed` is true; we should "FAIL" rather than "PASS". The previous code only reached that point if no errors had happened. Note that we also altered `runT` to use pointer method receivers. It used atomics to modify and read its `failed` field, but without pointer receivers, `T.Failed` always returned false. It appears that bug had been present for a long time. Co-Authored-By: Paul Jolly <[email protected]>
- Loading branch information
Showing
3 changed files
with
56 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# should support -continue | ||
unquote file.txt | ||
|
||
# Running with continue, the testscript command itself | ||
# should fail, but we should see the results of executing | ||
# both commands. | ||
! testscript -continue file.txt | ||
stdout 'grep banana in' | ||
stdout 'no match for `banana` found in in' | ||
stdout 'grep apple in' | ||
|
||
-- file.txt -- | ||
>grep banana in | ||
>grep apple in | ||
>-- in -- | ||
>apple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters