diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/CqueryCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/CqueryCommand.java index 89d1a97a49d44c..7f30a18e749fe7 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/CqueryCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/CqueryCommand.java @@ -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")); @@ -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); } diff --git a/src/test/shell/integration/configured_query_test.sh b/src/test/shell/integration/configured_query_test.sh index 9e4a89d8ea41b3..bc5c48e9d34ae0 100755 --- a/src/test/shell/integration/configured_query_test.sh +++ b/src/test/shell/integration/configured_query_test.sh @@ -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