From 4967468d71b0181c8678c064803ef772a50bc910 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Mon, 7 Aug 2023 23:38:15 +0200 Subject: [PATCH] tests --- tests-ng/import-negative-ignore-all-but.sh | 14 +++++++------- tests-ng/include-order.sh | 2 ++ tests-ng/update-ignore-missing.sh | 7 ++++--- tests-ng/update.sh | 4 +++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/tests-ng/import-negative-ignore-all-but.sh b/tests-ng/import-negative-ignore-all-but.sh index 9ac4e2e..cf030e0 100755 --- a/tests-ng/import-negative-ignore-all-but.sh +++ b/tests-ng/import-negative-ignore-all-but.sh @@ -62,9 +62,9 @@ config: dotpath: dotfiles impignore: - "*" - - "!*/c" - - "!*/d" - - "!*/x" + - "!*/c/**" + - "!*/d/**" + - "!*/x/**" dotfiles: profiles: p1: @@ -79,10 +79,10 @@ cd "${ddpath}" | ${bin} import -f -c "${cfg}" --verbose --profile=p1 "${tmpd}/a/ cd "${ddpath}" | ${bin} import -f -c "${cfg}" --verbose --profile=p1 "${tmpd}/a/x" set -e -[ -d "${basedir}/dotfiles/a/b" ] && (echo "/a/b created" && exit 1) -grep_or_fail "updated" "${basedir}/dotfiles/a/c/acfile" -grep_or_fail "updated" "${basedir}/dotfiles/a/d/adfile" -grep_or_fail "updated" "${basedir}/dotfiles/a/x/axfile" +[ -d "${basedir}/dotfiles/${tmpd}/a/b" ] && (echo "/a/b created" && exit 1) +grep_or_fail "updated" "${basedir}/dotfiles/${tmpd}/a/c/acfile" +grep_or_fail "updated" "${basedir}/dotfiles/${tmpd}/a/d/adfile" +grep_or_fail "updated" "${basedir}/dotfiles/${tmpd}/a/x/axfile" echo "OK" exit 0 diff --git a/tests-ng/include-order.sh b/tests-ng/include-order.sh index f9435d0..ee24b57 100755 --- a/tests-ng/include-order.sh +++ b/tests-ng/include-order.sh @@ -86,7 +86,9 @@ _EOF # create the source mkdir -p "${tmps}"/dotfiles/ echo "first" > "${tmps}"/dotfiles/first +sleep 1 echo "second" > "${tmps}"/dotfiles/second +sleep 1 echo "third" > "${tmps}"/dotfiles/third attempts="3" diff --git a/tests-ng/update-ignore-missing.sh b/tests-ng/update-ignore-missing.sh index d4c4e03..5c9f2a7 100755 --- a/tests-ng/update-ignore-missing.sh +++ b/tests-ng/update-ignore-missing.sh @@ -36,6 +36,7 @@ tmpd=$(mktemp -d --suffix='-dotdrop-tests-dest' || mktemp -d) cp -r "${dt}"/folder "${tmpd}"/ touch "${tmpd}"/folder/b mkdir "${tmpd}"/folder/c +touch "${tmpd}"/folder/c/cfile clear_on_exit "${tmps}" clear_on_exit "${tmpd}" @@ -68,12 +69,12 @@ _EOF echo "[+] test with no ignore-missing setting" cd "${ddpath}" | ${bin} update -f -c "${cfg}" --verbose --profile=p1 --key thedotfile -[ ! -e "${dt}"/folder/b ] && echo "should have been updated" && exit 1 -[ ! -e "${dt}"/folder/c ] && echo "should have been updated" && exit 1 +[ ! -e "${dt}"/folder/b ] && echo "${dt}/folder/b should have been updated" && exit 1 +[ ! -e "${dt}"/folder/c/cfile ] && echo "${dt}/folder/c/cfile should have been updated" && exit 1 # Reset rm "${dt}"/folder/b -rmdir "${dt}"/folder/c +rm -rf "${dt}"/folder/c # # Test with command-line flag diff --git a/tests-ng/update.sh b/tests-ng/update.sh index 527b243..1915109 100755 --- a/tests-ng/update.sh +++ b/tests-ng/update.sh @@ -104,7 +104,9 @@ rm "${basedir}"/dotfiles/"${tmpd}"/dir1/file_in_dir1 mkdir -p "${basedir}"/dotfiles/"${tmpd}"/dir1/file_in_dir1 # ensure changes applied correctly -diff "${tmpd}"/dir1 "${basedir}"/dotfiles/"${tmpd}"/dir1 +echo "diff dir1" +diff -r --suppress-common-lines "${tmpd}"/dir1 "${basedir}"/dotfiles/"${tmpd}"/dir1 +echo "diff uniquefile" diff "${tmpd}"/uniquefile "${basedir}"/dotfiles/"${tmpd}"/uniquefile [ ! -e "${basedir}"/dotfiles/"${tmpd}"/dir1/sub1/sub2/sub3/file ] && echo "sub does not exist" && exit 1