1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-12 18:10:15 +00:00

test verbosity

This commit is contained in:
deadc0de6
2024-08-20 22:28:37 +02:00
committed by deadc0de
parent d7eaee66dc
commit a617b95c1d
2 changed files with 11 additions and 1 deletions

6
tests-ng/backup.sh vendored
View File

@@ -32,6 +32,8 @@ grep_or_fail()
{ {
if ! grep "${1}" "${2}" >/dev/null 2>&1; then if ! grep "${1}" "${2}" >/dev/null 2>&1; then
echo "pattern \"${1}\" not found in ${2}" echo "pattern \"${1}\" not found in ${2}"
echo "content:"
cat "${2}"
exit 1 exit 1
fi fi
} }
@@ -143,6 +145,7 @@ clear_dotpath
clear_fs clear_fs
create_dotpath create_dotpath
create_fs create_fs
echo "doing test \"${pre}\""
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --verbose cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --verbose
# checks # checks
@@ -177,6 +180,7 @@ clear_dotpath
clear_fs clear_fs
create_dotpath create_dotpath
create_fs create_fs
echo "doing test \"${pre}\""
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --verbose cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --verbose
# checks # checks
@@ -199,6 +203,7 @@ clear_dotpath
clear_fs clear_fs
create_dotpath create_dotpath
create_fs create_fs
echo "doing test \"${pre}\""
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --verbose cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --verbose
# checks # checks
@@ -221,6 +226,7 @@ clear_dotpath
clear_fs clear_fs
create_dotpath create_dotpath
create_fs create_fs
echo "doing test \"${pre}\""
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --verbose cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --verbose
# checks # checks

View File

@@ -57,6 +57,7 @@ noprofile="ALL"
################################## ##################################
# import with profile from arg # import with profile from arg
echo "import with profile from arg"
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p "${noprofile}" -V "${tmpd}"/file1 cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p "${noprofile}" -V "${tmpd}"/file1
cat "${cfg}" cat "${cfg}"
@@ -71,11 +72,13 @@ nb=$(cat "${cfg}" | grep f_file1 | wc -l)
cntpre=$(find "${tmps}"/dotfiles -type f | wc -l) cntpre=$(find "${tmps}"/dotfiles -type f | wc -l)
# reimport # reimport
echo "reimport"
set +e set +e
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p "${noprofile}" -V "${tmpd}"/file1 cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p "${noprofile}" -V "${tmpd}"/file1
set -e set -e
cat "${cfg}" cat "${cfg}"
echo "test reimport"
cntpost=$(find "${tmps}"/dotfiles -type f | wc -l) cntpost=$(find "${tmps}"/dotfiles -type f | wc -l)
[ "${cntpost}" != "${cntpre}" ] && echo "imported twice" && exit 1 [ "${cntpost}" != "${cntpre}" ] && echo "imported twice" && exit 1
@@ -84,6 +87,7 @@ nb=$(cat "${cfg}" | grep "dst: ${tmpd}/file1" | wc -l)
################################## ##################################
# import with profile from env # import with profile from env
echo "import with profile from env"
export DOTDROP_PROFILE="${noprofile}" export DOTDROP_PROFILE="${noprofile}"
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -V "${tmpd}"/file2 cd "${ddpath}" | ${bin} import -f -c "${cfg}" -V "${tmpd}"/file2
cat "${cfg}" cat "${cfg}"
@@ -91,7 +95,7 @@ cat "${cfg}"
# ensure exists and is not link # ensure exists and is not link
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/file2 ] && echo "file not imported" && exit 1 [ ! -e "${tmps}"/dotfiles/"${tmpd}"/file2 ] && echo "file not imported" && exit 1
# ensure present in config # ensure present in config
cat "${cfg}" | grep "${tmpd}"/file2 >/dev/null 2>&1 cat "${cfg}" | grep "${tmpd}"/file2 >/dev/null 2>&1 || (echo "file2 not present in config" && exit 1)
nb=$(cat "${cfg}" | grep f_file2 | wc -l) nb=$(cat "${cfg}" | grep f_file2 | wc -l)
[ "${nb}" != "1" ] && echo 'bad config' && exit 1 [ "${nb}" != "1" ] && echo 'bad config' && exit 1