diff options
author | 2015-09-22 13:51:48 +0000 | |
---|---|---|
committer | 2015-09-22 17:09:47 +0000 | |
commit | 8ddc32d3cf5bc1e92206f84b9e1cc5b6e70e2375 (patch) | |
tree | bd4879dc54e79d13dbe8ce6ffc0bd8cb79b7b9c5 /src/main/java/com/google/devtools/build/lib/rules/test/InstrumentedFilesCollector.java | |
parent | f1b537ae1e8928a36929be72f2b7789e0807303c (diff) |
Switch objc rules to standard coverage propagation using InstrumentedFilesCollector.
--
MOS_MIGRATED_REVID=103642172
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/test/InstrumentedFilesCollector.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/test/InstrumentedFilesCollector.java | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/InstrumentedFilesCollector.java b/src/main/java/com/google/devtools/build/lib/rules/test/InstrumentedFilesCollector.java index 2266b54d1d..84b13a96fe 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/test/InstrumentedFilesCollector.java +++ b/src/main/java/com/google/devtools/build/lib/rules/test/InstrumentedFilesCollector.java @@ -15,7 +15,6 @@ package com.google.devtools.build.lib.rules.test; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Action; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.AnalysisEnvironment; @@ -35,15 +34,32 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import javax.annotation.Nullable; - /** * A helper class for collecting instrumented files and metadata for a target. */ public final class InstrumentedFilesCollector { - public static InstrumentedFilesProvider collect(RuleContext ruleContext, InstrumentationSpec spec, - @Nullable LocalMetadataCollector localMetadataCollector, - @Nullable Iterable<Artifact> rootFiles) { + + /** + * Forwards any instrumented files from the given target's dependencies (as defined in + * {@code dependencyAttributes}) for further export. No files from this target are considered + * instrumented. + * + * @return instrumented file provider of all dependencies in {@code dependencyAttributes} + */ + public static InstrumentedFilesProvider forward( + RuleContext ruleContext, String... dependencyAttributes) { + return collect( + ruleContext, + new InstrumentationSpec(FileTypeSet.NO_FILE).withDependencyAttributes(dependencyAttributes), + null, + null); + } + + public static InstrumentedFilesProvider collect( + RuleContext ruleContext, + InstrumentationSpec spec, + LocalMetadataCollector localMetadataCollector, + Iterable<Artifact> rootFiles) { return collect(ruleContext, spec, localMetadataCollector, rootFiles, false); } @@ -53,9 +69,12 @@ public final class InstrumentedFilesCollector { * configured target, and creates baseline coverage actions for the transitive closure of source * files (if <code>withBaselineCoverage</code> is true). */ - public static InstrumentedFilesProvider collect(RuleContext ruleContext, - InstrumentationSpec spec, @Nullable LocalMetadataCollector localMetadataCollector, - @Nullable Iterable<Artifact> rootFiles, boolean withBaselineCoverage) { + public static InstrumentedFilesProvider collect( + RuleContext ruleContext, + InstrumentationSpec spec, + LocalMetadataCollector localMetadataCollector, + Iterable<Artifact> rootFiles, + boolean withBaselineCoverage) { Preconditions.checkNotNull(ruleContext); Preconditions.checkNotNull(spec); @@ -118,11 +137,11 @@ public final class InstrumentedFilesCollector { // Create one baseline coverage action per target, but for the transitive closure of files. NestedSet<Artifact> baselineCoverageArtifacts = BaselineCoverageAction.create(ruleContext, baselineCoverageFiles); - return new InstrumentedFilesProviderImpl(instrumentedFilesBuilder.build(), + return new InstrumentedFilesProviderImpl( + instrumentedFilesBuilder.build(), metadataFilesBuilder.build(), baselineCoverageFiles, - baselineCoverageArtifacts, - ImmutableMap.<String, String>of()); + baselineCoverageArtifacts); } /** |