diff options
author | Peter Schmitt <schmitt@google.com> | 2015-07-29 14:49:01 +0000 |
---|---|---|
committer | Lukacs Berki <lberki@google.com> | 2015-07-29 16:03:41 +0000 |
commit | 40deeff2fb1a0686be6276c1559ce051fe079a04 (patch) | |
tree | db1ce933aeeecafb401be94741427552659254a7 /src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java | |
parent | a0345bce94607a7096777d9013eed4c08cf12edc (diff) |
Support coverage in experimental_ios_test.
Coverage depends on quite a few moving parts, several of which were changed for this test:
- BuildConfiguration.getCoverageLabels() used to include gcov support, this is now replaced by the dedicated getGcovLabels() and a separate implicit attribute on TestBaseRule. This new attribute is then overridden in ExperimentalIosTest to use an xcode-compatible gcov.
- Objc's TestSupport now correctly registers instrumented files and sets the necessary runfiles for collecting coverage.
- ios_test's template exports gcda files for coverage computation after the test's execution.
--
MOS_MIGRATED_REVID=99374435
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java b/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java index 4baf3b3d7e..48887ddf1b 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java @@ -93,7 +93,17 @@ public class BaseRuleClasses { @Override public List<Label> getDefault(Rule rule, BuildConfiguration configuration) { return configuration.isCodeCoverageEnabled() - ? ImmutableList.<Label>copyOf(configuration.getCoverageLabels()) + ? ImmutableList.copyOf(configuration.getCoverageLabels()) + : ImmutableList.<Label>of(); + } + }; + + private static final LateBoundLabelList<BuildConfiguration> GCOV = + new LateBoundLabelList<BuildConfiguration>(ImmutableList.of(COVERAGE_SUPPORT_LABEL)) { + @Override + public List<Label> getDefault(Rule rule, BuildConfiguration configuration) { + return configuration.isCodeCoverageEnabled() + ? ImmutableList.copyOf(configuration.getGcovLabels()) : ImmutableList.<Label>of(); } }; @@ -103,7 +113,7 @@ public class BaseRuleClasses { @Override public List<Label> getDefault(Rule rule, BuildConfiguration configuration) { return configuration.isCodeCoverageEnabled() - ? ImmutableList.<Label>copyOf(configuration.getCoverageReportGeneratorLabels()) + ? ImmutableList.copyOf(configuration.getCoverageReportGeneratorLabels()) : ImmutableList.<Label>of(); } }; @@ -158,6 +168,7 @@ public class BaseRuleClasses { // implicitly depend on crosstool, which provides gcov. We could add gcov to // InstrumentedFilesProvider.getInstrumentationMetadataFiles() (or a new method) for // all the test rules that have C++ in their transitive closure. Then this could go. + .add(attr(":gcov", LABEL_LIST).cfg(HOST).value(GCOV)) .add(attr(":coverage_support", LABEL_LIST).cfg(HOST).value(COVERAGE_SUPPORT)) .add(attr(":coverage_report_generator", LABEL_LIST).cfg(HOST) .value(COVERAGE_REPORT_GENERATOR)) |