atlaste / CPPCoverage

Visual Studio Extension for measuring C++ Code Coverage and profiling data
78 stars 19 forks source link

GMock #10

Closed joset15 closed 7 years ago

joset15 commented 7 years ago

Hello,

Thanks for share your great tool.

I have been using for a while with Visual Studio 2015 Professional without problem.

Recently I have added GMock (downloaded from trunk) to a small test project.

I can select "Run code coverage" without any problem if GMock is not used. But if I use, for example EXPECT_CALL and select "Run code coverage", I get some output messages until Visual Studio crash.

Have you tested with GMock?

Thanks and best regards, Jose.

atlaste commented 7 years ago

No we haven't tested that. Our classes are usually designed in such a way they can be easily tested without mocking. Can you supply me with a minimum test case? I'd be happy to figure out what's the problem.

joset15 commented 7 years ago

Hi, thanks for your fast reply.

Do you need full project or only test sample?

Regards.

atlaste commented 7 years ago

A full project that I don't have to tinker with is the easiest for me, and will probably be the fastest road towards a working solution. :-)

joset15 commented 7 years ago

Hi, tell me if you have any problem.

You will need to download GMock and set your include directories. Another little problem I have is that #pragma DisableCodeCoverage is not recognized.

Regards.

MFCDlg2015.zip

atlaste commented 7 years ago

Thanks; got it, I'll take a look when I have some spare time.

As for the pragma's; they give a warning because they're not recognized by the VS compiler. I assume that's what you mean? By std, pragma's that aren't recognized should be ignored.

Fortunately there's a way to fix that. In project settings -> C++, set the compiler to ignore the warning, from the top of my mind it's number 4860.

atlaste commented 7 years ago

@joset15 I finally found the time to figure out what's going on here. Apparently gmock uses child processes, which spawn for each test.

As soon as the coverage runner received an 'exit process' notification, it exited. It's not a crash, but sure looks like it... You can easily reproduce it by building gmock and running:

Coverage-x86.exe -o "C:\CodeCoverage_test.cov" -p "C:\Path_to_gmock\googlemock\msvc\2015\Debug" -- "C:\Path_to_gmock\googlemock\msvc\2015\Debug\gmock_test.exe"

(Obviously you need the x64 version if you build for that)

The patch that I just uploaded will keep the coverage runner alive as long as there are child processes that are alive, thereby fixing the bug. So, just install the latest and greatest and that should do the trick.

joset15 commented 7 years ago

@atlaste Thank you very much for your help.

I have downloaded from here: https://github.com/atlaste/CPPCoverage/blob/master/CoverageExt/CoverageExt.vsix

I have noted that size is 338 Kb, my previous downloaded version was 613 Kb.

I have tested it, but Visual Studio continue crashing when I select "Run code coverage". Maybe, I have some problem with my configuration. I will test again when I have more time.

Best regards.

atlaste commented 7 years ago

I've reopened the issue. Hmm, that means it's probably a detail like an extension that conflicts with another extension f.ex.

The easiest way to figure that out is to download the source, start the Visual Studio extension in Visual Studio (Set as startup project, press F5). No external dependencies of difficult builds; it works as-is. That will start an experimental instance of VS2015 in a new window. Open solution, run coverage, wait till crash -> you should now have a stacktrace that will tell where things go wrong.

Let me know if that works out... and do post the stacktrace here if you get one (and it originates from the coverage source.. otherwise you should disable the other extension probably...).

joset15 commented 7 years ago

@atlaste Thank you for your suggestion. I will try when I have some free time and I will feedback you. Best regards.

atlaste commented 7 years ago

@joset15 I was wondering, have you made any progress?

joset15 commented 7 years ago

Sorry for the delay. I have followed your instructions, but I think I need to install SDK. error build cppcoverage.txt

atlaste commented 7 years ago

Ah yes, that's the Visual Studio SDK. It's included in the VS installation. See: https://msdn.microsoft.com/en-us/library/mt683786.aspx .

joset15 commented 7 years ago

OK, Thanks, but I can not install it at this moment. I will feedback you.

joset15 commented 7 years ago

Hi, I had some problems with Visual Studio installation. I can not compile cppcoverage. Sorry, I can not invert more time at this moment. I have tested FakeIt mock library and it is working fine. Maybe I can try gmock again in the future.

Thank you very much for your support. Regards.