diff options
Diffstat (limited to 'test/local/lib/common.sh')
| -rw-r--r-- | test/local/lib/common.sh | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/test/local/lib/common.sh b/test/local/lib/common.sh index 9179376..fd9612b 100644 --- a/test/local/lib/common.sh +++ b/test/local/lib/common.sh @@ -3,23 +3,16 @@ # For details, see https://github.com/egor-tensin/config-links # Distributed under the MIT License. -root_dir= - src_dir_name='src' dest_dir_name='dest' alt_dest_dir_name='alt_dest' -src_dir_path="$script_dir/dirs/$src_dir_name" -dest_dir_path="$script_dir/dirs/$dest_dir_name" - test_root_dir= test_src_dir= test_dest_dir= test_alt_dest_dir= -new_test() { - root_dir="$( git -C "$script_dir" rev-parse --show-toplevel )" - +test_setup() { test_root_dir="$( mktemp -d )" # mktemp returns /var/..., which is actually in /private/var/... on macOS. test_root_dir="$( readlink -e -- "$test_root_dir" )" @@ -33,20 +26,20 @@ new_test() { echo "%DEST% directory: $test_dest_dir" echo "%ALT_DEST% directory: $test_alt_dest_dir" - cp -r -- "$src_dir_path" "$test_src_dir" - cp -r -- "$dest_dir_path" "$test_dest_dir" - cp -r -- "$dest_dir_path" "$test_alt_dest_dir" + cp -r -- "$script_dir/data/$src_dir_name" "$test_src_dir" + cp -r -- "$script_dir/data/$dest_dir_name" "$test_dest_dir" + cp -r -- "$script_dir/data/$dest_dir_name" "$test_alt_dest_dir" } -new_test_symlink() { - new_test +test_setup_symlink() { + test_setup # Create a stupid symlink. ln -s -- 'bar/3.txt' "$test_src_dir/%DEST%/3_copy.txt" } -new_test_dir_symlink() { - new_test "${FUNCNAME[1]}" +test_setup_dir_symlink() { + test_setup "${FUNCNAME[1]}" # Files will get symlinks in the directory pointed to by $DEST, as well as # by $ALT_DEST. @@ -57,7 +50,7 @@ test_cleanup_default() { [ -n "$test_root_dir" ] && rm -rf -- "$test_root_dir" } -call_bin_script() { +test_run_script() { echo echo -n 'Executing script:' @@ -68,19 +61,19 @@ call_bin_script() { DEST="$test_dest_dir" ALT_DEST="$test_alt_dest_dir" "$@" --shared-dir "$test_src_dir" --database "$test_root_dir/links.bin" } -call_update() { - call_bin_script "$root_dir/bin/links-update" "$@" +test_run_update() { + test_run_script "$script_dir/../../bin/links-update" "$@" } -call_remove() { - call_bin_script "$root_dir/bin/links-remove" +test_run_remove() { + test_run_script "$script_dir/../../bin/links-remove" } -call_chmod() { - call_bin_script "$root_dir/bin/links-chmod" "$@" +test_run_chmod() { + test_run_script "$script_dir/../../bin/links-chmod" "$@" } -verify_output() { +test_verify_output() { if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then echo "usage: ${FUNCNAME[0]} EXPECTED_OUTPUT [DEST_DIR]" >&2 return 1 @@ -109,7 +102,7 @@ verify_output() { fi } -verify_mode() { +test_verify_mode() { if [ "$#" -ne 2 ]; then echo "usage: ${FUNCNAME[0]} EXPECTED_MODE FILE" >&2 return 1 |
