-
Notifications
You must be signed in to change notification settings - Fork 1.7k
suite: fix panic if a WithStats suite skips a test early #1723
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
base: master
Are you sure you want to change the base?
suite: fix panic if a WithStats suite skips a test early #1723
Conversation
…eTest. This fixes issue stretchr#1722.
While it works, I would have done differently to focus the change on the small portion of code that causes the issues. Here is the code that fails func (s SuiteInformation) end(testName string, passed bool) {
s.TestStats[testName].End = time.Now()
s.TestStats[testName].Passed = passed
} Your PR is about avoiding to call I would like to suggest limiting the change in your PR to this func (s SuiteInformation) end(testName string, passed bool) {
if _, started := s.TestStats[testName]; !started {
return
}
s.TestStats[testName].End = time.Now()
s.TestStats[testName].Passed = passed
} The test you added is good. |
@ccoVeille I myself think it’s better, if It’s not something I feel strongly about, though, so I’ll make the change you requested. |
@ccoVeille Altered accordingly, with a small tweak to reduce repetition. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ccoVeille I myself think it’s better, if
start()
was never called, to avoid callingend()
; thus, I’d rather the fix be as I have it.
I understand your point, thanks for considering my fix.
Good idea with that tweak
@FGasper Could you rebase your branch and resolve the conflict? |
Summary
This fixes issue #1722.
Changes
Prevent stats.end() if stats.start() never ran.
Motivation
Allow skipping a test in a setup/before hook. See issue #1722 for an example.
Related issues
Closes #1722