aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google
diff options
context:
space:
mode:
authorGravatar mstaib <mstaib@google.com>2018-05-14 16:44:05 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-14 16:45:24 -0700
commiteb5a80c7ba8f139f293d12147aec683de8582bc0 (patch)
tree670e6e1fbf0fedffd8d2f82365001d59a22f47be /src/test/java/com/google
parenta6ee1ee9c4b4309b721f73a4b3de3f3432a89d6e (diff)
Ease the configuration-related restrictions of several more tests.
Use update() and other methods which properly respect the trimming transition over those which don't. Avoid using the target configuration if the configuration actually used by a target is available. RELNOTES: None. PiperOrigin-RevId: 196588405
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java13
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java27
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java4
3 files changed, 27 insertions, 17 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java
index 39f5fdce81..bca66c2e49 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java
@@ -302,11 +302,14 @@ public class AnalysisCachingTest extends AnalysisCachingTestBase {
"cc_library(name='x', srcs=['foo.cc'])",
"cc_binary(name='_objs/x/conflict/foo.o', srcs=['bar.cc'])");
reporter.removeHandler(failFastHandler); // expect errors
- update(defaultFlags().with(Flag.KEEP_GOING),
- "//conflict:x", "//conflict:_objs/x/conflict/foo.pic.o");
- ConfiguredTarget a = getConfiguredTarget("//conflict:x");
- ConfiguredTarget b = getConfiguredTarget("//conflict:_objs/x/conflict/foo.pic.o");
- assertThat(hasTopLevelAnalysisError(a) ^ hasTopLevelAnalysisError(b)).isTrue();
+ int successfulAnalyses =
+ update(
+ defaultFlags().with(Flag.KEEP_GOING),
+ "//conflict:x",
+ "//conflict:_objs/x/conflict/foo.pic.o")
+ .getTargetsToBuild()
+ .size();
+ assertThat(successfulAnalyses).isEqualTo(1);
}
/**
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
index 90bc03bb9f..941b85cf02 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
@@ -47,6 +47,7 @@ import com.google.devtools.build.lib.packages.Rule;
import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData;
import com.google.devtools.build.lib.testutil.Suite;
import com.google.devtools.build.lib.testutil.TestConstants;
+import com.google.devtools.build.lib.testutil.TestRuleClassProvider;
import com.google.devtools.build.lib.testutil.TestSpec;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.Path;
@@ -387,12 +388,20 @@ public class BuildViewTest extends BuildViewTestBase {
@Test
public void testGetDirectPrerequisiteDependencies() throws Exception {
+ // Override the trimming transition to not distort the results.
+ ConfiguredRuleClassProvider.Builder builder =
+ new ConfiguredRuleClassProvider.Builder();
+ TestRuleClassProvider.addStandardRules(builder);
+ builder.overrideTrimmingTransitionFactoryForTesting((rule) -> NoTransition.INSTANCE);
+ useRuleClassProvider(builder.build());
+
+ update();
+
scratch.file(
"package/BUILD",
"filegroup(name='top', srcs=[':inner', 'file'])",
"sh_binary(name='inner', srcs=['script.sh'])");
- update("//package:top");
- ConfiguredTarget top = getConfiguredTarget("//package:top", getTargetConfiguration());
+ ConfiguredTarget top = Iterables.getOnlyElement(update("//package:top").getTargetsToBuild());
Iterable<Dependency> targets = getView().getDirectPrerequisiteDependenciesForTesting(
reporter, top, getBuildConfigurationCollection(), /*toolchainContext=*/ null).values();
@@ -617,9 +626,8 @@ public class BuildViewTest extends BuildViewTestBase {
"genrule(name='a', ",
" cmd='',",
" outs=['a.out'])");
- update("//pkg:a.out");
OutputFileConfiguredTarget outputCT = (OutputFileConfiguredTarget)
- getConfiguredTarget("//pkg:a.out");
+ Iterables.getOnlyElement(update("//pkg:a.out").getTargetsToBuild());
Artifact outputArtifact = outputCT.getArtifact();
Action action = getGeneratingAction(outputArtifact);
assertThat(action).isNotNull();
@@ -656,8 +664,7 @@ public class BuildViewTest extends BuildViewTestBase {
" srcs = glob(['A*.java']))",
"java_test(name = 'B',",
" srcs = ['B.java'])");
- update("//java/a:A");
- ConfiguredTarget ct = getConfiguredTarget("//java/a:A");
+ ConfiguredTarget ct = Iterables.getOnlyElement(update("//java/a:A").getTargetsToBuild());
scratch.deleteFile("java/a/C.java");
update("//java/a:B");
update("//java/a:A");
@@ -772,10 +779,10 @@ public class BuildViewTest extends BuildViewTestBase {
// Then update the BUILD file and re-analyze.
scratch.file("actions_not_registered/BUILD",
"cc_binary(name = 'foo', srcs = ['foo.cc'])");
- update("//actions_not_registered:foo");
- Artifact fooOut = Iterables.getOnlyElement(
- getConfiguredTarget("//actions_not_registered:foo")
- .getProvider(FileProvider.class).getFilesToBuild());
+ ConfiguredTarget foo =
+ Iterables.getOnlyElement(update("//actions_not_registered:foo").getTargetsToBuild());
+ Artifact fooOut =
+ Iterables.getOnlyElement(foo.getProvider(FileProvider.class).getFilesToBuild());
assertThat(getActionGraph().getGeneratingAction(fooOut)).isNotNull();
clearAnalysisResult();
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java
index 3696c59a27..759bdef9e3 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java
@@ -130,8 +130,8 @@ public class ConfigurationsForLateBoundTargetsTest extends AnalysisTestCase {
" name = 'foo')",
"rule_with_test_fragment(",
" name = 'latebound_dep')");
- update("//foo:foo");
- assertThat(getConfiguredTarget("//foo:foo")).isNotNull();
+ // if the target fails to analyze, this iterable will be empty
+ assertThat(update("//foo:foo").getTargetsToBuild()).isNotEmpty();
Iterable<ConfiguredTarget> deps = SkyframeExecutorTestUtils.getExistingConfiguredTargets(
skyframeExecutor, Label.parseAbsolute("//foo:latebound_dep"));
assertThat(deps).hasSize(2);