Code coverage is not correctly reported for Swift projects with whole module optimization enabled
Originator: | keithbsmiley | ||
Number: | rdar://42562585 | Date Originated: | 24-Jul-2018 04:58 PM |
Status: | Open | Resolved: | |
Product: | Developer Tools | Product Version: | Xcode 10.0 beta 4 (10L213o) |
Classification: | Other Bug | Reproducible: | Always |
Summary: In a Swift project with static libraries, if you enable whole module optimizations, code coverage may not include your source files, only your test files. Steps to Reproduce: 1. Create a new Swift static library project 2. Create a test target for your library 3. Create 2 source files Foo and Bar, add a top level function to each 4. Create 2 test files FooTests and BarTests, add a test to both, don't call Foo from FooTests, but call Bar from BarTests 5. Setup your scheme to test the target and collect coverage 6. Enable whole module optimizations project wide by setting SWIFT_COMPILATION_MODE to wholemodule at the top level 7. Run the tests 8. View the coverage report Expected Results: You see Foo.swift included in the report with 0% coverage, you see Bar.swift in the report with 100% coverage Actual Results: Neither Foo.swift or Bar.swift appear in the coverage report, only FooTests.swift and BarTests.swift do Version: Xcode 10.0 beta 4 (10L213o) Notes: - If you change FooTests to call Foo, you see both files (this makes me think it's related to rdar://42562307) - See the attached project for an example - See screenshot.png for the view from Xcode, as well as output.txt for the text representation from `xccov` and the `test.xccovreport`
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!