|
33 | 33 | import java.util.LinkedHashSet;
|
34 | 34 | import java.util.List;
|
35 | 35 | import java.util.Set;
|
| 36 | +import java.util.stream.Collectors; |
36 | 37 | import org.junit.Before;
|
37 | 38 | import org.junit.Test;
|
38 | 39 |
|
@@ -71,7 +72,7 @@ public final void defineSimpleRule() throws Exception {
|
71 | 72 | " runfiles = ctx.runfiles([runfile]),",
|
72 | 73 | " ),",
|
73 | 74 | " OutputGroupInfo(",
|
74 |
| - " foobar = [output_group_only],", |
| 75 | + " foobar = [output_group_only, ctx.file.explicit_source_dep],", |
75 | 76 | " ),",
|
76 | 77 | " ]",
|
77 | 78 | "r = rule(",
|
@@ -134,21 +135,34 @@ private List<String> getOutput(String queryExpression, List<String> outputGroups
|
134 | 135 | @Test
|
135 | 136 | public void basicQuery_defaultOutputGroup() throws Exception {
|
136 | 137 | List<String> output = getOutput("//pkg:all", ImmutableList.of());
|
| 138 | + var sourceAndGeneratedFiles = |
| 139 | + output.stream() |
| 140 | + .collect(Collectors.<String>partitioningBy(path -> path.matches("^[^/]*-out/.*"))); |
| 141 | + assertThat(sourceAndGeneratedFiles.get(false)).containsExactly("pkg/BUILD", "defs/rules.bzl"); |
137 | 142 | assertContainsExactlyWithBinDirPrefix(
|
138 |
| - output, "pkg/main_default_file", "pkg/other_default_file"); |
| 143 | + sourceAndGeneratedFiles.get(true), "pkg/main_default_file", "pkg/other_default_file"); |
139 | 144 | }
|
140 | 145 |
|
141 | 146 | @Test
|
142 | 147 | public void basicQuery_defaultAndCustomOutputGroup() throws Exception {
|
143 | 148 | List<String> output = getOutput("//pkg:main", ImmutableList.of("+foobar"));
|
| 149 | + var sourceAndGeneratedFiles = |
| 150 | + output.stream() |
| 151 | + .collect(Collectors.<String>partitioningBy(path -> path.matches("^[^/]*-out/.*"))); |
| 152 | + assertThat(sourceAndGeneratedFiles.get(false)).containsExactly("pkg/BUILD", "defs/rules.bzl"); |
144 | 153 | assertContainsExactlyWithBinDirPrefix(
|
145 |
| - output, "pkg/main_default_file", "pkg/main_output_group_only"); |
| 154 | + sourceAndGeneratedFiles.get(true), "pkg/main_default_file", "pkg/main_output_group_only"); |
146 | 155 | }
|
147 | 156 |
|
148 | 157 | @Test
|
149 | 158 | public void basicQuery_customOutputGroupOnly() throws Exception {
|
150 | 159 | List<String> output = getOutput("//pkg:other", ImmutableList.of("foobar"));
|
151 |
| - assertContainsExactlyWithBinDirPrefix(output, "pkg/other_output_group_only"); |
| 160 | + var sourceAndGeneratedFiles = |
| 161 | + output.stream() |
| 162 | + .collect(Collectors.<String>partitioningBy(path -> path.matches("^[^/]*-out/.*"))); |
| 163 | + assertThat(sourceAndGeneratedFiles.get(false)).containsExactly("pkg/BUILD"); |
| 164 | + assertContainsExactlyWithBinDirPrefix( |
| 165 | + sourceAndGeneratedFiles.get(true), "pkg/other_output_group_only"); |
152 | 166 | }
|
153 | 167 |
|
154 | 168 | private void assertContainsExactlyWithBinDirPrefix(
|
|
0 commit comments