aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell/bazel/local_repository_test.sh
diff options
context:
space:
mode:
authorGravatar Alex Humesky <ahumesky@google.com>2016-02-12 00:23:16 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-02-12 09:15:03 +0000
commitde655af4a7f7a3e340365fbd9f48815ff388d70b (patch)
tree92fae3ded22f774769bd11876249a71f33a5280c /src/test/shell/bazel/local_repository_test.sh
parent3a19bda92bc3af164478ee3884642ee9d0a1b7b5 (diff)
Adds a build_file_content attribute to new_git_repository, new_http_archive, and
new_local_repository which allows the build file to be specified by a string directly in the rule rather than using a separate file. build_file and build_file_content are both optional, but one or the other must be specified. RELNOTES: build_file_content attribute added to new_git_repository, new_http_archive, and new_local_repository. -- MOS_MIGRATED_REVID=114490435
Diffstat (limited to 'src/test/shell/bazel/local_repository_test.sh')
-rwxr-xr-xsrc/test/shell/bazel/local_repository_test.sh44
1 files changed, 34 insertions, 10 deletions
diff --git a/src/test/shell/bazel/local_repository_test.sh b/src/test/shell/bazel/local_repository_test.sh
index 82874f09ab..0546bc47b8 100755
--- a/src/test/shell/bazel/local_repository_test.sh
+++ b/src/test/shell/bazel/local_repository_test.sh
@@ -187,7 +187,15 @@ EOF
expect_log "no such package '@common//carnivore'"
}
-function test_new_local_repository() {
+function test_new_local_repository_with_build_file() {
+ do_new_local_repository_test "build_file"
+}
+
+function test_new_local_repository_with_build_file_content() {
+ do_new_local_repository_test "build_file_content"
+}
+
+function do_new_local_repository_test() {
bazel clean
# Create a non-Bazel directory.
@@ -210,8 +218,9 @@ public class Mongoose {
}
EOF
- build_file=BUILD.carnivore
- cat > WORKSPACE <<EOF
+ if [ "$1" == "build_file" ] ; then
+ build_file=BUILD.carnivore
+ cat > WORKSPACE <<EOF
new_local_repository(
name = 'endangered',
path = '$project_dir',
@@ -219,6 +228,28 @@ new_local_repository(
)
EOF
+ cat > $build_file <<EOF
+java_library(
+ name = "mongoose",
+ srcs = ["carnivore/Mongoose.java"],
+ visibility = ["//visibility:public"],
+)
+EOF
+ else
+ cat > WORKSPACE <<EOF
+new_local_repository(
+ name = 'endangered',
+ path = '$project_dir',
+ build_file_content = """
+java_library(
+ name = "mongoose",
+ srcs = ["carnivore/Mongoose.java"],
+ visibility = ["//visibility:public"],
+)""",
+)
+EOF
+ fi
+
mkdir -p zoo
cat > zoo/BUILD <<EOF
java_binary(
@@ -239,13 +270,6 @@ public class BallPit {
}
EOF
- cat > $build_file <<EOF
-java_library(
- name = "mongoose",
- srcs = ["carnivore/Mongoose.java"],
- visibility = ["//visibility:public"],
-)
-EOF
bazel fetch //zoo:ball-pit || fail "Fetch failed"
bazel run //zoo:ball-pit >& $TEST_log || fail "Failed to build/run zoo"
expect_log "Tra-la!"