Skip to content

Commit

Permalink
cquery: disable --build_tests_only.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gregestren authored and copybara-github committed Aug 2, 2021
1 parent 8eba488 commit 9f67cdf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void editOptions(OptionsParser optionsParser) {
"cquery should include 'tags = [\"manual\"]' targets by default",
ImmutableList.of("--build_manual_tests"));
optionsParser.parse(
PriorityCategory.COMPUTED_DEFAULT,
PriorityCategory.SOFTWARE_REQUIREMENT,
// https://github.com/bazelbuild/bazel/issues/11078
"cquery should not exclude test_suite rules",
ImmutableList.of("--noexpand_test_suites"));
Expand All @@ -93,6 +93,10 @@ public void editOptions(OptionsParser optionsParser) {
"--include_config_fragments_provider="
+ cqueryOptions.showRequiredConfigFragments));
}
optionsParser.parse(
PriorityCategory.SOFTWARE_REQUIREMENT,
"cquery should not exclude tests",
ImmutableList.of("--nobuild_tests_only"));
} catch (OptionsParsingException e) {
throw new IllegalStateException("Cquery's known options failed to parse", e);
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/shell/integration/configured_query_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,20 @@ EOF
assert_contains "//$pkg:my_test" output
}

function test_build_tests_only_override() {
local -r pkg=$FUNCNAME
mkdir -p $pkg
cat > $pkg/BUILD <<'EOF'
cc_binary(
name = "not_a_test",
srcs = ["not_a_test.cc"])
EOF

bazel cquery --build_tests_only "//$pkg:all" > output 2>"$TEST_log" || \
fail "Expected success"
assert_contains "//$pkg:not_a_test" output
}

function test_label_output_shows_alias_labels() {
local -r pkg=$FUNCNAME
mkdir -p $pkg
Expand Down

0 comments on commit 9f67cdf

Please sign in to comment.