diff options
author | Googler <noreply@google.com> | 2018-08-10 09:03:26 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-08-10 09:04:58 -0700 |
commit | 3df620a1ef16e81780d7af40cd2dfa3251d40668 (patch) | |
tree | f1bd2797215caa3c0e8c6693b32211c98cdbf9f2 /src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java | |
parent | fc0654ff3798309c8b412220b1202f12059fd1ff (diff) |
Persist mappings from original command line patterns to expanded labels in TargetParsingCompleteEvent.
PiperOrigin-RevId: 208217102
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java index fdb6e80755..29ff98f98f 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java @@ -23,6 +23,7 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; import com.google.common.collect.MoreCollectors; @@ -695,6 +696,30 @@ public class LoadingPhaseRunnerTest { assertThat(err.getPattern()).containsExactly("//test:cycle1"); } + @Test + public void mapsOriginalPatternsToLabels() throws Exception { + tester.addFile("test/a/BUILD", "cc_library(name = 'a_lib', srcs = ['a.cc'])"); + tester.addFile("test/b/BUILD", "cc_library(name = 'b_lib', srcs = ['b.cc'])"); + + tester.load("test/a:all", "test/b:all", "test/..."); + + assertThat(tester.getOriginalPatternsToLabels()) + .containsExactly( + "test/a:all", Label.parseAbsoluteUnchecked("//test/a:a_lib"), + "test/b:all", Label.parseAbsoluteUnchecked("//test/b:b_lib"), + "test/...", Label.parseAbsoluteUnchecked("//test/a:a_lib"), + "test/...", Label.parseAbsoluteUnchecked("//test/b:b_lib")); + } + + @Test + public void mapsOriginalPatternsToLabels_omitsExcludedTargets() throws Exception { + tester.addFile("test/a/BUILD", "cc_library(name = 'a_lib', srcs = ['a.cc'])"); + + tester.load("test/...", "-test/a:a_lib"); + + assertThat(tester.getOriginalPatternsToLabels()).isEmpty(); + } + private static class LoadingPhaseTester { private final ManualClock clock = new ManualClock(); private final Path workspace; @@ -891,6 +916,10 @@ public class LoadingPhaseRunnerTest { return ImmutableSet.copyOf(targetParsingCompleteEvent.getLabels()); } + public ImmutableSetMultimap<String, Label> getOriginalPatternsToLabels() { + return targetParsingCompleteEvent.getOriginalPatternsToLabels(); + } + public ImmutableSet<Label> getTestSuiteTargets() { return loadingPhaseCompleteEvent.getFilteredLabels(); } |