Skip to content

Commit

Permalink
fix test_download_multiple
Browse files Browse the repository at this point in the history
This test was trying to verify that if two download locations are provided,
both are recorded in the workspace_rules_log. It also tested that the
build completed successfully; however, the latter only happened by accident,
as the testing server would blindly return 200 and only then try to read
the file---and then crash, as file1.txt does not exist; so the file returned
had to relation at all to the file served at the second (valid, but never
accessed) URL. This was uncovered when adding a checksum in preparation of
the upcoming #8607 flag flip.

As the test is only about logging, put the use of download to the intended
form that all provided URLs are valid and return a file with the correct
hash.

Change-Id: I208ebffc5a724df7a75b2bced6fafbd8f50417eb
PiperOrigin-RevId: 259486544
  • Loading branch information
aehlig authored and copybara-github committed Jul 23, 2019
1 parent a73aadf commit 5b4c0e5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/test/shell/bazel/bazel_workspaces_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,19 @@ function test_download_multiple() {
# Prepare HTTP server with Python
local server_dir="${TEST_TMPDIR}/server_dir"
mkdir -p "${server_dir}"
local file1="${server_dir}/file1.txt"
local file2="${server_dir}/file2.txt"
echo "second contents here" > "${file2}"
echo "contents here" > "${file1}"
echo "contents here" > "${file2}"
sha256=$(sha256sum "${file2}" | head -c 64)

# Start HTTP server with Python
ls -al "${server_dir}"
sha256sum "${file2}"

startup_server "${server_dir}"

set_workspace_command "repository_ctx.download([\"http://localhost:${fileserver_port}/file1.txt\",\"http://localhost:${fileserver_port}/file2.txt\"], \"out_for_list.txt\")"
set_workspace_command "repository_ctx.download([\"http://localhost:${fileserver_port}/file1.txt\",\"http://localhost:${fileserver_port}/file2.txt\"], \"out_for_list.txt\", sha256='${sha256}')"

build_and_process_log --exclude_rule "//external:local_config_cc"

Expand Down

0 comments on commit 5b4c0e5

Please sign in to comment.