aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell/integration/bazel_query_test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/shell/integration/bazel_query_test.sh')
-rwxr-xr-xsrc/test/shell/integration/bazel_query_test.sh30
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"