Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/testscript: add a -continue flag to not stop at the first error #189

Merged
merged 1 commit into from
Nov 23, 2022

Commits on Nov 23, 2022

  1. 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 <paul@myitcv.io>
    mvdan and myitcv committed Nov 23, 2022
    Configuration menu
    Copy the full SHA
    5cef7b9 View commit details
    Browse the repository at this point in the history