aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2016-03-24 14:17:24 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-03-24 20:06:16 +0000
commitf0e1ef60cad4b24105dfd22576d54e20b91ec5eb (patch)
treed17a1f4377bc655b7766ed643d448e7bfc7ce06b /src/test/shell
parent0c8daf89b780c1f559e632d0fd1169fcdeaf20ad (diff)
Add executable argument to repository_ctx.download function.
repository.download function now creates the necessary directories before downloading. Fixes #1069 Fixes #1078 -- MOS_MIGRATED_REVID=118026986
Diffstat (limited to 'src/test/shell')
-rwxr-xr-xsrc/test/shell/bazel/skylark_repository_test.sh19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/test/shell/bazel/skylark_repository_test.sh b/src/test/shell/bazel/skylark_repository_test.sh
index dd3744ae07..8cd50057fc 100755
--- a/src/test/shell/bazel/skylark_repository_test.sh
+++ b/src/test/shell/bazel/skylark_repository_test.sh
@@ -437,8 +437,10 @@ function test_skylark_repository_download() {
mkdir -p "${server_dir}"
local download_with_sha256="${server_dir}/download_with_sha256.txt"
local download_no_sha256="${server_dir}/download_no_sha256.txt"
+ local download_executable_file="${server_dir}/download_executable_file.sh"
echo "This is one file" > "${download_no_sha256}"
echo "This is another file" > "${download_with_sha256}"
+ echo "echo 'I am executable'" > "${download_executable_file}"
file_sha256="$(sha256sum "${download_with_sha256}" | head -c 64)"
# Start HTTP server with Python
@@ -448,13 +450,16 @@ function test_skylark_repository_download() {
# Our custom repository rule
cat >test.bzl <<EOF
def _impl(repository_ctx):
- repository_ctx.file("BUILD")
repository_ctx.download(
"http://localhost:${fileserver_port}/download_no_sha256.txt",
"download_no_sha256.txt")
repository_ctx.download(
"http://localhost:${fileserver_port}/download_with_sha256.txt",
"download_with_sha256.txt", "${file_sha256}")
+ repository_ctx.download(
+ "http://localhost:${fileserver_port}/download_executable_file.sh",
+ "download_executable_file.sh", True)
+ repository_ctx.file("BUILD") # necessary directories should already created by download function
repo = repository_rule(implementation=_impl, local=False)
EOF
@@ -467,6 +472,8 @@ EOF
|| fail "download_no_sha256.txt is not downloaded"
test -e "${output_base}/external/foo/download_with_sha256.txt" \
|| fail "download_with_sha256.txt is not downloaded"
+ test -e "${output_base}/external/foo/download_executable_file.sh" \
+ || fail "download_executable_file.sh is not downloaded"
# Test download
diff "${output_base}/external/foo/download_no_sha256.txt" \
"${download_no_sha256}" >/dev/null \
@@ -474,6 +481,16 @@ EOF
diff "${output_base}/external/foo/download_with_sha256.txt" \
"${download_with_sha256}" >/dev/null \
|| fail "download_with_sha256.txt is not downloaded successfully"
+ diff "${output_base}/external/foo/download_executable_file.sh" \
+ "${download_executable_file}" >/dev/null \
+ || fail "download_executable_file.sh is not downloaded successfully"
+ # Test executable
+ test ! -x "${output_base}/external/foo/download_no_sha256.txt" \
+ || fail "download_no_sha256.txt is executable"
+ test ! -x "${output_base}/external/foo/download_with_sha256.txt" \
+ || fail "download_with_sha256.txt is executable"
+ test -x "${output_base}/external/foo/download_executable_file.sh" \
+ || fail "download_executable_file.sh is not executable"
}
function test_skylark_repository_download_and_extract() {