Overrides BuildConfiguration.equals() for dynamic configs.
This makes ConstraintsTest#hostDependenciesNotCheckedNoDistinctHostConfiguration
pass with --experimental_dynamic_configs=notrim (the host config
is the same as the target config but it's still a separate instance).
--
MOS_MIGRATED_REVID=140652716
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
index 97f113f..dae241b 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
@@ -1120,6 +1120,29 @@
private final Map<String, OptionDetails> transitiveOptionsMap;
/**
+ * Returns {@code true} if this configuration is semantically equal to the other, including
+ * checking that both have the same sets of fragments and options.
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ } else if (!(other instanceof BuildConfiguration)) {
+ return false;
+ } else {
+ BuildConfiguration otherConfig = (BuildConfiguration) other;
+ return actionsEnabled == otherConfig.actionsEnabled
+ && fragments.values().equals(otherConfig.fragments.values())
+ && buildOptions.getOptions().equals(otherConfig.buildOptions.getOptions());
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(actionsEnabled, fragments, buildOptions.getOptions());
+ }
+
+ /**
* Returns true if this configuration is semantically equal to the other, with
* the possible exception that the other has fewer fragments.
*
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 9cf952c..d9dd9ae 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
@@ -426,7 +426,7 @@
*/
protected final void createBuildView() throws Exception {
Preconditions.checkNotNull(masterConfig);
- Preconditions.checkState(getHostConfiguration() == getTargetConfiguration()
+ Preconditions.checkState(getHostConfiguration().equals(getTargetConfiguration())
|| getHostConfiguration().isHostConfiguration(),
"Host configuration %s is not a host configuration' "
+ "and does not match target configuration %s",