luzhao / coverstory

Automatically exported from code.google.com/p/coverstory
Apache License 2.0
0 stars 0 forks source link

Coverstory reports 0% of coverage all the time. #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
To reproduce, just setup a standard GCov build config in Xcode and open the 
output files in CoverStory. The coverage is always 0%. 

As explained here : 

http://stackoverflow.com/questions/1385568/why-doesnt-gcov-report-any-lines-bein
g-covered-by-my-unit-tests 

it may be related to the version of gcc, since gcc4.0 instead of 4.2 produce a 
sensible output. The problem, is that when developing with iOS 4.2, UIKit uses 
blocks (among other things), and gcc4.0 doesn't work with them. Hence gcc4.2 is 
required. 

It is a re-opening of #issue28 since it has been set as invalid because of its 
bad description.

Original issue reported on code.google.com by cedric.f...@gmail.com on 31 Dec 2010 at 11:03

GoogleCodeExporter commented 9 years ago
Update: I found an explanation why it is always 0%. It was just in front of my 
eyes, as Coverstory was yelling me at: there are no .gcda files produced. I 
have only .gcno files. I have no clue why, my GCC setup is correct: 
-fprofile-arcs is setup, or in Xcode words: GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = 
YES

Original comment by cedric.f...@gmail.com on 31 Dec 2010 at 1:47

GoogleCodeExporter commented 9 years ago
So my guess is the 4.x Simulator adds the sandbox for the gcda files aren't 
getting written back.  We'll try to confirm things, but it may mean coverage on 
the simulator is dead until something else can be figured out.

Original comment by thoma...@gmail.com on 31 Dec 2010 at 5:17

GoogleCodeExporter commented 9 years ago
Is -ftest-coverage setup and are you linking to the gcov library? I'm getting 
gcda files here running in the simulator.

Original comment by dmaclach on 3 Jan 2011 at 9:06

GoogleCodeExporter commented 9 years ago
It's working fine here with a couple of fun things to be aware of (this is with 
XCode 3.2.5 building against the iOS 4.2 SDK running in Simulator with gcc 4.2)

a) It appears they have fixed the gcov linking issues documented here: 
http://code.google.com/p/google-toolbox-for-mac/wiki/SnowLeopardGCov although 
the prefix header issues still appear to exist
b) You need to make sure that your app quits properly for gcda files to be 
written out.

So, be sure to turn off prefix header generation. Then either:
a) Always quit the simulator by going to the simulator and choosing "quit" from 
the menu as opposed to hitting stop in xcode.
b) or add
  <key>UIApplicationExitsOnSuspend</key>
  <true/>
   to your plist.

Please let me know if this helps. If I don't hear back from you in a couple of 
days, I'm going to close this issue as "WontFix". I will update the gcov wiki 
information.

Original comment by dmaclach on 3 Jan 2011 at 9:23

GoogleCodeExporter commented 9 years ago
Thanks very much for all these informations. Once back to work tomorrow, I'll 
check and confirm you that it's also working for me. 

Original comment by cedric.f...@gmail.com on 3 Jan 2011 at 9:35

GoogleCodeExporter commented 9 years ago
Wiki updated with new info here:

http://code.google.com/p/google-toolbox-for-mac/wiki/iOSGCov

Original comment by dmaclach on 3 Jan 2011 at 9:57

GoogleCodeExporter commented 9 years ago
I must be wrong somewhere. I now have .gcda files as well as .gcno ones. And 
Coverstory gives me non-zero % coverage. But the coverage I see is for test 
classes! I obviously expect about 100% of my tests classes to be covered. Note 
that I also made sure that my GCC_PREFIX_HEADER entry is blank. I also tested 
with the libgcov.a file provided in GTM trunk, but without more success. Sorry, 
this might not be related to Coverstory itself.

Original comment by cedric.f...@gmail.com on 4 Jan 2011 at 8:33

GoogleCodeExporter commented 9 years ago
OK, the explanation is simple (a line in the documentation would be nice). To 
avoid adding manually all the classes I want to test, my UnitTest target (which 
is an app, not a test bundle) had a direct dependency on the main target. In 
this case, there are obviously no .gcda and .gcno files produced for the main 
target's classes. So to have coverage, I need to removed the direct dependency, 
and add the main target's classes, and now I have coverage. 

Original comment by cedric.f...@gmail.com on 4 Jan 2011 at 9:51

GoogleCodeExporter commented 9 years ago
Glad you got it working.

Original comment by dmaclach on 4 Jan 2011 at 4:13