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

testutil: Export ParseTestCaseFile #336

Closed
wants to merge 4 commits into from
Closed

testutil: Export ParseTestCaseFile #336

wants to merge 4 commits into from

Commits on Nov 11, 2022

  1. testutil: Add ParseTestCaseFile

    This moves the logic for parsing a test case file
    into a separate function named ParseTestCaseFile.
    This will make it easier for extensions
    to use the same format for test files,
    even if they want a different strategy to run them.
    
    The function does not do filtering like DoTestCaseFile;
    that logic has been left inside DoTestCaseFile.
    
    Minus that, this function does not modify any logic.
    The next commits do.
    abhinav committed Nov 11, 2022
    Configuration menu
    Copy the full SHA
    eb17108 View commit details
    Browse the repository at this point in the history
  2. ParseTestCaseFile: Don't panic

    Instead of panicking, ParseTestCaseFile now reports errors.
    The errors take the form,
    
        line $line: $msg: $cause
    
    For example,
    
        line 12: invalid case No: parse error
    
    As a result of this change,
    we no longer discard the error returned by strconv.Atoi or json.Marshal
    when we reject the test file,
    and include it in the error message instead.
    
    Note that the errors do not include the file name
    because the file name is always the same
    so the caller can add that if necessary
    (which it will, in the next commit).
    abhinav committed Nov 11, 2022
    Configuration menu
    Copy the full SHA
    282e142 View commit details
    Browse the repository at this point in the history
  3. DoTestCaseFile: Don't panic

    Instead of panicking, report the error in the form,
    
        $file: $msg
    
    So an error might look like,
    
        foo.txt: line 12: invalid case No: [..]
    
    And then kill the test with FailNow.
    This is the same as calling `t.Fatalf(...)`.
    abhinav committed Nov 11, 2022
    Configuration menu
    Copy the full SHA
    86794e9 View commit details
    Browse the repository at this point in the history
  4. Add io.Reader variant

    Move core logic to ParseTestCases,
    which operates on an io.Reader,
    but keep the file-based function around for convenience.
    abhinav committed Nov 11, 2022
    Configuration menu
    Copy the full SHA
    8fe644f View commit details
    Browse the repository at this point in the history