diff --git a/src/test/shell/bazel/skylark_repository_test.sh b/src/test/shell/bazel/skylark_repository_test.sh index ce3d635c33bb32..74bace4bc3eb05 100755 --- a/src/test/shell/bazel/skylark_repository_test.sh +++ b/src/test/shell/bazel/skylark_repository_test.sh @@ -1036,13 +1036,11 @@ function test_skylark_repository_download_args() { # Prepare HTTP server with Python 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 "echo 'I am executable'" > "${download_executable_file}" - file_sha256="$(sha256sum "${download_with_sha256}" | head -c 64)" + local download_1="${server_dir}/download_1.txt" + local download_2="${server_dir}/download_2.txt" + echo "The file's content" > "${download_1}" + echo "The file's content" > "${download_2}" + file_sha256="$(sha256sum "${download_1}" | head -c 64)" # Start HTTP server with Python startup_server "${server_dir}" @@ -1057,9 +1055,10 @@ function test_skylark_repository_download_args() { load('//:test.bzl', 'repo') repo(name = 'foo', urls = [ - "http://localhost:${fileserver_port}/download_no_sha256.txt", - "http://localhost:${fileserver_port}/download_with_sha256.txt", + "http://localhost:${fileserver_port}/download_1.txt", + "http://localhost:${fileserver_port}/download_2.txt", ], + sha256 = "${file_sha256}", output = "whatever.txt" ) EOF @@ -1068,11 +1067,19 @@ EOF cat >test.bzl < x/BUILD echo 'Hello World' > x/file.txt tar cvf x.tar x + sha256="$(sha256sum x.tar | head -c 64)" serve_file_auth x.tar cat >> $(create_workspace_with_default_repos WORKSPACE) < auth.bzl <<'EOF' def _impl(ctx): ctx.download_and_extract( url = ctx.attr.url, + sha256 = ctx.attr.sha256, # Use the username/password pair hard-coded # in the testing server. auth = {ctx.attr.url : { "type": "basic", @@ -1523,7 +1536,7 @@ def _impl(ctx): with_auth = repository_rule( implementation = _impl, - attrs = { "url" : attr.string() } + attrs = { "url" : attr.string(), "sha256" : attr.string() } ) EOF cat > BUILD <<'EOF' @@ -1767,6 +1780,7 @@ function test_http_archive_netrc() { echo 'exports_files(["file.txt"])' > x/BUILD echo 'Hello World' > x/file.txt tar cvf x.tar x + sha256=$(sha256sum x.tar | head -c 64) serve_file_auth x.tar cat > WORKSPACE < .netrc <<'EOF' @@ -1798,6 +1813,7 @@ function test_implicit_netrc() { echo 'exports_files(["file.txt"])' > x/BUILD echo 'Hello World' > x/file.txt tar cvf x.tar x + sha256=$(sha256sum x.tar | head -c 64) serve_file_auth x.tar export HOME=`pwd` @@ -1814,6 +1830,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name="ext", url = "http://127.0.0.1:$nc_port/x.tar", + sha256="$sha256", ) EOF cat > BUILD <<'EOF'