-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testscript: add Params.ContinueOnError (#192)
This fixes a few issues around the existing `testscript -continue` flag. Notably: - causing `T.Fatal` and `T.FailNow` to return normally meant that some logic inside the testscript package that was expecting the old behaviour would fail to work correctly (for example, a non-existent command would cause a panic) - the logging logic was erroneously assuming that if we got to the end of a script, all sections had passed therefore we could omit the logged messages. We fix the above by making "continue on error" a first class part of `testscript.Params`, so the testscript logic actually knows about it. To test it properly, we need a couple of hacks to make the output predictable. Unfortunately, those hacks are internal only, so it's hard to add similar tests to the `cmd/testscript` command to end-to-end test that, but the existing test should act as sufficient "smoke test" that the continue logic is wired up OK.
- Loading branch information
Showing
4 changed files
with
231 additions
and
80 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,108 @@ | ||
# non-verbose, non-continue | ||
! testscript scripts | ||
cmpenv stdout expect-stdout.txt | ||
|
||
# verbose | ||
! testscript -v scripts | ||
cmpenv stdout expect-stdout-v.txt | ||
|
||
# continue | ||
! testscript -continue scripts | ||
cmpenv stdout expect-stdout-c.txt | ||
|
||
# verbose, continue | ||
! testscript -v -continue scripts | ||
cmpenv stdout expect-stdout-vc.txt | ||
|
||
-- scripts/testscript.txt -- | ||
# comment 1 | ||
printargs section1 | ||
|
||
# comment 2 | ||
printargs section2 | ||
|
||
# comment 3 | ||
printargs section3 | ||
status 1 | ||
|
||
# comment 4 | ||
printargs section3 | ||
|
||
# comment 5 | ||
printargs section5 | ||
status 1 | ||
|
||
-- expect-stdout.txt -- | ||
# comment 1 (0.000s) | ||
# comment 2 (0.000s) | ||
# comment 3 (0.000s) | ||
> printargs section3 | ||
[stdout] | ||
["printargs" "section3"] | ||
> status 1 | ||
[exit status 1] | ||
FAIL: $$WORK${/}scripts${/}testscript.txt:9: unexpected command failure | ||
-- expect-stdout-v.txt -- | ||
# comment 1 (0.000s) | ||
> printargs section1 | ||
[stdout] | ||
["printargs" "section1"] | ||
# comment 2 (0.000s) | ||
> printargs section2 | ||
[stdout] | ||
["printargs" "section2"] | ||
# comment 3 (0.000s) | ||
> printargs section3 | ||
[stdout] | ||
["printargs" "section3"] | ||
> status 1 | ||
[exit status 1] | ||
FAIL: $$WORK${/}scripts${/}testscript.txt:9: unexpected command failure | ||
-- expect-stdout-c.txt -- | ||
# comment 1 (0.000s) | ||
# comment 2 (0.000s) | ||
# comment 3 (0.000s) | ||
> printargs section3 | ||
[stdout] | ||
["printargs" "section3"] | ||
> status 1 | ||
[exit status 1] | ||
FAIL: $$WORK${/}scripts${/}testscript.txt:9: unexpected command failure | ||
# comment 4 (0.000s) | ||
> printargs section3 | ||
[stdout] | ||
["printargs" "section3"] | ||
# comment 5 (0.000s) | ||
> printargs section5 | ||
[stdout] | ||
["printargs" "section5"] | ||
> status 1 | ||
[exit status 1] | ||
FAIL: $$WORK${/}scripts${/}testscript.txt:16: unexpected command failure | ||
-- expect-stdout-vc.txt -- | ||
# comment 1 (0.000s) | ||
> printargs section1 | ||
[stdout] | ||
["printargs" "section1"] | ||
# comment 2 (0.000s) | ||
> printargs section2 | ||
[stdout] | ||
["printargs" "section2"] | ||
# comment 3 (0.000s) | ||
> printargs section3 | ||
[stdout] | ||
["printargs" "section3"] | ||
> status 1 | ||
[exit status 1] | ||
FAIL: $$WORK${/}scripts${/}testscript.txt:9: unexpected command failure | ||
# comment 4 (0.000s) | ||
> printargs section3 | ||
[stdout] | ||
["printargs" "section3"] | ||
# comment 5 (0.000s) | ||
> printargs section5 | ||
[stdout] | ||
["printargs" "section5"] | ||
> status 1 | ||
[exit status 1] | ||
FAIL: $$WORK${/}scripts${/}testscript.txt:16: unexpected command failure |
Oops, something went wrong.