diff options
author | 2018-02-07 11:28:35 -0800 | |
---|---|---|
committer | 2018-02-07 11:30:12 -0800 | |
commit | 5b35c5cea86d45c382f8e13c07a59f961ded4070 (patch) | |
tree | 0c4573a00a193c3081a8059c55700182ed3bb265 /src | |
parent | e1ed133298cb65189fb7e2339a0920bbc4d42f07 (diff) |
When requesting nodes* look first in target configuration, then host (used to be the other way around).
This fixes b/72817591 which saw the following -
(1) somepath(//foo, //bar) --nohost_deps -> empty query results
(2) deps(//foo) --nohost_deps | grep '//bar' -> found //bar
This happened because //bar was configured in both the host and the target config. There was no path from //foo-target -> //bar-host because of the --nohost_deps setting (1) but //bar-target did exist in the results of (2)
PiperOrigin-RevId: 184868484
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java | 9 | ||||
-rwxr-xr-x | src/test/shell/integration/configured_query_test.sh | 23 |
2 files changed, 6 insertions, 26 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java index 0dfff29072..c87583db36 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java @@ -180,14 +180,17 @@ public class ConfiguredTargetQueryEnvironment } private ConfiguredTarget getConfiguredTarget(Label label) throws InterruptedException { - // Try with host configuration. + // Try with target configuration. ConfiguredTarget configuredTarget = - getConfiguredTarget(ConfiguredTargetValue.key(label, hostConfiguration)); + getConfiguredTarget(ConfiguredTargetValue.key(label, defaultTargetConfiguration)); if (configuredTarget != null) { return configuredTarget; } + // Try with host configuration (even when --nohost_deps is set in the case that top-level + // targets are configured in the host configuration so we are doing a host-configuration-only + // query). configuredTarget = - getConfiguredTarget(ConfiguredTargetValue.key(label, defaultTargetConfiguration)); + getConfiguredTarget(ConfiguredTargetValue.key(label, hostConfiguration)); if (configuredTarget != null) { return configuredTarget; } diff --git a/src/test/shell/integration/configured_query_test.sh b/src/test/shell/integration/configured_query_test.sh index bdeea8c23c..0a09332306 100755 --- a/src/test/shell/integration/configured_query_test.sh +++ b/src/test/shell/integration/configured_query_test.sh @@ -103,29 +103,6 @@ function test_universe_scope_specified() { assert_not_equals $HOST_CONFIG $TARGET_CONFIG } -# This test ensures the known buggy behavior described at b/71905538 i.e. nodes -# lingering from previous builds. -# TODO(juliexxia): Remove this test once b/71905538 is fixed. -function test_ghost_nodes_bug() { - write_java_library_build - - # Create host-configured //pine:plugin node in this cquery - bazel cquery "deps(//pine:my_java)" || fail "Excepted success" - # This cquery should return target configured //pine:plugin but actually returns - # the host-configured target generated above. This is the buggy behavior. - bazel cquery //pine:dep+//pine:plugin \ - > output 2>"$TEST_log" || fail "Excepted success" - - # Find the lines of output for //pine:plugin and //pine:dep. - PLUGIN=$(grep "//pine:plugin" output) - DEP=$(grep "//pine:dep" output) - # Trim to just configurations. - PLUGIN_CONFIG=${PLUGIN/"//pine:plugin"} - DEP_CONFIG=${DEP/"//pine:dep"} - # Ensure they are are not equal (the buggy behavior). - assert_not_equals $PLUGIN_CONFIG $DEP_CONFIG -} - function test_host_config_output() { write_java_library_build |