Skip to content

Commit 9f67cdf

Browse files
gregestrencopybara-github
authored andcommitted
cquery: disable --build_tests_only.
PriorityCategory.SOFTWARE_REQUIREMENT cannot be overridden by the user, unlike PriorityCategory.COMPUTED_DEFAULT. Also another existing flag that I think deserves the same enforcement. Re: concerns about aquery: none of this affects aquery because aquery doesn't inherit from TestCommand: https://github.com/bazelbuild/bazel/blob/a03442dd7408cdc6ef936f96cd3146ff6b3d09dd/src/main/java/com/google/devtools/build/lib/runtime/commands/CqueryCommand.java#L56 https://github.com/bazelbuild/bazel/blob/a03442dd7408cdc6ef936f96cd3146ff6b3d09dd/src/main/java/com/google/devtools/build/lib/runtime/commands/AqueryCommand.java#L48 PiperOrigin-RevId: 388330077
1 parent 8eba488 commit 9f67cdf

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/main/java/com/google/devtools/build/lib/runtime/commands/CqueryCommand.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void editOptions(OptionsParser optionsParser) {
8181
"cquery should include 'tags = [\"manual\"]' targets by default",
8282
ImmutableList.of("--build_manual_tests"));
8383
optionsParser.parse(
84-
PriorityCategory.COMPUTED_DEFAULT,
84+
PriorityCategory.SOFTWARE_REQUIREMENT,
8585
// https://github.com/bazelbuild/bazel/issues/11078
8686
"cquery should not exclude test_suite rules",
8787
ImmutableList.of("--noexpand_test_suites"));
@@ -93,6 +93,10 @@ public void editOptions(OptionsParser optionsParser) {
9393
"--include_config_fragments_provider="
9494
+ cqueryOptions.showRequiredConfigFragments));
9595
}
96+
optionsParser.parse(
97+
PriorityCategory.SOFTWARE_REQUIREMENT,
98+
"cquery should not exclude tests",
99+
ImmutableList.of("--nobuild_tests_only"));
96100
} catch (OptionsParsingException e) {
97101
throw new IllegalStateException("Cquery's known options failed to parse", e);
98102
}

src/test/shell/integration/configured_query_test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,20 @@ EOF
819819
assert_contains "//$pkg:my_test" output
820820
}
821821

822+
function test_build_tests_only_override() {
823+
local -r pkg=$FUNCNAME
824+
mkdir -p $pkg
825+
cat > $pkg/BUILD <<'EOF'
826+
cc_binary(
827+
name = "not_a_test",
828+
srcs = ["not_a_test.cc"])
829+
EOF
830+
831+
bazel cquery --build_tests_only "//$pkg:all" > output 2>"$TEST_log" || \
832+
fail "Expected success"
833+
assert_contains "//$pkg:not_a_test" output
834+
}
835+
822836
function test_label_output_shows_alias_labels() {
823837
local -r pkg=$FUNCNAME
824838
mkdir -p $pkg

0 commit comments

Comments
 (0)