From 975b4d7558995969771a1c8e967abccdb934ab8a Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 23 Jan 2020 11:20:21 +0300 Subject: Travis: refactor tests a bit --- .travis/dest/1.txt | 1 + .travis/dest/bar/3.txt | 1 + .travis/sample-dest/1.txt | 1 - .travis/sample-dest/bar/3.txt | 1 - .travis/sample-src/%DEST%/1.txt | 1 - .travis/sample-src/%DEST%/bar/3.txt | 1 - .travis/sample-src/%DEST%/bar/baz/4.txt | 1 - .travis/sample-src/%DEST%/foo/2.txt | 1 - .travis/src/%DEST%/1.txt | 1 + .travis/src/%DEST%/bar/3.txt | 1 + .travis/src/%DEST%/bar/baz/4.txt | 1 + .travis/src/%DEST%/foo/2.txt | 1 + .travis/test.sh | 53 ++++++++++++++++----------------- 13 files changed, 32 insertions(+), 33 deletions(-) create mode 100644 .travis/dest/1.txt create mode 100644 .travis/dest/bar/3.txt delete mode 100644 .travis/sample-dest/1.txt delete mode 100644 .travis/sample-dest/bar/3.txt delete mode 100644 .travis/sample-src/%DEST%/1.txt delete mode 100644 .travis/sample-src/%DEST%/bar/3.txt delete mode 100644 .travis/sample-src/%DEST%/bar/baz/4.txt delete mode 100644 .travis/sample-src/%DEST%/foo/2.txt create mode 100644 .travis/src/%DEST%/1.txt create mode 100644 .travis/src/%DEST%/bar/3.txt create mode 100644 .travis/src/%DEST%/bar/baz/4.txt create mode 100644 .travis/src/%DEST%/foo/2.txt diff --git a/.travis/dest/1.txt b/.travis/dest/1.txt new file mode 100644 index 0000000..3a2e3f4 --- /dev/null +++ b/.travis/dest/1.txt @@ -0,0 +1 @@ +-1 diff --git a/.travis/dest/bar/3.txt b/.travis/dest/bar/3.txt new file mode 100644 index 0000000..a83d1d5 --- /dev/null +++ b/.travis/dest/bar/3.txt @@ -0,0 +1 @@ +-3 diff --git a/.travis/sample-dest/1.txt b/.travis/sample-dest/1.txt deleted file mode 100644 index 3a2e3f4..0000000 --- a/.travis/sample-dest/1.txt +++ /dev/null @@ -1 +0,0 @@ --1 diff --git a/.travis/sample-dest/bar/3.txt b/.travis/sample-dest/bar/3.txt deleted file mode 100644 index a83d1d5..0000000 --- a/.travis/sample-dest/bar/3.txt +++ /dev/null @@ -1 +0,0 @@ --3 diff --git a/.travis/sample-src/%DEST%/1.txt b/.travis/sample-src/%DEST%/1.txt deleted file mode 100644 index d00491f..0000000 --- a/.travis/sample-src/%DEST%/1.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/.travis/sample-src/%DEST%/bar/3.txt b/.travis/sample-src/%DEST%/bar/3.txt deleted file mode 100644 index 00750ed..0000000 --- a/.travis/sample-src/%DEST%/bar/3.txt +++ /dev/null @@ -1 +0,0 @@ -3 diff --git a/.travis/sample-src/%DEST%/bar/baz/4.txt b/.travis/sample-src/%DEST%/bar/baz/4.txt deleted file mode 100644 index b8626c4..0000000 --- a/.travis/sample-src/%DEST%/bar/baz/4.txt +++ /dev/null @@ -1 +0,0 @@ -4 diff --git a/.travis/sample-src/%DEST%/foo/2.txt b/.travis/sample-src/%DEST%/foo/2.txt deleted file mode 100644 index 0cfbf08..0000000 --- a/.travis/sample-src/%DEST%/foo/2.txt +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/.travis/src/%DEST%/1.txt b/.travis/src/%DEST%/1.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.travis/src/%DEST%/1.txt @@ -0,0 +1 @@ +1 diff --git a/.travis/src/%DEST%/bar/3.txt b/.travis/src/%DEST%/bar/3.txt new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/.travis/src/%DEST%/bar/3.txt @@ -0,0 +1 @@ +3 diff --git a/.travis/src/%DEST%/bar/baz/4.txt b/.travis/src/%DEST%/bar/baz/4.txt new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/.travis/src/%DEST%/bar/baz/4.txt @@ -0,0 +1 @@ +4 diff --git a/.travis/src/%DEST%/foo/2.txt b/.travis/src/%DEST%/foo/2.txt new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/.travis/src/%DEST%/foo/2.txt @@ -0,0 +1 @@ +2 diff --git a/.travis/test.sh b/.travis/test.sh index 812a50f..a61badd 100755 --- a/.travis/test.sh +++ b/.travis/test.sh @@ -8,33 +8,38 @@ readonly script_dir script_name="$( basename -- "${BASH_SOURCE[0]}" )" readonly script_name -readonly sample_src_dir_name='sample-src' -readonly sample_dest_dir_name='sample-dest' +readonly src_dir_name='src' +readonly dest_dir_name='dest' +readonly alt_dest_dir_name='alt_dest' -sample_src_dir_path="$script_dir/$sample_src_dir_name" -readonly sample_src_dir_path -sample_dest_dir_path="$script_dir/$sample_dest_dir_name" -readonly sample_dest_dir_path +src_dir_path="$script_dir/$src_dir_name" +readonly src_dir_path +dest_dir_path="$script_dir/$dest_dir_name" +readonly dest_dir_path test_root_dir= test_src_dir= test_dest_dir= +test_alt_dest_dir= new_test() { echo echo 'New test' test_root_dir="$( mktemp --directory )" - test_src_dir="$test_root_dir/$sample_src_dir_name" - test_dest_dir="$test_root_dir/$sample_dest_dir_name" + test_src_dir="$test_root_dir/$src_dir_name" + test_dest_dir="$test_root_dir/$dest_dir_name" + test_alt_dest_dir="$test_root_dir/$alt_dest_dir_name" echo "Root directory: $test_root_dir" echo "Shared directory: $test_src_dir" echo "%DEST% directory: $test_dest_dir" + echo "%ALT_DEST% directory: $test_alt_dest_dir" echo - cp -r -- "$sample_src_dir_path" "$test_src_dir" - cp -r -- "$sample_dest_dir_path" "$test_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" } verify_output() { @@ -65,7 +70,6 @@ verify_output() { test_update_works() { new_test - cd -- "$test_root_dir" DEST="$test_dest_dir" "$script_dir/../bin/update.sh" --shared-dir "$test_src_dir" local expected_output="$test_dest_dir-> @@ -83,7 +87,6 @@ $test_dest_dir/bar/baz/4.txt->$test_src_dir/%DEST%/bar/baz/4.txt" test_unlink_works() { new_test - cd -- "$test_root_dir" 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" @@ -95,7 +98,6 @@ test_unlink_works() { test_unlink_does_not_overwrite_files() { new_test - cd -- "$test_root_dir" DEST="$test_dest_dir" "$script_dir/../bin/update.sh" --shared-dir "$test_src_dir" rm -- "$test_dest_dir/bar/3.txt" echo '+3' > "$test_dest_dir/bar/3.txt" @@ -111,11 +113,8 @@ $test_dest_dir/bar/3.txt->" 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" + ln -s -- '%DEST%' "$test_src_dir/%ALT_DEST%" + DEST="$test_dest_dir" ALT_DEST="$test_alt_dest_dir" "$script_dir/../bin/update.sh" --shared-dir "$test_src_dir" local expected_output @@ -130,16 +129,16 @@ $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" + expected_output="$test_alt_dest_dir-> +$test_alt_dest_dir/1.txt->$test_src_dir/%ALT_DEST%/1.txt +$test_alt_dest_dir/foo-> +$test_alt_dest_dir/foo/2.txt->$test_src_dir/%ALT_DEST%/foo/2.txt +$test_alt_dest_dir/bar-> +$test_alt_dest_dir/bar/3.txt->$test_src_dir/%ALT_DEST%/bar/3.txt +$test_alt_dest_dir/bar/baz-> +$test_alt_dest_dir/bar/baz/4.txt->$test_src_dir/%ALT_DEST%/bar/baz/4.txt" - verify_output "$expected_output" "$test_dest_dir-alt" + verify_output "$expected_output" "$test_alt_dest_dir" } main() { -- cgit v1.2.3