Skip to content

Commit

Permalink
skylark_repository_test: remove tests asserting downloads without che…
Browse files Browse the repository at this point in the history
…cksum

...over plain http to work. With the #8607 flag flip we
will be explicitly disallowing them.

Change-Id: I67e33cef57389656200b49e2d87fc372b813e3f6
PiperOrigin-RevId: 259687765
  • Loading branch information
aehlig authored and copybara-github committed Jul 24, 2019
1 parent cd4d195 commit 7bed9fa
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/test/shell/bazel/skylark_repository_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -910,12 +910,11 @@ function test_skylark_repository_download() {
local server_dir="${TEST_TMPDIR}/server_dir"
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 "This is a file" > "${download_with_sha256}"
echo "echo 'I am executable'" > "${download_executable_file}"
file_sha256="$(sha256sum "${download_with_sha256}" | head -c 64)"
file_exec_sha256="$(sha256sum "${download_executable_file}" | head -c 64)"

# Start HTTP server with Python
startup_server "${server_dir}"
Expand All @@ -924,15 +923,12 @@ function test_skylark_repository_download() {
# Our custom repository rule
cat >test.bzl <<EOF
def _impl(repository_ctx):
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", executable=True)
"download_executable_file.sh", executable=True, sha256="$file_exec_sha256")
repository_ctx.file("BUILD") # necessary directories should already created by download function
repo = repository_rule(implementation=_impl, local=False)
EOF
Expand All @@ -942,25 +938,18 @@ EOF

output_base="$(bazel info output_base)"
# Test download
test -e "${output_base}/external/foo/download_no_sha256.txt" \
|| 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 \
|| fail "download_no_sha256.txt is not downloaded successfully"
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" \
Expand Down

0 comments on commit 7bed9fa

Please sign in to comment.