Skip to content

Commit

Permalink
Rename and change default experimental_genquery_use_graphless_query.
Browse files Browse the repository at this point in the history
Genquery now uses graphless query by default.
This #12464 keeps track of the flag change on github.

PiperOrigin-RevId: 360377997
  • Loading branch information
zhengwei143 authored and copybara-github committed Mar 2, 2021
1 parent 7e95cfe commit 0f1e303
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,43 @@ public OutputPathsConverter() {
+ "all non-Genrule actions.\n")
public ExecutionInfoModifier executionInfoModifier;

@Option(
name = "incompatible_genquery_use_graphless_query",
defaultValue = "null",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
expansion = {
"--experimental_genquery_use_graphless_query=auto",
},
effectTags = {
OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION,
OptionEffectTag.AFFECTS_OUTPUTS,
OptionEffectTag.LOADING_AND_ANALYSIS
},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help = "Use graphless query and disable output ordering for genquery.")
public Void incompatibleUseGraphlessQuery;

@Option(
name = "noincompatible_genquery_use_graphless_query",
defaultValue = "null",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
expansion = {
"--experimental_genquery_use_graphless_query=false",
},
effectTags = {
OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION,
OptionEffectTag.AFFECTS_OUTPUTS,
OptionEffectTag.LOADING_AND_ANALYSIS
},
help = "Do not use graphless query for genquery.")
public Void noincompatibleUseGraphlessQuery;

@Option(
name = "experimental_genquery_use_graphless_query",
defaultValue = "false",
defaultValue = "auto",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {
OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,15 @@ public void testResultsAlphabetized() throws Exception {
write("c/BUILD", "sh_library(name = 'c', deps = ['//z:a'])");
assertQueryResult(
"//fruits:q",
// Results are ordered in reverse dependency order (nodes, then their dependencies), and in
// reverse alphabetic order for ties.
// Results are ordered in lexicographical order (uses graphless genquery by default).
"//a:z",
"//c:c",
"//fruits:1",
"//fruits:a",
"//fruits:c",
"//fruits:melon",
"//fruits:z",
"//fruits:c",
"//fruits:a",
"//fruits:1",
"//c:c",
"//z:a",
"//a:z");
"//z:a");
}

@Test
Expand All @@ -186,7 +185,7 @@ public void testQueryReexecutedIfDepsChange() throws Exception {
"sh_library(name='tropical', deps=[':papaya'])",
"sh_library(name='papaya')");

assertQueryResult("//food:q", "//food:fruit_salad", "//fruits:tropical", "//fruits:papaya");
assertQueryResult("//food:q", "//food:fruit_salad", "//fruits:papaya", "//fruits:tropical");

write("fruits/BUILD",
"sh_library(name='tropical', deps=[':papaya', ':coconut'])",
Expand All @@ -196,9 +195,9 @@ public void testQueryReexecutedIfDepsChange() throws Exception {
assertQueryResult(
"//food:q",
"//food:fruit_salad",
"//fruits:tropical",
"//fruits:coconut",
"//fruits:papaya",
"//fruits:coconut");
"//fruits:tropical");
}

@Test
Expand All @@ -219,11 +218,11 @@ public void testGenQueryEncountersAnotherGenQuery() throws Exception {

assertQueryResult(
"//fruits:q",
"//spices:q",
"//fruits:pear",
"//fruits:plum",
"//spices:cinnamon",
"//spices:nutmeg",
"//fruits:pear",
"//fruits:plum");
"//spices:q");
}

/**
Expand Down Expand Up @@ -261,8 +260,8 @@ public void testMultiplePatternsInQuery() throws Exception {
for (int i = 0; i < 20; i += 2) {
expected.add(i / 2, "//spices:in" + i);
}
Collections.sort(expected, Collections.reverseOrder());
expected.add(0, "//spices:top");
Collections.sort(expected);
assertQueryResult("//spices:q", expected.toArray(new String[0]));
}

Expand Down Expand Up @@ -358,10 +357,7 @@ public void testDoesntAllowLocationOutputWithBuildfiles() throws Exception {
" opts = ['--output=location'],",
" scope = ['//foo:foo'],",
")");
assertQueryResult(
"//foo:gen-buildfiles",
"//foo:bzl.bzl",
"//foo:BUILD");
assertQueryResult("//foo:gen-buildfiles", "//foo:BUILD", "//foo:bzl.bzl");
assertThrows(
ViewCreationFailedException.class, () -> buildTarget("//foo:gen-buildfiles-location"));
events.assertContainsError(
Expand Down
6 changes: 2 additions & 4 deletions src/test/shell/integration/bazel_query_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,7 @@ EOF
//foo:b
//foo:a
EOF
bazel build --experimental_genquery_use_graphless_query \
//foo:somepath >& $TEST_log || fail "Expected success"
bazel build //foo:somepath >& $TEST_log || fail "Expected success"
assert_equals "$(cat foo/expected_sp_output)" "$(cat bazel-bin/foo/somepath)"

# Allpaths in genquery outputs in lexicographical order (just like all other
Expand All @@ -706,8 +705,7 @@ EOF
//foo:b
//foo:c
EOF
bazel build --experimental_genquery_use_graphless_query \
//foo:allpaths >& $TEST_log || fail "Expected success"
bazel build //foo:allpaths >& $TEST_log || fail "Expected success"
assert_equals "$(cat foo/expected_ap_output)" "$(cat bazel-bin/foo/allpaths)"
}

Expand Down

0 comments on commit 0f1e303

Please sign in to comment.