From 91a944370b799f5871cc7616e3ea24ace48d1eb8 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 19 May 2021 12:03:57 +0100 Subject: [PATCH] cquery inherits from `test` not `build` This makes flags like `--test_arg` present in `.bazelrc` files be factored into the configuration hash for test targets. See https://github.com/bazelbuild/bazel/issues/13428 for extensive context. --- .../lib/runtime/commands/CqueryCommand.java | 7 +++++- .../integration/configured_query_test.sh | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) 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 3e30913b55f1fe..e18297560c1a32 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 @@ -48,7 +48,12 @@ @Command( name = "cquery", builds = true, - inherits = {BuildCommand.class}, + // We inherit from TestCommand so that we pick up changes like `test --test_arg=foo` in .bazelrc + // files. + // Without doing this, there is no easy way to use the output of cquery to determine whether a + // test has changed between two invocations, because the testrunner action is not easily + // introspectable. + inherits = {TestCommand.class}, options = {CqueryOptions.class}, usesConfigurationOptions = true, shortDescription = "Loads, analyzes, and queries the specified targets w/ configurations.", diff --git a/src/test/shell/integration/configured_query_test.sh b/src/test/shell/integration/configured_query_test.sh index 823a48648f922c..9e4a89d8ea41b3 100755 --- a/src/test/shell/integration/configured_query_test.sh +++ b/src/test/shell/integration/configured_query_test.sh @@ -1289,4 +1289,27 @@ EOF expect_log "@repo//:japanese" } +function test_test_arg_in_bazelrc() { + local -r pkg=$FUNCNAME + mkdir -p $pkg + + cat >$pkg/BUILD <