aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.travis/test.sh
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-01-23 10:55:47 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-01-23 11:09:04 +0300
commiteaab5d9acf6a04b350a49b285c1fe435c1eb4b90 (patch)
tree72327d6b279c9d2711a736b2a21add87e47945bd /.travis/test.sh
parentTravis: tweak test.sh output (diff)
downloadconfig-links-eaab5d9acf6a04b350a49b285c1fe435c1eb4b90.tar.gz
config-links-eaab5d9acf6a04b350a49b285c1fe435c1eb4b90.zip
support symlinks in --shared-dir
Diffstat (limited to '')
-rwxr-xr-x.travis/test.sh50
1 files changed, 44 insertions, 6 deletions
diff --git a/.travis/test.sh b/.travis/test.sh
index ad92059..812a50f 100755
--- a/.travis/test.sh
+++ b/.travis/test.sh
@@ -38,8 +38,8 @@ new_test() {
}
verify_output() {
- if [ "$#" -ne 1 ]; then
- echo "usage: ${FUNCNAME[0]} EXPECTED_OUTPUT" >&2
+ if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
+ echo "usage: ${FUNCNAME[0]} EXPECTED_OUTPUT [DEST_DIR]" >&2
return 1
fi
@@ -47,7 +47,10 @@ verify_output() {
echo 'Expected directory structure:'
echo "$expected_output"
- actual_output="$( find "$test_dest_dir" -printf '%h/%f->%l\n' )"
+ local dest_dir="$test_dest_dir"
+ [ "$#" -ge 2 ] && dest_dir="$2"
+
+ actual_output="$( find "$dest_dir" -printf '%h/%f->%l\n' )"
echo 'Actual directory structure:'
echo "$actual_output"
@@ -65,7 +68,7 @@ test_update_works() {
cd -- "$test_root_dir"
DEST="$test_dest_dir" "$script_dir/../bin/update.sh" --shared-dir "$test_src_dir"
- expected_output="$test_dest_dir->
+ local expected_output="$test_dest_dir->
$test_dest_dir/1.txt->$test_src_dir/%DEST%/1.txt
$test_dest_dir/foo->
$test_dest_dir/foo/2.txt->$test_src_dir/%DEST%/foo/2.txt
@@ -84,7 +87,7 @@ test_unlink_works() {
DEST="$test_dest_dir" "$script_dir/../bin/update.sh" --shared-dir "$test_src_dir"
DEST="$test_dest_dir" "$script_dir/../bin/unlink.sh" --shared-dir "$test_src_dir"
- expected_output="$test_dest_dir->"
+ local expected_output="$test_dest_dir->"
verify_output "$expected_output"
}
@@ -98,17 +101,52 @@ test_unlink_does_not_overwrite_files() {
echo '+3' > "$test_dest_dir/bar/3.txt"
DEST="$test_dest_dir" "$script_dir/../bin/unlink.sh" --shared-dir "$test_src_dir"
- expected_output="$test_dest_dir->
+ local expected_output="$test_dest_dir->
$test_dest_dir/bar->
$test_dest_dir/bar/3.txt->"
verify_output "$expected_output"
}
+test_shared_directory_symlinks_work() {
+ new_test
+
+ cd -- "$test_src_dir"
+ ln -s -- '%DEST%' '%ALT_DEST%'
+ mkdir -- "$test_dest_dir-alt"
+
+ DEST="$test_dest_dir" ALT_DEST="$test_dest_dir-alt" "$script_dir/../bin/update.sh" --shared-dir "$test_src_dir"
+
+ local expected_output
+
+ expected_output="$test_dest_dir->
+$test_dest_dir/1.txt->$test_src_dir/%DEST%/1.txt
+$test_dest_dir/foo->
+$test_dest_dir/foo/2.txt->$test_src_dir/%DEST%/foo/2.txt
+$test_dest_dir/bar->
+$test_dest_dir/bar/3.txt->$test_src_dir/%DEST%/bar/3.txt
+$test_dest_dir/bar/baz->
+$test_dest_dir/bar/baz/4.txt->$test_src_dir/%DEST%/bar/baz/4.txt"
+
+ verify_output "$expected_output"
+
+ expected_output="$test_dest_dir-alt->
+$test_dest_dir-alt/1.txt->$test_src_dir/%ALT_DEST%/1.txt
+$test_dest_dir-alt/foo->
+$test_dest_dir-alt/foo/2.txt->$test_src_dir/%ALT_DEST%/foo/2.txt
+$test_dest_dir-alt/bar->
+$test_dest_dir-alt/bar/3.txt->$test_src_dir/%ALT_DEST%/bar/3.txt
+$test_dest_dir-alt/bar/baz->
+$test_dest_dir-alt/bar/baz/4.txt->$test_src_dir/%ALT_DEST%/bar/baz/4.txt"
+
+ verify_output "$expected_output" "$test_dest_dir-alt"
+}
+
main() {
test_update_works
test_unlink_works
test_unlink_does_not_overwrite_files
+ test_shared_directory_symlinks_work
}
main