Open bartlibert opened 5 years ago
I could reproduce this bug as described using g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0.
Catch2 handles reporting to console and junit in different ways. The console reporter seems to print many assertion details as soon as the assertion happens. For junit it first saves all assertion results as objects and then creates the reports later when Catch::TestFailureException() is thrown (thus, an abort reason is detected).
I think this is a problem related to the lifetime of stack allocated string objects (somewhere in CatchAdapter) which remain referenced by Catch::StringRef. Thus, if you supply a literal to the Catch::AssertionHandler constructor, the StringRef constructor references the literal in the const section, which remains valid indefinitely contrary to the argument of fail(), which is gone after the call. However, I could not pinpoint the actual root cause. Maybe someone with a better architectural understanding of Catch2?
When using the junit reporter of catch, the failure message and failure type contain random noise, instead of the expected type (Verify, VerifyNoOtherInvocations,...) and failure message. I suspect it's related to some memory issues, but I could not pinpoint it myself. What I did notice was that if I replace "vetificationType" with a hardcoded string here, the failure type is correct. Note: for "normal" catch checks, this does fail.
Minimal code for reproduction:
Compile and then run with parameter
-r junit
. Result (failure message and type are different each run):Expected result (notice the failure message and type)
Fakeit version: 2.0.5 Catch version: 2.1.0 (but also seen with later versions)