aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell
diff options
context:
space:
mode:
authorGravatar John Cater <jcater@google.com>2017-12-04 07:53:19 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-12-04 07:55:32 -0800
commite5fb5f07ba9fe0dc40fc2d6039973dab5794f876 (patch)
tree96835f310868674e5ea02d41690233c5502f819d /src/test/shell
parent8e9b2895763eb9c38b0307fdff3268c0eee221a2 (diff)
Fix getBuildFiles to not assume BUILD is the name of the build file.
Fixes #4056. Change-Id: Ia7425c2146f15e9293605ee3da53007805e82275 PiperOrigin-RevId: 177813070
Diffstat (limited to 'src/test/shell')
-rwxr-xr-xsrc/test/shell/integration/bazel_query_test.sh45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/test/shell/integration/bazel_query_test.sh b/src/test/shell/integration/bazel_query_test.sh
index eed50de082..f5de27c8e5 100755
--- a/src/test/shell/integration/bazel_query_test.sh
+++ b/src/test/shell/integration/bazel_query_test.sh
@@ -26,6 +26,7 @@ add_to_bazelrc "build --package_path=%workspace%"
#### TESTS #############################################################
function test_does_not_fail_horribly() {
+ rm -rf peach
mkdir -p peach
cat > peach/BUILD <<EOF
sh_library(name='brighton', deps=[':harken'])
@@ -39,6 +40,7 @@ EOF
}
function test_visibility_affects_xml_output() {
+ rm -rf kiwi
mkdir -p kiwi
cat > kiwi/BUILD <<EOF
@@ -71,6 +73,7 @@ EOF
}
function test_visibility_affects_proto_output() {
+ rm -rf kiwi
mkdir -p kiwi
cat > kiwi/BUILD <<EOF
@@ -97,6 +100,8 @@ EOF
}
function make_depth_tests() {
+ rm -rf depth
+ rm -rf depth2
mkdir -p depth depth2 || die "Could not create test directory"
cat > "depth/BUILD" <<EOF
sh_binary(name = 'one', srcs = ['one.sh'], deps = [':two'])
@@ -154,6 +159,7 @@ function test_depth_query_idempotence_unordered() {
}
function test_universe_scope_with_without_star() {
+ rm -rf foo
mkdir -p foo || fail "Couldn't mkdir"
echo "sh_library(name = 'foo')" > foo/BUILD || fail "Couldn't write BUILD"
bazel query --order_output=no \
@@ -171,6 +177,8 @@ function test_universe_scope_with_without_star() {
}
function test_outside_universe_ok() {
+ rm -rf foo
+ rm -rf bar
mkdir -p foo bar || fail "Couldn't mkdir"
echo "sh_library(name = 'foo', deps = ['//bar:bar'])" > foo/BUILD ||
fail "Couldn't write BUILD"
@@ -209,6 +217,8 @@ function test_minrank_le_depth_bound() {
}
function test_skylark_dep_in_sky_query() {
+ rm -rf foo
+ rm -rf bar
mkdir -p foo bar || fail "Couldn't make directories"
echo 'load("//bar:fakerule.bzl", "const")' > foo/BUILD || fail "Couldn't write"
touch bar/BUILD || fail "Couldn't touch bar/BUILD"
@@ -221,6 +231,7 @@ function test_skylark_dep_in_sky_query() {
}
function test_skylark_regular_file_not_included_in_rbuildfiles() {
+ rm -rf foo
mkdir -p foo || fail "Couldn't make directories"
echo "baz" > "foo/baz.bzl" || fail "Couldn't create baz.bzl"
echo 'sh_library(name = "foo", srcs = ["baz.bzl"])' > foo/BUILD
@@ -233,6 +244,7 @@ function test_skylark_regular_file_not_included_in_rbuildfiles() {
}
function test_skylark_symlink_source_not_included_in_rbuildfiles() {
+ rm -rf foo
mkdir -p foo || fail "Couldn't make directories"
echo "moo" > "foo/moo" || fail "Couldn't create moo"
ln -s "foo/moo" "foo/baz.bzl" || fail "Couldn't create baz.bzl symlink"
@@ -246,6 +258,7 @@ function test_skylark_symlink_source_not_included_in_rbuildfiles() {
}
function test_skylark_symlink_target_not_included_in_rbuildfiles() {
+ rm -rf foo
mkdir -p foo || fail "Couldn't make directories"
echo "baz" > "foo/baz.bzl" || fail "Couldn't create baz.bzl"
ln -s "foo/baz.bzl" "foo/Moo.java" || fail "Couldn't create Moo.java symlink"
@@ -259,6 +272,7 @@ function test_skylark_symlink_target_not_included_in_rbuildfiles() {
}
function test_skylark_glob_regular_file_not_included_in_rbuildfiles() {
+ rm -rf foo
mkdir -p foo || fail "Couldn't make directories"
echo "baz" > "foo/baz.bzl" || fail "Couldn't create baz.bzl"
echo 'sh_library(name = "foo", srcs = glob(["*.bzl"]))' > foo/BUILD
@@ -271,6 +285,7 @@ function test_skylark_glob_regular_file_not_included_in_rbuildfiles() {
}
function test_skylark_glob_symlink_source_not_included_in_rbuildfiles() {
+ rm -rf foo
mkdir -p foo || fail "Couldn't make directories"
echo "moo" > "foo/moo" || fail "Couldn't create moo"
ln -s "foo/moo" "foo/baz.bzl" || fail "Couldn't create baz.bzl symlink"
@@ -284,6 +299,7 @@ function test_skylark_glob_symlink_source_not_included_in_rbuildfiles() {
}
function test_skylark_glob_symlink_target_not_included_in_rbuildfiles() {
+ rm -rf foo
mkdir -p foo || fail "Couldn't make directories"
echo "baz" > "foo/baz.bzl" || fail "Couldn't create baz.bzl"
ln -s "foo/baz.bzl" "foo/Moo.java" || fail "Couldn't create Moo.java symlink"
@@ -297,6 +313,7 @@ function test_skylark_glob_symlink_target_not_included_in_rbuildfiles() {
}
function test_skylark_recursive_glob_regular_file_not_included_in_rbuildfiles() {
+ rm -rf foo
mkdir -p foo/bar || fail "Couldn't make directories"
echo "baz" > "foo/bar/baz.bzl" || fail "Couldn't create baz.bzl"
echo 'sh_library(name = "foo", srcs = glob(["**/*.bzl"]))' > foo/BUILD
@@ -309,6 +326,7 @@ function test_skylark_recursive_glob_regular_file_not_included_in_rbuildfiles()
}
function test_skylark_recursive_glob_symlink_source_not_included_in_rbuildfiles() {
+ rm -rf foo
mkdir -p foo/bar || fail "Couldn't make directories"
echo "moo" > "foo/moo" || fail "Couldn't create moo"
ln -s "foo/moo" "foo/bar/baz.bzl" || fail "Couldn't create baz.bzl symlink"
@@ -322,6 +340,7 @@ function test_skylark_recursive_glob_symlink_source_not_included_in_rbuildfiles(
}
function test_skylark_recursive_glob_symlink_target_not_included_in_rbuildfiles() {
+ rm -rf foo
mkdir -p foo/bar || fail "Couldn't make directories"
echo "baz" > "foo/bar/baz.bzl" || fail "Couldn't create baz.bzl"
ln -s "foo/bar/baz.bzl" "foo/Moo.java" || fail "Couldn't create Moo.java symlink"
@@ -335,6 +354,7 @@ function test_skylark_recursive_glob_symlink_target_not_included_in_rbuildfiles(
}
function test_skylark_subdir_dep_in_sky_query() {
+ rm -rf foo
mkdir -p foo bar/baz || fail "Couldn't make directories"
echo 'load("//bar:baz/fakerule.bzl", "const")' > foo/BUILD || fail "Couldn't write"
touch bar/BUILD || fail "Couldn't touch bar/BUILD"
@@ -347,6 +367,7 @@ function test_skylark_subdir_dep_in_sky_query() {
}
function test_parent_independent_of_child() {
+ rm -rf foo
mkdir -p foo/subdir || fail "Couldn't make directories"
echo 'sh_library(name = "sh", data = glob(["**"]))' > foo/BUILD ||
fail "Couldn't write"
@@ -358,6 +379,7 @@ function test_parent_independent_of_child() {
}
function test_does_not_fail_horribly_with_file() {
+ rm -rf peach
mkdir -p peach
cat > peach/BUILD <<EOF
sh_library(name='brighton', deps=[':harken'])
@@ -372,7 +394,8 @@ EOF
}
function test_location_output_not_allowed_with_buildfiles_or_loadfiles() {
- mkdir foo
+ rm -rf foo
+ mkdir -p foo
cat > foo/bzl.bzl <<EOF
x = 2
EOF
@@ -414,6 +437,26 @@ EOF
expect_log "//foo/bar:t2"
}
+function test_buildfiles_with_build_bazel() {
+ if [ "${PRODUCT_NAME}" != "bazel" ]; then
+ return 0
+ fi
+ rm -rf foo
+ mkdir -p foo
+ cat > foo/bzl.bzl <<EOF
+x = 2
+EOF
+ cat > foo/BUILD.bazel <<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$"
+ expect_log "//foo:BUILD.bazel$"
+ expect_not_log "//foo:BUILD$"
+}
+
function tear_down() {
bazel shutdown
}