From 70173bc2948085942e59760ef8178d3bbce2e083 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Mon, 30 May 2022 10:23:26 +0200 Subject: [PATCH] more tests for relative symlink --- tests-ng/symlink-relative.sh | 65 ++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/tests-ng/symlink-relative.sh b/tests-ng/symlink-relative.sh index 44bcd57..8534d3a 100755 --- a/tests-ng/symlink-relative.sh +++ b/tests-ng/symlink-relative.sh @@ -137,9 +137,68 @@ grep 'This dotfile is managed using dotdrop' ${tmpd}/jkl/anotherfile [[ $(realpath --relative-base="${tmpw}" -- "$(realpath ${tmpd}/ghi)") =~ "^/" ]] && echo "ghi not subpath of workdir" && exit 1 [[ $(realpath --relative-base="${tmpw}" -- "$(realpath ${tmpd}/jkl)") =~ ^/ ]] && echo "jkl not subpath of workdir" && exit 1 -## TODO test with install path children of dotpath -echo "TODO more tests" -exit 1 + +############################################################################################################################# + +rm -rf ${tmps} ${tmpd} ${tmpw} + +# the dotfile source +tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` +mkdir -p ${tmps}/dotfiles +tmpd="${tmps}" +mkdir -p ${tmpd} + +clear_on_exit "${tmps}" +clear_on_exit "${tmpd}" + +# create the file +echo "file1" > ${tmps}/dotfiles/abc +mkdir -p ${tmps}/dotfiles/def +echo 'file2' > ${tmps}/dotfiles/def/afile + +# create the config file +cfg="${tmps}/config.yaml" +cat > ${cfg} << _EOF +config: + backup: true + create: true + dotpath: dotfiles + link_dotfile_default: nolink + workdir: ${tmpw} +dotfiles: + f_abc: + dst: ${tmpd}/abc + src: abc + link: relative + f_abc2: + dst: ${tmpd}/abc2 + src: abc + link: absolute + d_def: + dst: ${tmpd}/def + src: def + link: relative +profiles: + p1: + dotfiles: + - f_abc + - f_abc2 + - d_def +_EOF +#cat ${cfg} + +# install +cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V + +# ensure exists and is link +[ ! -h ${tmpd}/abc ] && echo "not a symlink" && exit 1 +[ ! -h ${tmpd}/abc2 ] && echo "not a symlink" && exit 1 +[ ! -h ${tmpd}/def ] && echo "not a symlink" && exit 1 +[ ! -d ${tmpd}/def ] && echo "not a symlink" && exit 1 + +grep 'file1' ${tmpd}/abc +grep 'file1' ${tmpd}/abc2 +grep 'file2' ${tmpd}/def/afile echo "OK" exit 0