Does this work with managed C++? Is it able to either report on managed C++ coverage or ignore it?
I have tried it on a few native applications and it works great. However, I also have a native Windows app “TestRunner” that runs a series of C++ unit tests. Some of the tests call into managed C++ code.
The TestRunner app runs fine when executed without OpenCppCoverage.
First attempt at using OpenCppCoverage
But when I run under OpenCppCoverage and hit the test that will call into managed code, an exception is thrown that is caught by the TestRunner app itself. If I run the tests a second time without quitting the Windows TestRunner app, same thing happens.
OpenCppCoverage finishes and generates a valid coverage report. The report displays the executable lines in the managed C++ source files correctly, but they are all red, indicating that they were apparently not executed. The LastCoverageResults.log file doesn’t show any problems.
The "--continue_after_cpp_exception" flag has no apparent effect on this behavior.
Another attempt
If I put in “--excluded_modules” for the managed DLL, when I hit the test that will call into managed code, the target application exits, and apparently OpenCppCoverage.exe quits as well, since it doesn’t generate any coverage report. The last line output by OpenCppCoverage is:
Error: FileDebugInformation.cpp:78 Error when calling SymFromAddr
In Visual Studio debugger
If I run the application under the Visual Studio debugger (not using OpenCppCoverage at all), with all Exception catching turned on, the debugger stops at a number of exceptions, and I need to press "Continue". But still the code succeeds; none of the exceptions are uncaught, presumably because they were caught and handled within .NET, and are expected errors. (The initial error is a Microsoft C++ exception EEFileLoadException, followed by a few other Microsoft C++ exceptions and .NET exceptions.) If I run the tests a second time without quitting the Windows TestRunner app, there are no exceptions caught at all.
Analysis
So it seems like OpenCppCoverage is attached to the code like a debugger, but rather than ignoring .NET exceptions and letting .NET itself handle them, it is allowing them to propagate as uncaught exceptions out of the managed code back to the native code.
Question: is this kind of scenario supposed to work?
Thanks!