gradle / gradle-native

The home of Gradle's support for natively compiled languages
https://blog.gradle.org/introducing-the-new-cpp-plugins
Apache License 2.0
92 stars 8 forks source link

Generate code coverage data for Xcode #303

Open big-guy opened 6 years ago

big-guy commented 6 years ago

After generating the Xcode configuration for a project, enabling 'Gather coverage data' in the test scheme does nothing.

As a developer, I should be able to generate coverage data for my project, execute tests and visualize the results in Xcode.

Test coverage:

Out-of-scope:

big-guy commented 6 years ago

I'm satisfied that this has a potential workaround and would be low priority for now to remove it from the iteration.

I think this is just a matter of adding these as the compiler arguments to SwiftCompile -profile-generate -profile-coverage-mapping. We may want to model this as a isProfilable option on the task/binary.

We could key off of an environment variable (CLANG_COVERAGE_MAPPING) that Xcode sets to enable code profiling, but I think we should just add a new Xcode configuration that you need to switch to if you want to generate profile data. We would want to also consider adding another buildType on the Gradle side (e.g., debug, release, profile) so we could potentially generate code coverage reports ourselves.

As a workaround, it looks viable to just add those compiler arguments to the task and see how close that gets us. We would need to spend some time in Xcode to figure out if we need to do anything else.