Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cquery inherits from test not build #13491

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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},
gregestren marked this conversation as resolved.
Show resolved Hide resolved
options = {CqueryOptions.class},
usesConfigurationOptions = true,
shortDescription = "Loads, analyzes, and queries the specified targets w/ configurations.",
Expand Down
23 changes: 23 additions & 0 deletions src/test/shell/integration/configured_query_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
sh_test(
name = "test",
srcs = ["test.sh"],
)
EOF

touch $pkg/test.sh
chmod +x $pkg/test.sh

output_before="$(bazel cquery "//$pkg:test")"

add_to_bazelrc "test --test_arg=foo"

output_after="$(bazel cquery "//$pkg:test")"

assert_not_equals "${output_before}" "${output_after}"
}

run_suite "${PRODUCT_NAME} configured query tests"