Skip to content

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
@github-actions
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.

3 participants