aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/google/devtools')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java19
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/config/BuildOptionsTest.java27
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java6
3 files changed, 42 insertions, 10 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java b/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java
index fa62eccb3d..fc5b156dca 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java
@@ -114,6 +114,7 @@ public class DependencyResolverTest extends AnalysisTestCase {
Target target = packageManager.getTarget(reporter, Label.parseAbsolute(targetName));
return dependencyResolver.dependentNodeMap(
new TargetAndConfiguration(target, getTargetConfiguration()),
+ getHostConfiguration(),
aspectDefinition,
ImmutableSet.<ConfigMatchingProvider>of());
}
@@ -227,10 +228,10 @@ public class DependencyResolverTest extends AnalysisTestCase {
new Dependency(aExplicit, target, inverseAspects))
.addEqualityGroup(
// base set but with null configuration
- new Dependency(a, null, twoAspects),
- new Dependency(aExplicit, null, twoAspects),
- new Dependency(a, null, inverseAspects),
- new Dependency(aExplicit, null, inverseAspects))
+ new Dependency(a, (BuildConfiguration) null, twoAspects),
+ new Dependency(aExplicit, (BuildConfiguration) null, twoAspects),
+ new Dependency(a, (BuildConfiguration) null, inverseAspects),
+ new Dependency(aExplicit, (BuildConfiguration) null, inverseAspects))
.addEqualityGroup(
// base set but with different aspects
new Dependency(a, host, differentAspects),
@@ -241,8 +242,8 @@ public class DependencyResolverTest extends AnalysisTestCase {
new Dependency(b, target, inverseAspects))
.addEqualityGroup(
// base set but with label //b and null configuration
- new Dependency(b, null, twoAspects),
- new Dependency(b, null, inverseAspects))
+ new Dependency(b, (BuildConfiguration) null, twoAspects),
+ new Dependency(b, (BuildConfiguration) null, inverseAspects))
.addEqualityGroup(
// base set but with label //b and different aspects
new Dependency(b, host, differentAspects))
@@ -252,14 +253,14 @@ public class DependencyResolverTest extends AnalysisTestCase {
new Dependency(aExplicit, target, differentAspects))
.addEqualityGroup(
// base set but with null configuration and different aspects
- new Dependency(a, null, differentAspects),
- new Dependency(aExplicit, null, differentAspects))
+ new Dependency(a, (BuildConfiguration) null, differentAspects),
+ new Dependency(aExplicit, (BuildConfiguration) null, differentAspects))
.addEqualityGroup(
// inverse of base set: //b, target configuration, different aspects
new Dependency(b, target, differentAspects))
.addEqualityGroup(
// inverse of base set: //b, null configuration, different aspects
- new Dependency(b, null, differentAspects))
+ new Dependency(b, (BuildConfiguration) null, differentAspects))
.testEquals();
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/config/BuildOptionsTest.java b/src/test/java/com/google/devtools/build/lib/analysis/config/BuildOptionsTest.java
index 10b8f685cd..fcb5cd895a 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/config/BuildOptionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/config/BuildOptionsTest.java
@@ -14,8 +14,10 @@
package com.google.devtools.build.lib.analysis.config;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.rules.cpp.CppOptions;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -47,4 +49,29 @@ public class BuildOptionsTest {
BuildOptions b = BuildOptions.of(TEST_OPTIONS, options);
assertEquals(a.toString(), b.toString());
}
+
+ @Test
+ public void testOptionsEquality() throws Exception {
+ String[] options1 = new String[] { "--compilation_mode=opt" };
+ String[] options2 = new String[] { "--compilation_mode=dbg" };
+ // Distinct instances with the same values are equal:
+ assertEquals(BuildOptions.of(TEST_OPTIONS, options1), BuildOptions.of(TEST_OPTIONS, options1));
+ // Same fragments, different values aren't equal:
+ assertFalse(BuildOptions.of(TEST_OPTIONS, options1).equals(
+ BuildOptions.of(TEST_OPTIONS, options2)));
+ // Same values, different fragments aren't equal:
+ assertFalse(BuildOptions.of(TEST_OPTIONS, options1).equals(
+ BuildOptions.of(
+ ImmutableList.<Class<? extends FragmentOptions>>of(
+ BuildConfiguration.Options.class, CppOptions.class),
+ options1)));
+ // Same values and fragments, same original options are equal:
+ BuildOptions original1 = BuildOptions.of(TEST_OPTIONS, options1);
+ BuildOptions original2 = BuildOptions.of(TEST_OPTIONS, options2);
+ assertEquals(BuildOptions.of(TEST_OPTIONS, original1, options2),
+ BuildOptions.of(TEST_OPTIONS, original1, options2));
+ // Same values and fragments, different original options are not equal:
+ assertFalse(BuildOptions.of(TEST_OPTIONS, original1, options2).equals(
+ BuildOptions.of(TEST_OPTIONS, original2, options2)));
+ }
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
index 81f7dc433b..77ab72ce06 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
@@ -1240,7 +1240,11 @@ public abstract class BuildViewTestCase extends FoundationTestCase {
}
protected BuildConfiguration getDataConfiguration() {
- return getTargetConfiguration().getConfiguration(ConfigurationTransition.DATA);
+ BuildConfiguration targetConfig = getTargetConfiguration();
+ // TODO(bazel-team): do a proper data transition for dynamic configurations.
+ return targetConfig.useDynamicConfigurations()
+ ? targetConfig
+ : targetConfig.getConfiguration(ConfigurationTransition.DATA);
}
protected BuildConfiguration getHostConfiguration() {