aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/skylark
diff options
context:
space:
mode:
authorGravatar Greg Estren <gregce@google.com>2016-06-20 21:24:42 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-06-21 09:58:45 +0000
commit81a89997be258d6978ead96608c240aee9ec95ea (patch)
treee536729cec9cb71d5d93ecc1caef202c1ff95303 /src/test/java/com/google/devtools/build/lib/skylark
parentaedfc8aec2d086a3400bb9773f59f5d5e3cbfc67 (diff)
Updates BuildViewTestCase.invalidatePackages() to also invalidate
configurations. This is important for dynamic configurations. invalidatePackages() invalidates every file. This includes CROSSTOOL, which the CppConfiguration fragment depends on. For static configurations, this doesn't matter because all configurations and their fragments are pre-computed at the beginning of the build (or in the case of tests before the test case starts). For dynamic configurations, the configuration can get custom-created each configured target. When that happens after invalidatePackages, a new CppConfiguration instance gets created. This can impact code like CcLibraryHelper.addDeps(), which assumes equality (CppConfiguration has no .equals() method). Normally that's not a problem because the same CppConfiguration instance is used for every target in the post-invalidatePackages() graph. But host configurations break this: we keep a non-Skyframe host config cache in SkyframeBuildView.hostConfigurationCache. Without this change, it doesn't get cleared out, so it keeps old pre-invalidation references that under certain circumstances get applied to post-invalidation targets. -- MOS_MIGRATED_REVID=125379342
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/skylark')
-rw-r--r--src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
index c96a65e50b..1a430ed4b3 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
@@ -339,7 +339,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase {
scratch.file("/r/BUILD", "cc_library(name = 'cclib',", " srcs = ['sub/my_sub_lib.h'])");
scratch.file("/r/sub/BUILD", "cc_library(name = 'my_sub_lib', srcs = ['my_sub_lib.h'])");
scratch.overwriteFile("WORKSPACE", "local_repository(name='r', path='/r')");
- invalidatePackages();
+ invalidatePackages(/*alsoConfigs=*/false); // Repository shuffling messes with toolchain labels.
reporter.removeHandler(failFastHandler);
getConfiguredTarget("@r//:cclib");
assertContainsEvent(
@@ -812,7 +812,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase {
scratch.overwriteFile("WORKSPACE",
"local_repository(name='r', path='/r')");
- invalidatePackages();
+ invalidatePackages(/*alsoConfigs=*/false); // Repository shuffling messes with toolchain labels.
SkylarkRuleContext context = createRuleContext("@r//a:r");
Label depLabel = (Label) evalRuleContextCode(context, "ruleContext.attr.internal_dep.label");
assertThat(depLabel).isEqualTo(Label.parseAbsolute("//:dep"));
@@ -843,7 +843,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase {
scratch.overwriteFile("WORKSPACE",
"local_repository(name='r', path='/r')");
- invalidatePackages();
+ invalidatePackages(/*alsoConfigs=*/false); // Repository shuffling messes with toolchain labels.
SkylarkRuleContext context = createRuleContext("@r//a:r");
Label depLabel = (Label) evalRuleContextCode(context, "ruleContext.attr.internal_dep.label");
assertThat(depLabel).isEqualTo(Label.parseAbsolute("@r//:dep"));
@@ -879,7 +879,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase {
"load('@r2//:other_test.bzl', 'other_macro')", // We can still refer to r2 in other chunks.
"macro(NEXT_NAME, '/r2')" // and we can still use macro outside of its chunk.
);
- invalidatePackages();
+ invalidatePackages(/*alsoConfigs=*/false); // Repository shuffling messes with toolchain labels.
assertThat(getConfiguredTarget("@r1//:test")).isNotNull();
}
@@ -897,7 +897,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase {
"WORKSPACE",
"local_repository(name = 'foo', path = '/bar')",
"local_repository(name = 'foo', path = '/baz')");
- invalidatePackages();
+ invalidatePackages(/*alsoConfigs=*/false); // Repository shuffling messes with toolchain labels.
assertThat(
(List<Label>)
getConfiguredTarget("@foo//:baz")
@@ -915,7 +915,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase {
"load('//:bar.bzl', 'dummy')",
"local_repository(name = 'foo', path = '/baz')");
try {
- invalidatePackages();
+ invalidatePackages(/*alsoConfigs=*/false); // Repository shuffling messes with toolchains.
createRuleContext("@foo//:baz");
fail("Should have failed because repository 'foo' is overloading after a load!");
} catch (Exception ex) {