[SERVER-6024] unittest assertions (ASSERT_*) should collect stack traces before throwing exceptions. Created: 07/Jun/12 Updated: 07/Mar/18 Resolved: 09/Jan/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Testing Infrastructure |
| Affects Version/s: | None |
| Fix Version/s: | 3.7.1 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Andy Schwerin | Assignee: | Kevin Albertson |
| Resolution: | Done | Votes: | 1 |
| Labels: | tig-unittests | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Minor Change | ||||||||
| Sprint: | TIG 2018-1-15, TIG 2018-1-1 | ||||||||
| Participants: | |||||||||
| Description |
|
When an ASSERT_* macro fails, it throws a special test exception. It should collect, but not immediately print, a stack trace record, to aid in debugging failed tests. |
| Comments |
| Comment by Githook User [ 08/Jan/18 ] | |||||||||||||||
|
Author: {'name': 'Kevin Albertson', 'username': 'kevinAlbs', 'email': 'kevin.albertson@10gen.com'}Message: | |||||||||||||||
| Comment by Kevin Albertson [ 26/Dec/17 ] | |||||||||||||||
|
That would be simpler, but Max pointed out that this would show stack traces even when we expect code to throw as in an ASSERT_THROWS. So I'll store the stack trace on the exception and and print it if the exception reaches up to unittest::Suite::run. Also, It'll likely be a much smaller change to store the stringified stack trace, so I'll do that first. | |||||||||||||||
| Comment by Andy Schwerin [ 24/Dec/17 ] | |||||||||||||||
|
Yeah, that would work pretty well. Mathias and Judah suggested a simpler On Thu, Dec 21, 2017, 2:42 PM Kevin Albertson (JIRA) <jira@mongodb.org> | |||||||||||||||
| Comment by Kevin Albertson [ 21/Dec/17 ] | |||||||||||||||
|
I think we can add the stack trace to TestAssertionFailureException and print out the stack trace in the unit test summary. E.g.
Judah mentioned it may be helpful to get the stack traces for other exceptions as well. From talking to Mathias it looks like we can add a stack trace field to Status::ErrorInfo. We can limit this to only getting populated in the context of unit tests since it could impact perf. With this, uasserts/masserts show stack traces the same way as a test assertion. schwerin does this sound like what you had in mind? |