diff options
Diffstat (limited to 'src/test/shell')
-rwxr-xr-x | src/test/shell/integration/bazel_query_test.sh | 45 |
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 } |