aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell
diff options
context:
space:
mode:
authorGravatar Brian Silverman <bsilver16384@gmail.com>2015-08-12 15:26:01 +0000
committerGravatar Florian Weikert <fwe@google.com>2015-08-13 14:01:14 +0000
commita5df40d81abafa674085c1006cdfdb36a49c38a2 (patch)
treea87a684ae646925ab8557fd64e213d4b3eda4b1e /src/test/shell
parent8c2881324d2e98bbc876b84eddd58baa98d40121 (diff)
Properly extract symlinks from tar archives.
This includes rewriting absolute symlink targets by interpreting them relative to the root of the archive. -- Change-Id: Ia6b8accd6fed3205809d621ed8984058d3b5a356 Reviewed-on: https://bazel-review.googlesource.com/#/c/1780 MOS_MIGRATED_REVID=100478005
Diffstat (limited to 'src/test/shell')
-rwxr-xr-xsrc/test/shell/bazel/external_integration_test.sh25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh
index 829ad1474f..d16e0cc3ed 100755
--- a/src/test/shell/bazel/external_integration_test.sh
+++ b/src/test/shell/bazel/external_integration_test.sh
@@ -72,10 +72,14 @@ function tar_gz_up() {
# fox/
# BUILD
# male
+# male_relative -> male
+# male_absolute -> /fox/male
function http_archive_helper() {
zipper=$1
local write_workspace
[[ $# -gt 1 ]] && [[ "$2" = "nowrite" ]] && write_workspace=1 || write_workspace=0
+ local do_symlink
+ [[ $# -gt 1 ]] && [[ "$2" = "do_symlink" ]] && do_symlink=1 || do_symlink=0
if [[ $write_workspace = 0 ]]; then
# Create a zipped-up repository HTTP response.
@@ -97,6 +101,10 @@ EOF
echo $what_does_the_fox_say
EOF
chmod +x fox/male
+ if [[ $do_symlink = 1 ]]; then
+ ln -s male fox/male_relative
+ ln -s /fox/male fox/male_absolute
+ fi
# Add some padding to the .zip to test that Bazel's download logic can
# handle breaking a response into chunks.
dd if=/dev/zero of=fox/padding bs=1024 count=10240 >& $TEST_log
@@ -135,6 +143,19 @@ fi
|| echo "Expected build/run to succeed"
kill_nc
expect_log $what_does_the_fox_say
+
+ if [[ $do_symlink = 1 ]]; then
+ if [[ -x ${realpath_path} ]]; then
+ realpath=${realpath_path}
+ else
+ realpath=realpath
+ fi
+ base_external_path=bazel-out/../external/endangered/fox
+ assert_equals $(${realpath} ${base_external_path}/male) \
+ $(${realpath} ${base_external_path}/male_relative)
+ assert_equals $(${realpath} ${base_external_path}/male) \
+ $(${realpath} ${base_external_path}/male_absolute)
+ fi
}
function test_http_archive_zip() {
@@ -157,9 +178,9 @@ EOF
}
function test_http_archive_tgz() {
- http_archive_helper tar_gz_up
+ http_archive_helper tar_gz_up "do_symlink"
bazel shutdown
- http_archive_helper tar_gz_up
+ http_archive_helper tar_gz_up "do_symlink"
}
function test_http_archive_no_server() {