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

CBG-4455 do not panic when calling FailNow #7308

Merged
merged 4 commits into from
Jan 23, 2025
Merged

CBG-4455 do not panic when calling FailNow #7308

merged 4 commits into from
Jan 23, 2025

Conversation

torcolvin
Copy link
Collaborator

CBG-4455 do not panic when calling FailNow

Confusingly, require.FailNow's signature is FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}). There are a few consequences to this, one of which is that expecting failureMessage to be formatted will not happen. The second problem is if the first argument in msgAndArgs is not a format string, then the test harness can panic.

  • Created a ruleguard rule to find the misuse of this. This prevents use of % followed by an letter but most "real" uses of % are followed by a space, number, or punctuation. Forcing passing to fmt.Sprintf will cause the compiler to error if the wrong argument types are passed. Updated ruleguard rules in linter to account for new checks, and changed the string to only pick up rules-*.go files so the test files in that directory aren't picked up.
  • Fixed existing misuse.

Integration Tests

bbrks
bbrks previously approved these changes Jan 21, 2025
Copy link

Redocly previews

@torcolvin torcolvin requested a review from bbrks January 21, 2025 21:41
@torcolvin torcolvin force-pushed the CBG-4455 branch 2 times, most recently from 52e939f to a7350fe Compare January 22, 2025 16:26
@bbrks bbrks merged commit 72e0568 into main Jan 23, 2025
40 checks passed
@bbrks bbrks deleted the CBG-4455 branch January 23, 2025 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants