diff options
author | nharmata <nharmata@google.com> | 2017-06-16 21:14:10 +0200 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2017-06-19 18:23:44 +0200 |
commit | 9e26369575f04776c0416fd75a9434a22b4d5e9a (patch) | |
tree | 6e7cb5b75d5d766586a3e9bf51bb5affee8e9e7d /src/test/shell | |
parent | b1b794ba78d9f1ccfd013fd56c62c737ec14a4d4 (diff) |
Ban the combination of buildfiles/loadfiles and --output=location.
RELNOTES[INC]: The --output=location flag to 'bazel query' cannot be used with query expressions that involve the 'buildfiles' or 'loadfiles' operators. This also applies to 'genquery' rules.
PiperOrigin-RevId: 159259061
Diffstat (limited to 'src/test/shell')
-rwxr-xr-x | src/test/shell/integration/bazel_query_test.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/shell/integration/bazel_query_test.sh b/src/test/shell/integration/bazel_query_test.sh index b009adb147..0342370dfd 100755 --- a/src/test/shell/integration/bazel_query_test.sh +++ b/src/test/shell/integration/bazel_query_test.sh @@ -257,4 +257,34 @@ EOF expect_log "//peach:harken" } +function test_location_output_not_allowed_with_buildfiles_or_loadfiles() { + mkdir foo + cat > foo/bzl.bzl <<EOF +x = 2 +EOF + cat > foo/BUILD <<EOF +load('//foo:bzl.bzl', 'x') +sh_library(name='foo') +EOF + + bazel query 'buildfiles(//foo)' >& $TEST_log || fail "Expected success" + expect_log "//foo:bzl.bzl" + bazel query 'loadfiles(//foo)' >& $TEST_log || fail "Expected success" + expect_log "//foo:bzl.bzl" + bazel query --output=location '//foo' >& $TEST_log || fail "Expected success" + expect_log "//foo:foo" + + local expected_error_msg="Query expressions involving 'buildfiles' or 'loadfiles' cannot be used with --output=location" + local expected_exit_code=2 + for query_string in 'buildfiles(//foo)' 'loadfiles(//foo)' + do + bazel query --output=location "$query_string" >& $TEST_log \ + && fail "Expected failure" + exit_code=$? + expect_log "$expected_error_msg" + assert_equals "$expected_exit_code" "$exit_code" + done +} + + run_suite "${PRODUCT_NAME} query tests" |