aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rwxr-xr-x.travis/test.sh50
-rw-r--r--src/db.sh4
2 files changed, 46 insertions, 8 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
diff --git a/src/db.sh b/src/db.sh
index a4a37a5..990d0a1 100644
--- a/src/db.sh
+++ b/src/db.sh
@@ -213,8 +213,8 @@ link_all_entries() {
is_dry_run || link_entry "$entry"
fi
- done < <( find "$shared_root_dir$shared_var_dir" -type f -print0 )
- done < <( find "$shared_root_dir" -regextype posix-basic -mindepth 1 -maxdepth 1 -type d -regex ".*/$var_name_regex\$" -printf '%P\0' )
+ done < <( find "$shared_root_dir$shared_var_dir/" -type f -print0 )
+ done < <( find "$shared_root_dir" -regextype posix-basic -mindepth 1 -maxdepth 1 -\( -type d -o -type l -\) -regex ".*/$var_name_regex\$" -printf '%P\0' )
}
unlink_all_entries() {