From f4cff17f1bb3bb8a60602a572b2de135cf0cf169 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Tue, 19 Oct 2021 22:18:39 +0200 Subject: [PATCH] add tests cleaning --- tests-ng/actions-args-template.sh | 7 ++-- tests-ng/actions-args.sh | 7 ++-- tests-ng/actions-default.sh | 7 ++-- tests-ng/actions-empty-dir.sh | 7 ++-- tests-ng/actions-pre.sh | 7 ++-- tests-ng/actions-template.sh | 7 ++-- tests-ng/actions.sh | 7 ++-- tests-ng/chmod-compare.sh | 6 ++-- tests-ng/chmod-import.sh | 6 ++-- tests-ng/chmod-install.sh | 6 ++-- tests-ng/chmod-more.sh | 6 ++-- tests-ng/chmod-update.sh | 6 ++-- tests-ng/compare-ignore-missing.sh | 6 ++-- tests-ng/compare-ignore-relative.sh | 6 ++-- tests-ng/compare-ignore.sh | 6 ++-- tests-ng/compare-negative-ignore-relative.sh | 6 ++-- tests-ng/compare-negative-ignore.sh | 6 ++-- tests-ng/compare-profile-check.sh | 6 ++-- tests-ng/compare.sh | 6 ++-- tests-ng/corner-case.sh | 12 ++++--- tests-ng/deprecated-link.sh | 6 ++-- tests-ng/diff-cmd.sh | 6 ++-- tests-ng/dir-import-update.sh | 6 ++-- tests-ng/dotdrop-variables.sh | 6 ++-- tests-ng/dotfile-no-src.sh | 6 ++-- tests-ng/dotfile-sub-variables.sh | 6 ++-- tests-ng/dotfile-variables.sh | 6 ++-- tests-ng/dotfiles-all.sh | 6 ++-- tests-ng/dotfiles-dyn-paths.sh | 6 ++-- tests-ng/dry.sh | 8 +++-- tests-ng/duplicate-key.sh | 6 ++-- tests-ng/dynactions.sh | 7 ++-- tests-ng/dyndotfilepaths.sh | 6 ++-- tests-ng/dynextvariables.sh | 6 ++-- tests-ng/dyninclude.sh | 6 ++-- tests-ng/dynvariables.sh | 7 ++-- tests-ng/ext-actions.sh | 7 ++-- tests-ng/extvariables.sh | 6 ++-- tests-ng/filter_file.sh | 9 +++-- tests-ng/force-actions.sh | 7 ++-- tests-ng/func_file.sh | 9 +++-- tests-ng/global-compare-ignore.sh | 6 ++-- tests-ng/global-compare-negative-ignore.sh | 6 ++-- tests-ng/global-update-ignore.sh | 6 ++-- tests-ng/global-update-negative-ignore.sh | 6 ++-- tests-ng/globs.sh | 7 ++-- tests-ng/header.sh | 6 ++-- tests-ng/helpers | 25 ++++++++++++++ tests-ng/ignore-empty.sh | 6 ++-- tests-ng/import-as.sh | 17 ++++----- tests-ng/import-configs.sh | 6 ++-- tests-ng/import-duplicate.sh | 6 ++-- tests-ng/import-ignore.sh | 6 ++-- tests-ng/import-link-children.sh | 6 ++-- tests-ng/import-negative-ignore.sh | 6 ++-- tests-ng/import-non-existing.sh | 6 ++-- tests-ng/import-profile-dotfiles.sh | 6 ++-- tests-ng/import-subfile.sh | 6 ++-- tests-ng/import-with-empty.sh | 10 +++--- tests-ng/import.sh | 6 ++-- tests-ng/imported-configs-variables.sh | 6 ++-- tests-ng/imported-variables-from-config.sh | 6 ++-- tests-ng/include-actions.sh | 7 ++-- tests-ng/include-order.sh | 7 ++-- tests-ng/include-variables.sh | 6 ++-- tests-ng/include.sh | 6 ++-- tests-ng/inst-link-default.sh | 6 ++-- tests-ng/install-empty.sh | 5 ++- tests-ng/install-ignore.sh | 6 ++-- tests-ng/install-link-children.sh | 6 ++-- tests-ng/install-negative-ignore.sh | 6 ++-- tests-ng/install-to-temp.sh | 6 ++-- tests-ng/install.sh | 6 ++-- tests-ng/jhelpers.sh | 6 ++-- tests-ng/link-import-default.sh | 6 ++-- tests-ng/link-templates-dir-home.sh | 6 ++-- tests-ng/link-templates-dir.sh | 6 ++-- tests-ng/link-templates.sh | 6 ++-- tests-ng/link-value-tests.sh | 6 ++-- tests-ng/macro-with-globals.sh | 6 ++-- tests-ng/minversion.sh | 6 ++-- tests-ng/negative-ignore-no-match.sh | 6 ++-- tests-ng/notemplate.sh | 7 ++-- tests-ng/profile-actions.sh | 7 ++-- tests-ng/profile-dyninclude.sh | 6 ++-- tests-ng/profile-dynvariables.sh | 9 +++-- tests-ng/profile-undefined-variables.sh | 6 ++-- tests-ng/re-import.sh | 36 +++++++++----------- tests-ng/recinclude.sh | 6 ++-- tests-ng/recvariables.sh | 6 ++-- tests-ng/remove.sh | 6 ++-- tests-ng/symlink.sh | 6 ++-- tests-ng/template-link-value.sh | 6 ++-- tests-ng/transformations-template.sh | 6 ++-- tests-ng/transformations-with-args.sh | 6 ++-- tests-ng/transformations.sh | 8 +++-- tests-ng/update-ignore-missing.sh | 6 ++-- tests-ng/update-ignore-relative.sh | 7 ++-- tests-ng/update-ignore.sh | 7 ++-- tests-ng/update-negative-ignore-relative.sh | 7 ++-- tests-ng/update-negative-ignore.sh | 7 ++-- tests-ng/update-profile-check.sh | 6 ++-- tests-ng/update-rights.sh | 6 ++-- tests-ng/update-templates.sh | 6 ++-- tests-ng/update-with-key.sh | 6 ++-- tests-ng/update.sh | 6 ++-- tests-ng/uservariables.sh | 6 ++-- tests-ng/variables-include.sh | 6 ++-- tests-ng/variables.sh | 6 ++-- tests-ng/workdir.sh | 12 +++++-- 110 files changed, 413 insertions(+), 355 deletions(-) diff --git a/tests-ng/actions-args-template.sh b/tests-ng/actions-args-template.sh index f8d469d..bec2560 100755 --- a/tests-ng/actions-args-template.sh +++ b/tests-ng/actions-args-template.sh @@ -68,6 +68,10 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + # create the config file cfg="${tmps}/config.yaml" @@ -137,8 +141,5 @@ should_grep profile_var ${tmpa}/profile should_grep profile_var_2 ${tmpa}/profile should_grep "$USER" ${tmpa}/dyn -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/actions-args.sh b/tests-ng/actions-args.sh index b15d9d5..028586f 100755 --- a/tests-ng/actions-args.sh +++ b/tests-ng/actions-args.sh @@ -54,6 +54,10 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmpa}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -112,8 +116,5 @@ grep empty ${tmpa}/empty >/dev/null [ ! -e ${tmpa}/tgt ] && echo "tgt arg action not found" && exit 1 grep tgt ${tmpa}/tgt >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/actions-default.sh b/tests-ng/actions-default.sh index 9cd720a..7aed2ad 100755 --- a/tests-ng/actions-default.sh +++ b/tests-ng/actions-default.sh @@ -54,6 +54,10 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + # create the config file cfg="${tmps}/config.yaml" @@ -152,8 +156,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V set -e [ -e ${tmpd}/abc ] && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/actions-empty-dir.sh b/tests-ng/actions-empty-dir.sh index 6e4d8de..b19d3a6 100755 --- a/tests-ng/actions-empty-dir.sh +++ b/tests-ng/actions-empty-dir.sh @@ -54,6 +54,10 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + # create the config file cfg="${tmps}/config.yaml" @@ -183,8 +187,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V # 2>&1 | tee ${tmpa}/log [ -d ${tmpd}/dir3/empty ] && echo "empty directory not cleaned" && exit 1 [ -d ${tmpd}/dir3/sub/empty ] && echo "empty directory not cleaned" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/actions-pre.sh b/tests-ng/actions-pre.sh index a0d3efa..ffbbdc4 100755 --- a/tests-ng/actions-pre.sh +++ b/tests-ng/actions-pre.sh @@ -61,6 +61,10 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + # create the config file cfg="${tmps}/config.yaml" @@ -174,8 +178,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p2 -V set -e [ -e ${tmpd}/fail ] && echo "fail exists" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/actions-template.sh b/tests-ng/actions-template.sh index 577a28f..ee27c5a 100755 --- a/tests-ng/actions-template.sh +++ b/tests-ng/actions-template.sh @@ -54,6 +54,10 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + # create the config file cfg="${tmps}/config.yaml" @@ -136,8 +140,5 @@ grep "${tmpd}/abc" ${tmpa}/pre >/dev/null grep "${tmpd}/abc" ${tmpa}/post >/dev/null grep "${tmpd}/abc" ${tmpa}/naked >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/actions.sh b/tests-ng/actions.sh index a5805d4..5f3abf2 100755 --- a/tests-ng/actions.sh +++ b/tests-ng/actions.sh @@ -54,6 +54,10 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + # create the config file cfg="${tmps}/config.yaml" @@ -130,8 +134,5 @@ grep fake ${tmpa}/fake >/dev/null [ ! -e ${tmpa}/fake_pre ] && echo 'fake pre action not executed' && exit 1 grep 'fake pre' ${tmpa}/fake_pre >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/chmod-compare.sh b/tests-ng/chmod-compare.sh index 6a2b909..3bc1155 100755 --- a/tests-ng/chmod-compare.sh +++ b/tests-ng/chmod-compare.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the dotfile dnormal="${tmpd}/dir_normal" mkdir -p ${dnormal} @@ -113,8 +116,5 @@ cnt=`cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 2>&1 | grep 'modes differ' | set -e [ "${cnt}" != "5" ] && echo "compare modes failed (${cnt})" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/chmod-import.sh b/tests-ng/chmod-import.sh index cb810eb..7fd437f 100755 --- a/tests-ng/chmod-import.sh +++ b/tests-ng/chmod-import.sh @@ -67,6 +67,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the dotfiles dnormal="${tmpd}/dir_normal" mkdir -p ${dnormal} @@ -243,8 +246,5 @@ tot=`echo ${toimport} | wc -w` cnt=`cat ${cfg} | grep "chmod: " | wc -l` [ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (3)" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/chmod-install.sh b/tests-ng/chmod-install.sh index 5628368..9fcd341 100755 --- a/tests-ng/chmod-install.sh +++ b/tests-ng/chmod-install.sh @@ -81,6 +81,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -270,8 +273,5 @@ cd ${ddpath} | printf 'y\ny\n' | ${bin} install -f -c ${cfg} -p p2 -V f_nomode echo "different mode (2)" has_rights "${tmpd}/nomode" "600" -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/chmod-more.sh b/tests-ng/chmod-more.sh index f78a719..001734a 100755 --- a/tests-ng/chmod-more.sh +++ b/tests-ng/chmod-more.sh @@ -78,6 +78,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the dotfiles f1="${tmpd}/f1" touch ${f1} @@ -120,8 +123,5 @@ has_rights "${tmps}/dotfiles/${tmpd}/f2" "644" # install cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 -V | grep '0 dotfile(s) installed' || (echo "should not install" && exit 1) -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/chmod-update.sh b/tests-ng/chmod-update.sh index 6e96a66..5e38fbd 100755 --- a/tests-ng/chmod-update.sh +++ b/tests-ng/chmod-update.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the dotfile dnormal="${tmpd}/dir_normal" mkdir -p ${dnormal} @@ -150,8 +153,5 @@ cd ${ddpath} | ${bin} update -c ${cfg} -f -p p1 -V ${flink} cnt=`cat ${cfg} | grep "chmod: '777'" | wc -l` [ "${cnt}" != "5" ] && echo "chmod not updated (5)" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/compare-ignore-missing.sh b/tests-ng/compare-ignore-missing.sh index 61da321..c055f49 100755 --- a/tests-ng/compare-ignore-missing.sh +++ b/tests-ng/compare-ignore-missing.sh @@ -52,6 +52,9 @@ touch ${dt}/folder/a # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # some files cp -r ${dt}/folder ${tmpd}/ mkdir -p ${tmpd}/folder @@ -151,8 +154,5 @@ cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --profile=p1 [ "$?" != "0" ] && exit 1 set -e -# CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/compare-ignore-relative.sh b/tests-ng/compare-ignore-relative.sh index 4b9278c..662ac33 100755 --- a/tests-ng/compare-ignore-relative.sh +++ b/tests-ng/compare-ignore-relative.sh @@ -54,6 +54,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # some files mkdir -p ${tmpd}/{program,config,vscode} touch ${tmpd}/program/a @@ -182,8 +185,5 @@ cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose -C ${tmpd}/.zsh [ "$?" != "0" ] && exit 1 set -e -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/compare-ignore.sh b/tests-ng/compare-ignore.sh index cf162c4..42c2916 100755 --- a/tests-ng/compare-ignore.sh +++ b/tests-ng/compare-ignore.sh @@ -54,6 +54,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # some files mkdir -p ${tmpd}/{program,config} touch ${tmpd}/program/a @@ -194,8 +197,5 @@ cat ${cfg2} cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose [ "$?" != "0" ] && exit 1 -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/compare-negative-ignore-relative.sh b/tests-ng/compare-negative-ignore-relative.sh index 9773c32..b78ee7d 100755 --- a/tests-ng/compare-negative-ignore-relative.sh +++ b/tests-ng/compare-negative-ignore-relative.sh @@ -77,6 +77,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # some files mkdir -p ${tmpd}/program/ignore_me echo "some data" > ${tmpd}/program/a @@ -146,7 +149,4 @@ echo ${ret} [ "${ret}" = "0" ] && exit 1 set -e -# clean -rm -rf ${basedir} ${tmpd} - echo "OK" diff --git a/tests-ng/compare-negative-ignore.sh b/tests-ng/compare-negative-ignore.sh index 24e6b38..2b79f7b 100755 --- a/tests-ng/compare-negative-ignore.sh +++ b/tests-ng/compare-negative-ignore.sh @@ -76,6 +76,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # some files mkdir -p ${tmpd}/program/ignore_me echo "some data" > ${tmpd}/program/a @@ -125,8 +128,5 @@ cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose [ "$?" = "0" ] && exit 1 set -e -# clean -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/compare-profile-check.sh b/tests-ng/compare-profile-check.sh index 6d42f4c..b71f043 100755 --- a/tests-ng/compare-profile-check.sh +++ b/tests-ng/compare-profile-check.sh @@ -56,6 +56,9 @@ echo "${yori}" > ${dt}/file_y tmpd=`mktemp -d --suffix='-dotdrop-tests-dest' || mktemp -d` touch ${tmpd}/file +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" cat > ${cfg} << _EOF @@ -140,8 +143,5 @@ cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -p y [ "$?" = "0" ] && exit 1 set -e -# CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/compare.sh b/tests-ng/compare.sh index 5faed63..8e91257 100755 --- a/tests-ng/compare.sh +++ b/tests-ng/compare.sh @@ -54,6 +54,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # single file echo 'unique' > ${tmpd}/uniquefile @@ -121,8 +124,5 @@ cd ${ddpath} | ${bin} compare -c ${cfg} -L [ "$?" = "0" ] && exit 1 set -e -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/corner-case.sh b/tests-ng/corner-case.sh index e5fb665..b74ab22 100755 --- a/tests-ng/corner-case.sh +++ b/tests-ng/corner-case.sh @@ -56,6 +56,8 @@ basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "[+] dotdrop dir: ${basedir}" echo "[+] dotpath dir: ${basedir}/dotfiles" +clear_on_exit "${basedir}" + export DOTDROP_WORKERS=1 # create the config file @@ -94,11 +96,13 @@ echo "[+] test install not existing src" cd ${ddpath} | ${bin} install -c ${cfg} -f --dry -p p1 --verbose f_y echo "[+] test install to temp" -cd ${ddpath} | ${bin} install -t -c ${cfg} -p p1 --verbose f_x -[ "$?" != "0" ] && exit 1 +cd ${ddpath} | ${bin} install -t -c ${cfg} -p p1 --verbose f_x > ${basedir}/log 2>&1 +[ "$?" != "0" ] && echo "install to tmp failed" && exit 1 -## CLEANING -rm -rf ${basedir} +# cleaning +tmpfile=`cat ${basedir}/log | grep 'installed to tmp ' | sed 's/^.*to tmp "\(.*\)"./\1/'` +echo "tmpfile: ${tmpfile}" +rm -rf "${tmpfile}" echo "OK" exit 0 diff --git a/tests-ng/deprecated-link.sh b/tests-ng/deprecated-link.sh index be96783..241da7c 100755 --- a/tests-ng/deprecated-link.sh +++ b/tests-ng/deprecated-link.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -133,8 +136,5 @@ cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_children' | head -1 | cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_children2' | head -1 | grep ',link:link_children,' cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_children3' | head -1 | grep ',link:nolink,' -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/diff-cmd.sh b/tests-ng/diff-cmd.sh index 7af22f6..8429267 100755 --- a/tests-ng/diff-cmd.sh +++ b/tests-ng/diff-cmd.sh @@ -54,6 +54,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # some files echo "original" > ${tmpd}/singlefile @@ -117,8 +120,5 @@ set -e #cat ${tmpd}/fake grep fakediff ${tmpd}/fake &> /dev/null || exit 1 -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/dir-import-update.sh b/tests-ng/dir-import-update.sh index 79dcad6..a7f77cd 100755 --- a/tests-ng/dir-import-update.sh +++ b/tests-ng/dir-import-update.sh @@ -54,6 +54,9 @@ echo "dotdrop dir: ${basedir}" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` create_dir ${tmpd} +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # create the config file cfg="${basedir}/config.yaml" create_conf ${cfg} # sets token @@ -69,8 +72,5 @@ cd ${ddpath} | ${bin} update -f -c ${cfg} ${tmpd} --verbose grep 'changed' ${token} >/dev/null 2>&1 -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/dotdrop-variables.sh b/tests-ng/dotdrop-variables.sh index c5d7639..2561747 100755 --- a/tests-ng/dotdrop-variables.sh +++ b/tests-ng/dotdrop-variables.sh @@ -54,6 +54,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -88,8 +91,5 @@ grep "^dotpath: ${tmps}/dotfiles$" ${tmpd}/abc >/dev/null grep "^cfgpath: ${tmps}/config.yaml$" ${tmpd}/abc >/dev/null grep "^workdir: /tmp/xxx$" ${tmpd}/abc >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/dotfile-no-src.sh b/tests-ng/dotfile-no-src.sh index ccfaf37..fea77de 100755 --- a/tests-ng/dotfile-no-src.sh +++ b/tests-ng/dotfile-no-src.sh @@ -55,6 +55,9 @@ echo "dotfiles source (dotpath): ${tmps}" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "dotfiles destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -88,8 +91,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V [ ! -e ${tmpd}/abc ] && exit 1 grep 'abc' ${tmpd}/abc -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpx} ${tmpy} - echo "OK" exit 0 diff --git a/tests-ng/dotfile-sub-variables.sh b/tests-ng/dotfile-sub-variables.sh index c03a730..d223772 100755 --- a/tests-ng/dotfile-sub-variables.sh +++ b/tests-ng/dotfile-sub-variables.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -99,8 +102,5 @@ grep "dst:${tmpd}/abc/file1" ${tmpd}/abc/file1>/dev/null grep "src:${tmps}/dotfiles/abc/subdir/file2" ${tmpd}/abc/subdir/file2 >/dev/null grep "dst:${tmpd}/abc/subdir/file2" ${tmpd}/abc/subdir/file2 >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/dotfile-variables.sh b/tests-ng/dotfile-variables.sh index cda2104..f96f215 100755 --- a/tests-ng/dotfile-variables.sh +++ b/tests-ng/dotfile-variables.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -88,8 +91,5 @@ grep "dst:${tmpd}/abc" ${tmpd}/abc >/dev/null grep "key:f_abc" ${tmpd}/abc >/dev/null grep "link:nolink" ${tmpd}/abc >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/dotfiles-all.sh b/tests-ng/dotfiles-all.sh index fc5fdfd..72c42e2 100755 --- a/tests-ng/dotfiles-all.sh +++ b/tests-ng/dotfiles-all.sh @@ -55,6 +55,9 @@ echo "dotfiles source (dotpath): ${tmps}" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "dotfiles destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -110,8 +113,5 @@ ret="$?" set -e [ "$ret" = "0" ] && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpx} ${tmpy} - echo "OK" exit 0 diff --git a/tests-ng/dotfiles-dyn-paths.sh b/tests-ng/dotfiles-dyn-paths.sh index 7450752..d91c1e2 100755 --- a/tests-ng/dotfiles-dyn-paths.sh +++ b/tests-ng/dotfiles-dyn-paths.sh @@ -55,6 +55,9 @@ echo "dotfiles source (dotpath): ${tmps}" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "dotfiles destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -92,8 +95,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V # checks [ ! -e ${tmpd}/abc ] && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/dry.sh b/tests-ng/dry.sh index 5707f08..849ee08 100755 --- a/tests-ng/dry.sh +++ b/tests-ng/dry.sh @@ -55,6 +55,11 @@ tmpw=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` # temp tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpw}" +clear_on_exit "${tmpa}" + # ----------------------------- # test install # ----------------------------- @@ -312,8 +317,5 @@ cd ${ddpath} | ${bin} remove -c ${cfg} -f -p p1 -V --dry ${dotfiles} diff ${cfg} ${tmpa}/config.yaml || (echo "dry remove failed (8)" && exit 1) -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpw} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/duplicate-key.sh b/tests-ng/duplicate-key.sh index 3d11cc2..9069203 100755 --- a/tests-ng/duplicate-key.sh +++ b/tests-ng/duplicate-key.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -98,8 +101,5 @@ cd ${ddpath} | ${bin} import --verbose -c ${cfg} -p p2 \ cnt=`cd ${ddpath} | ${bin} files --verbose -c ${cfg} -p p2 -b | grep '^f_' | wc -l` [ "${cnt}" != "4" ] && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/dynactions.sh b/tests-ng/dynactions.sh index 81bb3b3..a9f50fa 100755 --- a/tests-ng/dynactions.sh +++ b/tests-ng/dynactions.sh @@ -54,6 +54,10 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + # create the config file cfg="${tmps}/config.yaml" @@ -120,8 +124,5 @@ grep 'dvar1 dvar2 dvar3' ${tmpa}/postaction2 >/dev/null grep 'var1 var2 var3' ${tmpa}/naked1 >/dev/null grep 'dvar1 dvar2 dvar3' ${tmpa}/naked2 >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/dyndotfilepaths.sh b/tests-ng/dyndotfilepaths.sh index 9b26d8a..8696d63 100755 --- a/tests-ng/dyndotfilepaths.sh +++ b/tests-ng/dyndotfilepaths.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -88,8 +91,5 @@ grep "^${tmpd}" ${tmpd}/abc >/dev/null #cat ${tmpd}/abc -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/dynextvariables.sh b/tests-ng/dynextvariables.sh index 83e9799..4b06c3c 100755 --- a/tests-ng/dynextvariables.sh +++ b/tests-ng/dynextvariables.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file extvars="${tmps}/variables.yaml" extdvars="${tmps}/dynvariables.yaml" @@ -148,8 +151,5 @@ grep '^pvar: pvar1' ${tmpd}/abc >/dev/null grep '^pdvar: pdvar1' ${tmpd}/abc >/dev/null grep '^test: profileok' ${tmpd}/abc >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/dyninclude.sh b/tests-ng/dyninclude.sh index 6db0155..8d147c5 100755 --- a/tests-ng/dyninclude.sh +++ b/tests-ng/dyninclude.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -109,8 +112,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p profile_4 --verbose #cat ${tmpd}/def grep ${c2} ${tmpd}/def >/dev/null || exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/dynvariables.sh b/tests-ng/dynvariables.sh index 89527ba..0062534 100755 --- a/tests-ng/dynvariables.sh +++ b/tests-ng/dynvariables.sh @@ -53,11 +53,15 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create a shell script export TESTENV="this is my testenv" scr=`mktemp --suffix='-dotdrop-tests' || mktemp -d` chmod +x ${scr} echo -e "#!/bin/bash\necho $TESTENV\n" >> ${scr} +clear_on_exit "${scr}" # create the config file cfg="${tmps}/config.yaml" @@ -107,8 +111,5 @@ grep '^4ravd_eht' ${tmpd}/abc >/dev/null #cat ${tmpd}/abc -## CLEANING -rm -rf ${tmps} ${tmpd} ${scr} - echo "OK" exit 0 diff --git a/tests-ng/ext-actions.sh b/tests-ng/ext-actions.sh index 968b01b..7dc168f 100755 --- a/tests-ng/ext-actions.sh +++ b/tests-ng/ext-actions.sh @@ -54,6 +54,10 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + act="${tmps}/actions.yaml" cat > ${act} << _EOF actions: @@ -116,8 +120,5 @@ echo "naked is ok" grep over ${tmpa}/write >/dev/null echo "write is ok" -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/extvariables.sh b/tests-ng/extvariables.sh index aae8e17..a432afd 100755 --- a/tests-ng/extvariables.sh +++ b/tests-ng/extvariables.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file extvars="${tmps}/variables.yaml" cfg="${tmps}/config.yaml" @@ -195,8 +198,5 @@ grep '^dvar4: extvar1 var2 var3' ${tmpd}/abc >/dev/null grep '^varx: profvarx' ${tmpd}/abc >/dev/null grep '^vary: profvary' ${tmpd}/abc >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/filter_file.sh b/tests-ng/filter_file.sh index def9e09..933a34c 100755 --- a/tests-ng/filter_file.sh +++ b/tests-ng/filter_file.sh @@ -56,6 +56,12 @@ filter_file=`mktemp` filter_file2=`mktemp` filter_file3=`mktemp` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${filter_file}" +clear_on_exit "${filter_file2}" +clear_on_exit "${filter_file3}" + # create the config file cfg="${tmps}/config.yaml" cfgext="${tmps}/ext.yaml" @@ -135,8 +141,5 @@ grep '^something$' ${tmpd}/abc >/dev/null && exit 1 set -e grep '^filteredvariable$' ${tmpd}/abc > /dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} ${filter_file} ${filter_file2} ${filter_file3} - echo "OK" exit 0 diff --git a/tests-ng/force-actions.sh b/tests-ng/force-actions.sh index 242904c..78d08ac 100755 --- a/tests-ng/force-actions.sh +++ b/tests-ng/force-actions.sh @@ -54,6 +54,10 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + # create the config file cfg="${tmps}/config.yaml" @@ -117,8 +121,5 @@ grep pre2 ${tmpa}/pre2 >/dev/null [ ! -e ${tmpa}/post2 ] && exit 1 grep post2 ${tmpa}/post2 >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/func_file.sh b/tests-ng/func_file.sh index 081f747..65f5ca6 100755 --- a/tests-ng/func_file.sh +++ b/tests-ng/func_file.sh @@ -56,6 +56,12 @@ func_file=`mktemp` func_file2=`mktemp` func_file3=`mktemp` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${func_file}" +clear_on_exit "${func_file2}" +clear_on_exit "${func_file3}" + # create the config file cfg="${tmps}/config.yaml" cfgext="${tmps}/ext.yaml" @@ -151,8 +157,5 @@ grep '^nope$' ${tmpd}/abc >/dev/null && exit 1 set -e grep '^Falseadded$' ${tmpd}/abc >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} ${func_file} ${func_file2} ${func_file3} - echo "OK" exit 0 diff --git a/tests-ng/global-compare-ignore.sh b/tests-ng/global-compare-ignore.sh index 5f9ef10..91a4ba8 100755 --- a/tests-ng/global-compare-ignore.sh +++ b/tests-ng/global-compare-ignore.sh @@ -54,6 +54,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # some files mkdir -p ${tmpd}/{program,config} touch ${tmpd}/program/a @@ -105,8 +108,5 @@ cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose [ "$?" != "0" ] && exit 1 set -e -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/global-compare-negative-ignore.sh b/tests-ng/global-compare-negative-ignore.sh index 56ca367..00cf4a7 100755 --- a/tests-ng/global-compare-negative-ignore.sh +++ b/tests-ng/global-compare-negative-ignore.sh @@ -77,6 +77,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # some files mkdir -p ${tmpd}/{program,config} touch ${tmpd}/program/a @@ -112,8 +115,5 @@ cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose [ "$?" = "0" ] && exit 1 set -e -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/global-update-ignore.sh b/tests-ng/global-update-ignore.sh index 93c6971..60e18c0 100755 --- a/tests-ng/global-update-ignore.sh +++ b/tests-ng/global-update-ignore.sh @@ -58,6 +58,9 @@ echo 'a' > ${dt}/a/c/acfile tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` cp -r ${dt}/a ${tmpd}/ +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" cat > ${cfg} << _EOF @@ -104,8 +107,5 @@ grep 'b' ${dt}/a/c/acfile || (echo "acfile not updated" && exit 1) set -e [ -e ${dt}/a/newfile ] && echo "newfile found" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/global-update-negative-ignore.sh b/tests-ng/global-update-negative-ignore.sh index 3598f0f..5afa67d 100755 --- a/tests-ng/global-update-negative-ignore.sh +++ b/tests-ng/global-update-negative-ignore.sh @@ -83,6 +83,9 @@ echo 'a' > ${basedir}/dotfiles/a/c/acfile tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d` cp -r ${basedir}/dotfiles/a ${tmpd}/ +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # create the config file cfg="${basedir}/config.yaml" cat > ${cfg} << _EOF @@ -128,8 +131,5 @@ set -e [ -e ${basedir}/dotfiles/a/newdir/b/c ] && echo "newdir/b/c should not have been updated" && exit 1 [ ! -e ${basedir}/dotfiles/a/newdir/b/d ] && echo "newdir/b/d should have been updated" && exit 1 -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/globs.sh b/tests-ng/globs.sh index d38915f..5ae60bf 100755 --- a/tests-ng/globs.sh +++ b/tests-ng/globs.sh @@ -57,6 +57,10 @@ tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` # temporary tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + ########### # test globs in import_actions ########### @@ -107,8 +111,5 @@ grep fromaction1 ${tmpa}/fromaction1 [ ! -e ${tmpa}/fromaction2 ] && echo "action2 not executed" && exit 1 grep fromaction2 ${tmpa}/fromaction2 -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/header.sh b/tests-ng/header.sh index 311be3c..bd0ae5b 100755 --- a/tests-ng/header.sh +++ b/tests-ng/header.sh @@ -54,6 +54,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -88,8 +91,5 @@ grep '^// This dotfile is managed using dotdrop' ${tmpd}/abc >/dev/null #cat ${tmpd}/abc -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/helpers b/tests-ng/helpers index 2d8581b..2d46606 100644 --- a/tests-ng/helpers +++ b/tests-ng/helpers @@ -3,6 +3,31 @@ # # file to be sourced from test scripts # +# for i in *.sh; do ./$i >/dev/null 2>&1; find /tmp/ -maxdepth 1 -type f -iname 'tmp*' >> /tmp/$i.log; find /tmp/ -maxdepth 1 -type d -iname 'tmp.*-dotdrop-tests' >> /tmp/$i.log; find /tmp/ -maxdepth 1 -type d -iname 'dotdrop-*' >> /tmp/$i.log; wc -l /tmp/$i.log; [ "`wc -l /tmp/$i.log | awk '{print $1}'`" -gt "0" ] && break; done + +declare -a to_be_cleared + +# add a file/directory to be cleared +# on exit +# +# $1: file path to clear +clear_on_exit() +{ + local len="${#to_be_cleared[*]}" + to_be_cleared[${len}]="$1" + if [ "${len}" = "0" ]; then + # set trap + trap on_exit EXIT + fi +} + +# clear files +on_exit() +{ + for i in "${to_be_cleared[@]}"; do + rm -rf "${i}" + done +} # create a directory with sub-dirs and file # for tests diff --git a/tests-ng/ignore-empty.sh b/tests-ng/ignore-empty.sh index 92a3d2f..8e265ef 100755 --- a/tests-ng/ignore-empty.sh +++ b/tests-ng/ignore-empty.sh @@ -54,6 +54,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -116,8 +119,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V [ -e ${tmpd}/d1/empty ] && echo 'empty should not exist' && exit 1 [ ! -e ${tmpd}/d1/notempty ] && echo 'not empty should exist' && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/import-as.sh b/tests-ng/import-as.sh index d5b29e9..b77da19 100755 --- a/tests-ng/import-as.sh +++ b/tests-ng/import-as.sh @@ -45,11 +45,6 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)" # this is the test ################################################################ -clean() -{ - rm -rf ${tmps} ${tmpd} ~/.dotdrop.test ~/.dotdrop-dotfiles-test -} - # the dotfile source tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` mkdir -p ${tmps}/dotfiles @@ -57,6 +52,11 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "~/.dotdrop.test" +clear_on_exit "~/.dotdrop-dotfiles-test" + # create the dotfile mkdir -p ${tmpd}/adir echo "adir/file1" > ${tmpd}/adir/file1 @@ -140,11 +140,8 @@ _EOF cd ${ddpath} | ${bin} import -b -c ${cfg} -p test -V ~/.dotdrop.test --as=~/.whatever #cat ${cfg} -[ ! -e ~/.dotdrop-dotfiles-test/dotfiles/whatever ] && clean && echo 'tild imported' && exit 1 -cat ${cfg} | grep '~/.whatever' && clean && echo 'import with tild failed' && exit 1 - -## CLEANING -clean +[ ! -e ~/.dotdrop-dotfiles-test/dotfiles/whatever ] && echo 'tild imported' && exit 1 +cat ${cfg} | grep '~/.whatever' && echo 'import with tild failed' && exit 1 echo "OK" exit 0 diff --git a/tests-ng/import-configs.sh b/tests-ng/import-configs.sh index 41a45e8..67f5577 100755 --- a/tests-ng/import-configs.sh +++ b/tests-ng/import-configs.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles-other # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg1="${tmps}/config1.yaml" cfg2="${tmps}/config2.yaml" @@ -175,8 +178,5 @@ _EOF cd ${ddpath} | ${bin} install -c ${cfg1} -p p2 -V -f cd ${ddpath} | ${bin} compare -c ${cfg1} -p p2 -V -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/import-duplicate.sh b/tests-ng/import-duplicate.sh index 262e3a5..3c818cf 100755 --- a/tests-ng/import-duplicate.sh +++ b/tests-ng/import-duplicate.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the dotfile touch ${tmpd}/.colors mkdir -p ${tmpd}/.mutt @@ -103,8 +106,5 @@ cat ${cfg} cat ${cfg} | grep ${tmpd}/.mutt/colors >/dev/null 2>&1 cat ${cfg} | grep ${tmpd}/.colors >/dev/null 2>&1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/import-ignore.sh b/tests-ng/import-ignore.sh index f6be416..a2a16be 100755 --- a/tests-ng/import-ignore.sh +++ b/tests-ng/import-ignore.sh @@ -60,6 +60,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # dotdrop directory mkdir -p ${tmpd} mkdir -p ${tmpd}/a/{b,c} @@ -93,8 +96,5 @@ cd ${ddpath} | ${bin} import -c ${cfg} --verbose --profile=p1 ${tmpd}/a [ -e ${tmps}/dotfiles/newdir/newfile ] && echo "newfile not ignored" && exit 1 [ -e ${tmps}/dotfiles/a/b/newfile ] && echo "newfile not ignored" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/import-link-children.sh b/tests-ng/import-link-children.sh index 309fd54..2f97c18 100755 --- a/tests-ng/import-link-children.sh +++ b/tests-ng/import-link-children.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # dotpath dotpath="${tmps}/dotfiles" mkdir -p ${dotpath} @@ -123,8 +126,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V [ ! -h ${dtsub2} ] && echo "dtsub2 is not a symlink" && exit 1 [ -h ${dtsub3} ] && echo "dtsub3 is not a regular directory" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/import-negative-ignore.sh b/tests-ng/import-negative-ignore.sh index 034deee..ff1c073 100755 --- a/tests-ng/import-negative-ignore.sh +++ b/tests-ng/import-negative-ignore.sh @@ -75,6 +75,9 @@ mkdir -p ${basedir}/dotfiles # the dotfile destination tmpd=`mkdir -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # dotdrop directory echo "[+] dotdrop dir: ${basedir}" echo "[+] dotpath dir: ${basedir}/dotfiles" @@ -109,8 +112,5 @@ cd ${ddpath} | ${bin} import -f -c ${cfg2} --verbose --profile=p1 ${tmpd}/a --as [ -e ${basedir}/dotfiles/a/b/abfile2 ] && echo "abfile2 should not have been imported" && exit 1 [ ! -e ${basedir}/dotfiles/a/b/abfile3 ] && echo "abfile3 should have been imported" && exit 1 -## CLEANING -rm -rf ${tmpd} ${basedir} - echo "OK" exit 0 diff --git a/tests-ng/import-non-existing.sh b/tests-ng/import-non-existing.sh index 9b05efa..72b5e83 100755 --- a/tests-ng/import-non-existing.sh +++ b/tests-ng/import-non-existing.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the dotfile echo "test" > ${tmps}/dotfiles/abc @@ -296,8 +299,5 @@ cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V [ "$?" = "0" ] && echo "configs glob" && exit 1 set -e -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/import-profile-dotfiles.sh b/tests-ng/import-profile-dotfiles.sh index 1215388..bfd6528 100755 --- a/tests-ng/import-profile-dotfiles.sh +++ b/tests-ng/import-profile-dotfiles.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` extdotfiles="${tmps}/df_p1.yaml" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + dynextdotfiles_name="d_uid_dynvar" dynextdotfiles="${tmps}/ext_${dynextdotfiles_name}" @@ -121,8 +124,5 @@ grep 'def' ${tmpd}/def >/dev/null 2>&1 grep 'xyz' ${tmpd}/xyz >/dev/null 2>&1 grep 'dyn' ${tmpd}/dyn >/dev/null 2>&1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/import-subfile.sh b/tests-ng/import-subfile.sh index b416a63..38a6c01 100755 --- a/tests-ng/import-subfile.sh +++ b/tests-ng/import-subfile.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the dotfile mkdir -p ${tmpd}/adir echo "first" > ${tmpd}/adir/file1 @@ -84,8 +87,5 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir/file1 [ ! -e ${tmps}/dotfiles/${tmpd}/adir/file1 ] && echo "not exist" && exit 1 grep 'second' ${tmps}/dotfiles/${tmpd}/adir/file1 >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/import-with-empty.sh b/tests-ng/import-with-empty.sh index 8937313..6af2aab 100755 --- a/tests-ng/import-with-empty.sh +++ b/tests-ng/import-with-empty.sh @@ -53,6 +53,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the temp directory tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # create a dotfile dftoimport="${tmpd}/a_dotfile" echo 'some content' > ${dftoimport} @@ -101,13 +104,10 @@ cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 --verbose | grep '^5 dotfile(s) rm -f ${dftoimport} cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 --verbose | grep '^6 dotfile(s) installed.$' -nb=`cd ${ddpath} | ${bin} files -c ${cfg} -p p1 --verbose | grep '^[a-zA-Z]' | wc -l` -[ "${nb}" != "6" ] && echo 'error in dotfile list' && exit 1 +nb=`cd ${ddpath} | ${bin} files -c ${cfg} -p p1 --verbose | grep '^[a-zA-Z]' | grep -v '^Dotfile(s)' | wc -l` +[ "${nb}" != "6" ] && echo "error in dotfile list (${nb} VS 6)" && exit 1 #cat ${cfg} -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/import.sh b/tests-ng/import.sh index 81eb79c..9646b38 100755 --- a/tests-ng/import.sh +++ b/tests-ng/import.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the dotfile mkdir -p ${tmpd}/adir echo "adir/file1" > ${tmpd}/adir/file1 @@ -130,8 +133,5 @@ cd ${ddpath} | ${bin} import -c ${cfg} -p p2 -V ${d} cat ${cfg} | grep ${d} >/dev/null 2>&1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/imported-configs-variables.sh b/tests-ng/imported-configs-variables.sh index f852c00..55093c6 100755 --- a/tests-ng/imported-configs-variables.sh +++ b/tests-ng/imported-configs-variables.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file extcfg="${tmps}/ext-config.yaml" cfg="${tmps}/config.yaml" @@ -132,8 +135,5 @@ grep '^provar: provar' ${tmpd}/abc >/dev/null grep '^dvarx: dprofvarx' ${tmpd}/abc >/dev/null grep '^dprovar: dprovar' ${tmpd}/abc >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/imported-variables-from-config.sh b/tests-ng/imported-variables-from-config.sh index 004c5df..2cf6c88 100755 --- a/tests-ng/imported-variables-from-config.sh +++ b/tests-ng/imported-variables-from-config.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" subcfg="${tmps}/subconfig.yaml" @@ -103,8 +106,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V exit 1 } -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/include-actions.sh b/tests-ng/include-actions.sh index abe4f75..1754f9b 100755 --- a/tests-ng/include-actions.sh +++ b/tests-ng/include-actions.sh @@ -55,6 +55,10 @@ tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` # the action temp tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + # create the config file cfg="${tmps}/config.yaml" @@ -177,8 +181,5 @@ nb=`wc -l ${tmpa}/post2 | awk '{print $1}'` nb=`wc -l ${tmpa}/naked | awk '{print $1}'` [ "${nb}" != "1" ] && echo "naked executed multiple times" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/include-order.sh b/tests-ng/include-order.sh index 3c261e4..60978d1 100755 --- a/tests-ng/include-order.sh +++ b/tests-ng/include-order.sh @@ -55,6 +55,10 @@ tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` # temporary tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + export DOTDROP_WORKERS=1 # create the config file cfg="${tmps}/config.yaml" @@ -137,8 +141,5 @@ for ((i=0;i<${attempts};i++)); do rm ${tmpd}/first ${tmpd}/second ${tmpd}/third done -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/include-variables.sh b/tests-ng/include-variables.sh index 2361a04..98919a7 100755 --- a/tests-ng/include-variables.sh +++ b/tests-ng/include-variables.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -101,8 +104,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p0 --verbose grep 'p0v' ${tmpd}/abc grep 'p0dv' ${tmpd}/abc -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/include.sh b/tests-ng/include.sh index 526ffa4..a7defd1 100755 --- a/tests-ng/include.sh +++ b/tests-ng/include.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -116,8 +119,5 @@ cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p0 | grep f_abc | wc -l` cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -b | grep '^f_' | wc -l` [ "${cnt}" != "1" ] && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/inst-link-default.sh b/tests-ng/inst-link-default.sh index c3ed955..200eb5e 100755 --- a/tests-ng/inst-link-default.sh +++ b/tests-ng/inst-link-default.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the dotfile mkdir -p ${tmps}/dotfiles/abc echo "test link_dotfile_default 1" > ${tmps}/dotfiles/abc/file1 @@ -159,8 +162,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V [ ! -h ${tmpd}/abc/file2 ] && echo "not a symlink" && exit 1 rm -rf ${tmpd}/abc -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/install-empty.sh b/tests-ng/install-empty.sh index 8ca2ff3..34ce1c9 100755 --- a/tests-ng/install-empty.sh +++ b/tests-ng/install-empty.sh @@ -51,6 +51,8 @@ basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "[+] dotdrop dir: ${basedir}" echo "[+] dotpath dir: ${basedir}/dotfiles" +clear_on_exit "${basedir}" + # create the config file cfg="${basedir}/config.yaml" cat > ${cfg} << _EOF @@ -90,8 +92,5 @@ echo "[+] install" cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 --verbose | grep '^5 dotfile(s) installed.$' [ "$?" != "0" ] && exit 1 -## CLEANING -rm -rf ${basedir} - echo "OK" exit 0 diff --git a/tests-ng/install-ignore.sh b/tests-ng/install-ignore.sh index 7fff8e6..602d07e 100755 --- a/tests-ng/install-ignore.sh +++ b/tests-ng/install-ignore.sh @@ -55,6 +55,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` tmps="${basedir}" +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # some files mkdir -p ${tmpd}/{program,config,vscode} echo "some data" > ${tmpd}/program/a @@ -179,8 +182,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg2} -p p1 -V f_template grep 'p1' ${tmpd}/nvim/templated/ftemplated grep 'p1' ${tmpd}/nvim/template -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/install-link-children.sh b/tests-ng/install-link-children.sh index fa0d10a..20e640c 100755 --- a/tests-ng/install-link-children.sh +++ b/tests-ng/install-link-children.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -105,8 +108,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V grep "p1" ${tmpd}/dir1/not-empty/file -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/install-negative-ignore.sh b/tests-ng/install-negative-ignore.sh index 6fd6779..961d242 100755 --- a/tests-ng/install-negative-ignore.sh +++ b/tests-ng/install-negative-ignore.sh @@ -77,6 +77,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # some files mkdir -p ${tmpd}/program/ignore_me echo "some data" > ${tmpd}/program/a @@ -118,9 +121,6 @@ echo "(1) didn't find program/b ... good" [[ -n "$(find ${tmpd}/program/ignore_me -name c)" ]] || exit 1 echo "(1) found program/c ... good" -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/install-to-temp.sh b/tests-ng/install-to-temp.sh index 7ffa49c..5e88767 100755 --- a/tests-ng/install-to-temp.sh +++ b/tests-ng/install-to-temp.sh @@ -53,6 +53,9 @@ tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "[+] dotdrop dir: ${basedir}" echo "[+] dotpath dir: ${basedir}/dotfiles" +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # create the config file cfg="${basedir}/config.yaml" cat > ${cfg} << _EOF @@ -87,8 +90,5 @@ echo "[+] install" cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 --showdiff --verbose --temp | grep '^3 dotfile(s) installed.$' [ "$?" != "0" ] && exit 1 -## CLEANING -rm -rf ${basedir} - echo "OK" exit 0 diff --git a/tests-ng/install.sh b/tests-ng/install.sh index 16afa60..5164330 100755 --- a/tests-ng/install.sh +++ b/tests-ng/install.sh @@ -72,6 +72,9 @@ echo "[+] dotdrop dir: ${basedir}" echo "[+] dotpath dir: ${basedir}/dotfiles" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + echo "content" > ${basedir}/dotfiles/x # create the config file @@ -120,8 +123,5 @@ cd ${ddpath} | printf "y\n" | ${bin} install -c ${cfg} -p p1 --verbose has_rights "${tmpd}/x" "666" -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/jhelpers.sh b/tests-ng/jhelpers.sh index f502ed6..c2067b1 100755 --- a/tests-ng/jhelpers.sh +++ b/tests-ng/jhelpers.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -137,8 +140,5 @@ set -e grep "dotfile dst filename: `basename ${tmpd}/def`" ${tmpd}/def grep "dotfile dst dirname: `dirname ${tmpd}/def`" ${tmpd}/def -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/link-import-default.sh b/tests-ng/link-import-default.sh index b20f145..3600dcc 100755 --- a/tests-ng/link-import-default.sh +++ b/tests-ng/link-import-default.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -101,8 +104,5 @@ inside="${tmps}/dotfiles/${tmpd}/abc" cat ${cfg} cat ${cfg} | grep 'link: link' >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/link-templates-dir-home.sh b/tests-ng/link-templates-dir-home.sh index 0b58c16..3fd9569 100755 --- a/tests-ng/link-templates-dir-home.sh +++ b/tests-ng/link-templates-dir-home.sh @@ -57,6 +57,9 @@ echo "dotfiles destination: ${tmpd}" tmpw=`mktemp -d -p ${HOME} --suffix='-dotdrop-tests' || mktemp -d` echo "workdir: ${tmpw}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpw}" # create the config file cfg="${tmps}/config.yaml" @@ -97,8 +100,5 @@ set +e grep '{{@@' ${tmpd}/abc/template >/dev/null 2>&1 && echo "[ERROR] template in dir not replace" && exit 1 set -e -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpw} - echo "OK" exit 0 diff --git a/tests-ng/link-templates-dir.sh b/tests-ng/link-templates-dir.sh index 8d57133..2c0c74f 100755 --- a/tests-ng/link-templates-dir.sh +++ b/tests-ng/link-templates-dir.sh @@ -57,6 +57,9 @@ echo "dotfiles destination: ${tmpd}" tmpw=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "workdir: ${tmpw}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpw}" # create the config file cfg="${tmps}/config.yaml" @@ -97,8 +100,5 @@ set +e grep '{{@@' ${tmpd}/abc/template >/dev/null 2>&1 && echo "[ERROR] template in dir not replace" && exit 1 set -e -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpw} - echo "OK" exit 0 diff --git a/tests-ng/link-templates.sh b/tests-ng/link-templates.sh index 74d7acb..68a60f9 100755 --- a/tests-ng/link-templates.sh +++ b/tests-ng/link-templates.sh @@ -57,6 +57,9 @@ echo "dotfiles destination: ${tmpd}" tmpw=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "workdir: ${tmpw}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpw}" # create the config file cfg="${tmps}/config.yaml" @@ -90,8 +93,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V [ ! -e ${tmpd}/abc ] && echo "[ERROR] dotfile not installed" && exit 1 [ ! -h ${tmpd}/abc ] && echo "[ERROR] dotfile is not a symlink" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpw} - echo "OK" exit 0 diff --git a/tests-ng/link-value-tests.sh b/tests-ng/link-value-tests.sh index 853fade..7a8a3bc 100755 --- a/tests-ng/link-value-tests.sh +++ b/tests-ng/link-value-tests.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -462,8 +465,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V [ ! -h ${df}/directory ] && echo "directory is not a symlink" && exit 1 [ -h ${df}/directory/file ] && echo "directory/file is a symlink" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/macro-with-globals.sh b/tests-ng/macro-with-globals.sh index f29b6f3..d03e14f 100755 --- a/tests-ng/macro-with-globals.sh +++ b/tests-ng/macro-with-globals.sh @@ -51,6 +51,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -95,8 +98,5 @@ cat ${tmpd}/abc grep 'global_var' ${tmpd}/abc >/dev/null 2>&1 grep 'local_var' ${tmpd}/abc >/dev/null 2>&1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/minversion.sh b/tests-ng/minversion.sh index 2442354..deec8bd 100755 --- a/tests-ng/minversion.sh +++ b/tests-ng/minversion.sh @@ -50,6 +50,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + cfg="${tmps}/config.yaml" cat > ${cfg} << _EOF config: @@ -127,8 +130,5 @@ cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 -V cat ${cfg} grep 'minversion' ${cfg} && echo "minversion added, not needed" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/negative-ignore-no-match.sh b/tests-ng/negative-ignore-no-match.sh index 7b2023a..e0ca76b 100755 --- a/tests-ng/negative-ignore-no-match.sh +++ b/tests-ng/negative-ignore-no-match.sh @@ -78,6 +78,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # some files mkdir -p ${tmpd}/program/ignore_me echo "some data" > ${tmpd}/program/a @@ -109,8 +112,5 @@ pattern to work, it must match a file that is being ignored by a previous ignore cd ${ddpath} | ${bin} install -c ${cfg2} --verbose 2>&1 >/dev/null | grep -F "${patt}" || (echo "dotdrop did not warn when negative ignore pattern did not match an already-ignored file" && exit 1) -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/notemplate.sh b/tests-ng/notemplate.sh index 389f7d7..e8bb451 100755 --- a/tests-ng/notemplate.sh +++ b/tests-ng/notemplate.sh @@ -54,6 +54,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -280,9 +283,5 @@ echo "* normal dotfile" [ ! -e ${tmpd}/fn ] && echo 'not installed' && exit 1 grep 'should not be stripped' ${tmpd}/fn && echo "no templated" && exit 1 - -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/profile-actions.sh b/tests-ng/profile-actions.sh index 307f5cb..c050efe 100755 --- a/tests-ng/profile-actions.sh +++ b/tests-ng/profile-actions.sh @@ -55,6 +55,10 @@ tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` # the action temp tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpa}" + # create the config file cfg="${tmps}/config.yaml" @@ -131,8 +135,5 @@ nb=`wc -l ${tmpa}/post2 | awk '{print $1}'` nb=`wc -l ${tmpa}/naked | awk '{print $1}'` [ "${nb}" -gt "1" ] && echo "action naked executed twice" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpa} - echo "OK" exit 0 diff --git a/tests-ng/profile-dyninclude.sh b/tests-ng/profile-dyninclude.sh index 44db6f9..94bd7c8 100755 --- a/tests-ng/profile-dyninclude.sh +++ b/tests-ng/profile-dyninclude.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" cfg2="${tmps}/sub.yaml" @@ -138,8 +141,5 @@ grep 'subdyncontent' ${tmpd}/abc >/dev/null || (echo "dynvariables 2 not resolve #cat ${tmpd}/abc [ ! -e ${tmpd}/ghi ] && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/profile-dynvariables.sh b/tests-ng/profile-dynvariables.sh index 9455401..813e802 100755 --- a/tests-ng/profile-dynvariables.sh +++ b/tests-ng/profile-dynvariables.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create a shell script export TESTENV="this is my global testenv" scr=`mktemp --suffix='-dotdrop-tests' || mktemp -d` @@ -64,6 +67,9 @@ scr2=`mktemp --suffix='-dotdrop-tests' || mktemp -d` chmod +x ${scr2} echo -e "#!/bin/bash\necho $TESTENV2\n" >> ${scr2} +clear_on_exit "${scr}" +clear_on_exit "${scr2}" + # create the config file cfg="${tmps}/config.yaml" @@ -124,8 +130,5 @@ grep "^cba" ${tmpd}/abc >/dev/null #cat ${tmpd}/abc -## CLEANING -rm -rf ${tmps} ${tmpd} ${scr} ${scr2} - echo "OK" exit 0 diff --git a/tests-ng/profile-undefined-variables.sh b/tests-ng/profile-undefined-variables.sh index 157be19..0e6cf23 100755 --- a/tests-ng/profile-undefined-variables.sh +++ b/tests-ng/profile-undefined-variables.sh @@ -54,6 +54,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -117,8 +120,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p pinclude -V [ ! -e ${tmpd}/abc ] && echo "dotfile not installed" && exit 1 grep main ${tmpd}/abc -## CLEANING -rm -rf ${tmps} ${tmpd} ${scr} ${scr2} - echo "OK" exit 0 diff --git a/tests-ng/re-import.sh b/tests-ng/re-import.sh index 99e1736..1bd7c6c 100755 --- a/tests-ng/re-import.sh +++ b/tests-ng/re-import.sh @@ -45,11 +45,6 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)" # this is the test ################################################################ -clean() -{ - rm -rf ${tmps} ${tmpd} ~/.dotdrop-test -} - # the dotfile source tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` mkdir -p ${tmps}/dotfiles @@ -57,6 +52,10 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "~/.dotdrop-test" + # create the dotfile echo "original" > ${tmpd}/testfile @@ -79,11 +78,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/testfile cat ${cfg} # ensure exists and is not link -[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && clean && exit 1 +[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && exit 1 cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1 grep 'original' ${tmps}/dotfiles/${tmpd}/testfile nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l` -[ "${nb}" != "1" ] && echo 'not 1 entry' && clean && exit 1 +[ "${nb}" != "1" ] && echo 'not 1 entry' && exit 1 # re-import without changing echo "[+] re-import without changes" @@ -91,11 +90,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/testfile cat ${cfg} # test is only once -[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && clean && exit 1 +[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && exit 1 cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1 grep 'original' ${tmps}/dotfiles/${tmpd}/testfile nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l` -[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1 +[ "${nb}" != "1" ] && echo 'two entries!' && exit 1 # re-import with changes echo "[+] re-import with changes" @@ -104,11 +103,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/testfile cat ${cfg} # test is only once -[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && clean && exit 1 +[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && exit 1 cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1 grep 'modified' ${tmps}/dotfiles/${tmpd}/testfile nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l` -[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1 +[ "${nb}" != "1" ] && echo 'two entries!' && exit 1 # ################################################### @@ -119,11 +118,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ~/.dotdrop.test cat ${cfg} # ensure exists and is not link -[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && clean && exit 1 +[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1 cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1 grep 'original' ${tmps}/dotfiles/dotdrop.test nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l` -[ "${nb}" != "1" ] && echo 'not 1 entry' && clean && exit 1 +[ "${nb}" != "1" ] && echo 'not 1 entry' && exit 1 # re-import without changing echo "[+] re-import without changes in home" @@ -131,11 +130,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ~/.dotdrop.test cat ${cfg} # test is only once -[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && clean && exit 1 +[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1 cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1 grep 'original' ${tmps}/dotfiles/dotdrop.test nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l` -[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1 +[ "${nb}" != "1" ] && echo 'two entries!' && exit 1 # re-import with changes echo "[+] re-import with changes in home" @@ -144,14 +143,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ~/.dotdrop.test cat ${cfg} # test is only once -[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && clean && exit 1 +[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1 cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1 grep 'modified' ${tmps}/dotfiles/dotdrop.test nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l` -[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1 - -## CLEANING -clean +[ "${nb}" != "1" ] && echo 'two entries!' && exit 1 echo "OK" exit 0 diff --git a/tests-ng/recinclude.sh b/tests-ng/recinclude.sh index af63484..5cf2b55 100755 --- a/tests-ng/recinclude.sh +++ b/tests-ng/recinclude.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile destination tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -135,8 +138,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p host -V [ "$?" = 0 ] && exit 1 set -e -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/recvariables.sh b/tests-ng/recvariables.sh index 3255718..c1c7369 100755 --- a/tests-ng/recvariables.sh +++ b/tests-ng/recvariables.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -102,8 +105,5 @@ grep '^dvar4: var1 var2 var3' ${tmpd}/abc >/dev/null #cat ${tmpd}/abc -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/remove.sh b/tests-ng/remove.sh index fb7c004..854f047 100755 --- a/tests-ng/remove.sh +++ b/tests-ng/remove.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" cat > ${cfg} << _EOF @@ -173,8 +176,5 @@ cat ${cfg} cat ${cfg} -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/symlink.sh b/tests-ng/symlink.sh index 818cba4..8f8b8c1 100755 --- a/tests-ng/symlink.sh +++ b/tests-ng/symlink.sh @@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + ################################################## # test symlink directory ################################################## @@ -215,8 +218,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V [ ! -h ${tmpd}/abc/file2 ] && echo "does not exist" && exit 1 grep '^p1$' ${tmpd}/abc/file1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/template-link-value.sh b/tests-ng/template-link-value.sh index 418c53f..63e5a96 100755 --- a/tests-ng/template-link-value.sh +++ b/tests-ng/template-link-value.sh @@ -54,6 +54,9 @@ echo "dotfiles source (dotpath): ${tmps}" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "dotfiles destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -145,8 +148,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V [ ! -h ${tmpd}/f/2 ] && echo "[ERROR] children f/2 not linked" && exit 1 [ ! -h ${tmpd}/f/3 ] && echo "[ERROR] children f/3 not linked" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/transformations-template.sh b/tests-ng/transformations-template.sh index a33f604..04f9a78 100755 --- a/tests-ng/transformations-template.sh +++ b/tests-ng/transformations-template.sh @@ -54,6 +54,9 @@ echo "dotfiles source (dotpath): ${tmps}" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "dotfiles destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -144,8 +147,5 @@ grep "^abc; ${tmps}/dotfiles/abc; f_abc$" ${tmps}/dotfiles/abc cat ${tmps}/dotfiles/ghi grep "^ghi; readvar; writevar$" ${tmps}/dotfiles/ghi -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/transformations-with-args.sh b/tests-ng/transformations-with-args.sh index 5815620..20bda59 100755 --- a/tests-ng/transformations-with-args.sh +++ b/tests-ng/transformations-with-args.sh @@ -54,6 +54,9 @@ echo "dotfiles source (dotpath): ${tmps}" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "dotfiles destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -133,8 +136,5 @@ grep "^abc; ${tmps}/dotfiles/abc; arg1; f_abc; arg2$" ${tmps}/dotfiles/abc cat ${tmps}/dotfiles/ghi grep "^ghi; readvar; p1; writevar; f_ghi$" ${tmps}/dotfiles/ghi -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/transformations.sh b/tests-ng/transformations.sh index 93d18f6..5bb44b7 100755 --- a/tests-ng/transformations.sh +++ b/tests-ng/transformations.sh @@ -56,6 +56,9 @@ echo "dotfiles source (dotpath): ${tmps}" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "dotfiles destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -110,6 +113,7 @@ echo 'marker' > ${tmps}/dotfiles/def # create the compressed dotfile tmpx=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmpx}" mkdir -p ${tmpx}/{a,b,c} mkdir -p ${tmpx}/a/{dir1,dir2} # ambiguous redirect ?? @@ -205,6 +209,7 @@ tar -tf ${tmps}/dotfiles/ghi | grep './a/dir1/otherfile' || (echo "otherfile not set -e tmpy=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${tmpy}" tar -xf ${tmps}/dotfiles/ghi -C ${tmpy} content=`cat ${tmpy}/a/somefile` [ "${content}" != "${touched}" ] && echo "bad content" && exit 1 @@ -212,8 +217,5 @@ content=`cat ${tmpy}/a/somefile` # check canary dotfile [ ! -e ${tmps}/dotfiles/def ] && echo "def not found" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpx} ${tmpy} - echo "OK" exit 0 diff --git a/tests-ng/update-ignore-missing.sh b/tests-ng/update-ignore-missing.sh index 21dc2b3..df1fbe9 100755 --- a/tests-ng/update-ignore-missing.sh +++ b/tests-ng/update-ignore-missing.sh @@ -60,6 +60,9 @@ cp -r ${dt}/folder ${tmpd}/ touch ${tmpd}/folder/b mkdir ${tmpd}/folder/c +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" cat > ${cfg} << _EOF @@ -159,8 +162,5 @@ cd ${ddpath} | ${bin} update -f -c ${cfg} --verbose --profile=p1 --key thedotfil [ -e ${dt}/folder/b ] && echo "should not have been updated" && exit 1 [ -e ${dt}/folder/c ] && echo "should not have been updated" && exit 1 -# CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/update-ignore-relative.sh b/tests-ng/update-ignore-relative.sh index 3456284..93db333 100755 --- a/tests-ng/update-ignore-relative.sh +++ b/tests-ng/update-ignore-relative.sh @@ -56,6 +56,10 @@ echo 'a' > ${dt}/a/c/acfile # fs dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` + +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + cp -r ${dt}/a ${tmpd}/ # create the config file @@ -101,8 +105,5 @@ cd ${ddpath} | ${bin} update -f -c ${cfg} --verbose --profile=p1 --key f_abc grep 'b' ${dt}/a/c/acfile >/dev/null || (echo "b not found" && exit 1) [ -e ${dt}/a/newfile ] && echo "new file does not exist" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/update-ignore.sh b/tests-ng/update-ignore.sh index acea979..167c94b 100755 --- a/tests-ng/update-ignore.sh +++ b/tests-ng/update-ignore.sh @@ -63,6 +63,10 @@ echo 'a' > ${dt}/a/c/acfile # fs dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` + +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + cp -r ${dt}/a ${tmpd}/ # create the config file @@ -104,8 +108,5 @@ cd ${ddpath} | ${bin} update -f -c ${cfg} --verbose --profile=p1 --key f_abc grep_or_fail 'b' "${dt}/a/c/acfile" [ -e ${dt}/a/newfile ] && echo "should not have been updated" && exit 1 -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/update-negative-ignore-relative.sh b/tests-ng/update-negative-ignore-relative.sh index 0f9b281..cc67836 100755 --- a/tests-ng/update-negative-ignore-relative.sh +++ b/tests-ng/update-negative-ignore-relative.sh @@ -81,6 +81,10 @@ echo 'a' > ${basedir}/dotfiles/a/c/acfile # the dotfile to be updated tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d` + +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + cp -r ${basedir}/dotfiles/a ${tmpd}/ # create the config file @@ -128,8 +132,5 @@ set -e [ -e ${basedir}/dotfiles/a/newdir/b/c ] && echo "newdir/b/c should not have been updated" && exit 1 [ ! -e ${basedir}/dotfiles/a/newdir/b/d ] && echo "newdir/b/d should have been updated" && exit 1 -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/update-negative-ignore.sh b/tests-ng/update-negative-ignore.sh index 77dc09c..efb18f4 100755 --- a/tests-ng/update-negative-ignore.sh +++ b/tests-ng/update-negative-ignore.sh @@ -93,6 +93,10 @@ echo 'a' > ${basedir}/dotfiles/a/c/acfile # the dotfile to be updated tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d` + +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + cp -r ${basedir}/dotfiles/a ${tmpd}/ # create the config file @@ -138,8 +142,5 @@ grep_or_fail b ${basedir}/dotfiles/a/b/abfile3 [ -e ${basedir}/dotfiles/a/newdir/b/c ] && echo "newdir/b/c should not have been updated" && exit 1 [ ! -e ${basedir}/dotfiles/a/newdir/b/d ] && echo "newdir/b/d should have been updated" && exit 1 -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/update-profile-check.sh b/tests-ng/update-profile-check.sh index e8283b4..02f1e11 100755 --- a/tests-ng/update-profile-check.sh +++ b/tests-ng/update-profile-check.sh @@ -62,6 +62,9 @@ echo "${yori}" > ${dt}/file_y tmpd=`mktemp -d --suffix='-dotdrop-tests-dest' || mktemp -d` touch ${tmpd}/file +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" cat > ${cfg} << _EOF @@ -163,8 +166,5 @@ set -e grep_or_fail "${xori}" "${dt}/file_x" grep_or_fail "${yori}" "${dt}/file_y" -# CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/update-rights.sh b/tests-ng/update-rights.sh index 2e804de..f7207e6 100755 --- a/tests-ng/update-rights.sh +++ b/tests-ng/update-rights.sh @@ -56,6 +56,9 @@ tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` # the dotfile file to be imported tmpf=`mktemp` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # single file echo 'file' > ${tmpf} @@ -95,8 +98,5 @@ cd ${ddpath} | ${bin} update -c ${cfg} -f --verbose ${tmpd} [ "`stat -c '%a' ${tmpd}/dir1/newfile`" != "`stat -c '%a' ${basedir}/dotfiles/${tmpd}/dir1/newfile`" ] && exit 1 [ "`stat -c '%a' ${tmpd}/dir1/file2`" != "`stat -c '%a' ${basedir}/dotfiles/${tmpd}/dir1/file2`" ] && exit 1 -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/update-templates.sh b/tests-ng/update-templates.sh index 67bfcbd..7f56699 100755 --- a/tests-ng/update-templates.sh +++ b/tests-ng/update-templates.sh @@ -57,6 +57,9 @@ echo "dotfiles destination: ${tmpd}" tmpw=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "workdir: ${tmpw}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" +clear_on_exit "${tmpw}" # create the config file cfg="${tmps}/config.yaml" @@ -102,8 +105,5 @@ echo "patching with: ${patch}" eval ${patch} #cat ${tmps}/dotfiles/abc -## CLEANING -rm -rf ${tmps} ${tmpd} ${tmpw} - echo "OK" exit 0 diff --git a/tests-ng/update-with-key.sh b/tests-ng/update-with-key.sh index 8c44d0e..e3c579f 100755 --- a/tests-ng/update-with-key.sh +++ b/tests-ng/update-with-key.sh @@ -54,6 +54,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # originally imported directory echo 'unique' > ${tmpd}/uniquefile uniquefile_key="f_uniquefile" @@ -98,8 +101,5 @@ cd ${ddpath} | ${bin} update -c ${cfg} -k -f --verbose # ensure all changes applied diff ${tmpd} ${basedir}/dotfiles/${tmpd} -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/update.sh b/tests-ng/update.sh index 2535b3d..8d2fcb2 100755 --- a/tests-ng/update.sh +++ b/tests-ng/update.sh @@ -54,6 +54,9 @@ echo "[+] dotpath dir: ${basedir}/dotfiles" # the dotfile to be imported tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +clear_on_exit "${basedir}" +clear_on_exit "${tmpd}" + # single file echo 'unique' > ${tmpd}/uniquefile @@ -126,8 +129,5 @@ diff ${tmpd}/dir1 ${basedir}/dotfiles/${tmpd}/dir1 diff ${tmpd}/uniquefile ${basedir}/dotfiles/${tmpd}/uniquefile [ ! -e ${basedir}/dotfiles/${tmpd}/dir1/sub1/sub2/sub3/file ] && echo "sub does not exist" && exit 1 -## CLEANING -rm -rf ${basedir} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/uservariables.sh b/tests-ng/uservariables.sh index fa7ee81..7f4e6d2 100755 --- a/tests-ng/uservariables.sh +++ b/tests-ng/uservariables.sh @@ -53,6 +53,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -120,8 +123,5 @@ grep '^var2: editedvar2$' ${tmpd}/abc >/dev/null grep '^var3: dynvariables_var3$' ${tmpd}/abc >/dev/null grep '^var4: variables_var4$' ${tmpd}/abc >/dev/null -## CLEANING -rm -rf ${tmps} ${tmpd} ${scr} - echo "OK" exit 0 diff --git a/tests-ng/variables-include.sh b/tests-ng/variables-include.sh index e87b60d..ac11738 100755 --- a/tests-ng/variables-include.sh +++ b/tests-ng/variables-include.sh @@ -54,6 +54,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" @@ -108,8 +111,5 @@ grep '^another test' ${tmpd}/abc >/dev/null #cat ${tmpd}/abc -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/variables.sh b/tests-ng/variables.sh index aa0680c..94f6e60 100755 --- a/tests-ng/variables.sh +++ b/tests-ng/variables.sh @@ -54,6 +54,9 @@ mkdir -p ${tmps}/dotfiles tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` #echo "dotfile destination: ${tmpd}" +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + # create the config file cfg="${tmps}/config.yaml" export dotdrop_test_dst="${tmpd}/def" @@ -104,8 +107,5 @@ grep '^test_def' ${tmpd}/def >/dev/null #cat ${tmpd}/abc -## CLEANING -rm -rf ${tmps} ${tmpd} - echo "OK" exit 0 diff --git a/tests-ng/workdir.sh b/tests-ng/workdir.sh index bdc2d31..f7ca866 100755 --- a/tests-ng/workdir.sh +++ b/tests-ng/workdir.sh @@ -67,6 +67,9 @@ echo "config file: ${cfg}" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "dotfiles destination: ${tmpd}" +clear_on_exit "${tmp}" +clear_on_exit "${tmpd}" + ## RELATIVE echo "RUNNING RELATIVE" cat > ${cfg} << _EOF @@ -124,6 +127,9 @@ echo "config file: ${cfg}" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "dotfiles destination: ${tmpd}" +clear_on_exit "${tmp}" +clear_on_exit "${tmpd}" + cat > ${cfg} << _EOF config: backup: true @@ -176,6 +182,9 @@ echo "config file: ${cfg}" tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` echo "dotfiles destination: ${tmpd}" +clear_on_exit "${tmp}" +clear_on_exit "${tmpd}" + cat > ${cfg} << _EOF config: backup: true @@ -206,8 +215,5 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V [ ! -e ${tmpd}/abc ] && echo "[ERROR] dotfile not installed" && exit 1 [ ! -h ${tmpd}/abc ] && echo "[ERROR] dotfile is not a symlink" && exit 1 -## CLEANING -rm -rf ${tmp} ${tmpd} - echo "OK" exit 0