Inability to generate Code Coverage files for static library
| Originator: | david.anderson | ||
| Number: | rdar://15605406 | Date Originated: | December 6, 2013 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | 5.0.2 |
| Classification: | Other Bug | Reproducible: | Yes |
Summary: It is possible to generate the files necessary for creating a code coverage report using the workaround documented here: http://stackoverflow.com/a/19386835/1751969 Unfortunately, this workaround depends on the availability of Application Delegate methods +initialize and -applicationWillTerminate: particularly to trigger __gcov_flush() from within the target application, thereby generating the .gcda files necessary for visualizing code coverage. In a project for a static library, with a separate target for performing unit tests on that static library, there does not appear to be a way to register a subclass of XCTestObserver such that when the test suite has completed __gcov_flush() can be triggered. Steps to Reproduce: 1. Launch Xcode 5.0.1 on Mavericks 13A598 2. File > New Project... 3. Framework & Library > Cocoa Touch Static Library 4. Give the Project the name "SampleKit" and create a git repo for it (on My Mac) 5. Add a non-library target to workaround rdar://15156225 6. At the project (not target) level set GCC_GENERATE_TEST_COVERAGE_FILES = YES and set GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES per http://stackoverflow.com/a/19386835/1751969 6. Pick a simulator (not a device) 7. Cmd + U to run the tests 8. Open a terminal and cd ~/Library/Developer/Xcode/DerivedData/ 9. Check for .gcno files via find . -name *.gcno (.gcno files will be available as expected.) 10. Check for .gcda files via find . -name *.gcda No .gcda files are created. Attempting to use the workaround for calling __gcov_flush() documented in http://stackoverflow.com/a/19386835/1751969 does not work as it is not clear how to register the subclass of XCTestObserver as SampleKitTestLog (added to the to the Unit Test Target) from within the static library. That is the subclass of XCTestObserver is never instantiated and therefore it is not possible to hook in and trigger __gcov_flush() when the suite of tests has completed. Expected Results: For __gcov_flush() to get call automatically (for iOS Apps and Static Libraries) when a set of unit tests completes, without the need for the workarounds documented in http://stackoverflow.com/a/19386835/1751969 Actual Results: It is possible to manually call __gcov_flush() for iOS apps, but the same opportunity to register a subclass of XCTestObserver and trigger __gcov_flush() at the end of the test suite is not available for static libraries. Version: Xcode 5.0.2 Notes: Configuration: Attachments:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!