1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-16 02:01:11 +00:00
This commit is contained in:
deadc0de6
2023-01-28 10:45:45 +01:00
committed by deadc0de
parent 2f1bbeacee
commit 0c3fe55d47
5 changed files with 19 additions and 18 deletions

View File

@@ -51,7 +51,6 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sg
# dotdrop directory # dotdrop directory
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d) basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
dotfiles="${basedir}/dotfiles"
echo "dotdrop dir: ${basedir}" echo "dotdrop dir: ${basedir}"
# the dotfile # the dotfile
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d) tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)

View File

@@ -28,7 +28,7 @@ cur=$(dirname "$(${rl} "${0}")")
# dotdrop path can be pass as argument # dotdrop path can be pass as argument
ddpath="${cur}/../" ddpath="${cur}/../"
[ "${1}" != "" ] && ddpath="${1}" [ "${1}" != "" ] && ddpath="${1}"
[ ! -d ${ddpath} ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1 [ ! -d "${ddpath}" ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
export PYTHONPATH="${ddpath}:${PYTHONPATH}" export PYTHONPATH="${ddpath}:${PYTHONPATH}"
bin="python3 -m dotdrop.dotdrop" bin="python3 -m dotdrop.dotdrop"
@@ -40,48 +40,49 @@ echo "dotdrop path: ${ddpath}"
echo "pythonpath: ${PYTHONPATH}" echo "pythonpath: ${PYTHONPATH}"
# get the helpers # get the helpers
source ${cur}/helpers # shellcheck source=tests-ng/helpers
source "${cur}"/helpers
echo -e "$(tput setaf 6)==> RUNNING $(basename ${BASH_SOURCE[0]}) <==$(tput sgr0)" echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
################################################################ ################################################################
# this is the test # this is the test
################################################################ ################################################################
# the dotfile source # the dotfile source
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
mkdir -p ${tmps}/dotfiles mkdir -p "${tmps}"/dotfiles
# the dotfile destination # the dotfile destination
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
clear_on_exit "${tmps}" clear_on_exit "${tmps}"
clear_on_exit "${tmpd}" clear_on_exit "${tmpd}"
# dotpath # dotpath
dotpath="${tmps}/dotfiles" dotpath="${tmps}/dotfiles"
mkdir -p ${dotpath} mkdir -p "${dotpath}"
# create the dotfile to import # create the dotfile to import
dt="${tmpd}/directory" dt="${tmpd}/directory"
mkdir -p ${dt} mkdir -p "${dt}"
# subdir # subdir
dtsub1="${dt}/sub1" dtsub1="${dt}/sub1"
mkdir -p ${dtsub1} mkdir -p "${dtsub1}"
dtsub2="${dt}/sub2" dtsub2="${dt}/sub2"
mkdir -p ${dtsub2} mkdir -p "${dtsub2}"
dtsub3="${dtsub1}/subsub1" dtsub3="${dtsub1}/subsub1"
mkdir -p ${dtsub3} mkdir -p "${dtsub3}"
# files # files
f1="${dt}/file" f1="${dt}/file"
subf1="${dtsub1}/file" subf1="${dtsub1}/file"
subf2="${dtsub2}/file" subf2="${dtsub2}/file"
subf3="${dtsub3}/file" subf3="${dtsub3}/file"
touch ${f1} ${subf1} ${subf2} ${subf3} touch "${f1}" "${subf1}" "${subf2}" "${subf3}"
# create the config file # create the config file
cfg="${tmps}/config.yaml" cfg="${tmps}/config.yaml"
cat > ${cfg} << _EOF cat > "${cfg}" << _EOF
config: config:
backup: true backup: true
create: true create: true
@@ -91,10 +92,10 @@ profiles:
_EOF _EOF
# import # import
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V --link=link_children ${dt} cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V --link=link_children "${dt}"
# check is set to link_children # check is set to link_children
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "d_`basename "${dt}"`" | grep ',link:link_children,' cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "d_$(basename "${dt}")" | grep ',link:link_children,'
# checks file exists in dotpath # checks file exists in dotpath
[ ! -e "${dotpath}"/"${dt}" ] && echo "dotfile not imported" && exit 1 [ ! -e "${dotpath}"/"${dt}" ] && echo "dotfile not imported" && exit 1

View File

@@ -114,7 +114,7 @@ echo "second" > "${tmps}"/dotfiles/second
echo "third" > "${tmps}"/dotfiles/third echo "third" > "${tmps}"/dotfiles/third
attempts="3" attempts="3"
for ((i=0;i<${attempts};i++)); do for ((i=0;i<attempts;i++)); do
# install # install
cd "${ddpath}" | ${bin} install -w 1 -f -c "${cfg}" -p p0 -V cd "${ddpath}" | ${bin} install -w 1 -f -c "${cfg}" -p p0 -V

View File

@@ -91,7 +91,7 @@ cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | cut -f1 -d',' | grep '_top_
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | cut -f1 -d',' | grep '_mutt_sub' | grep -q 'd_' cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | cut -f1 -d',' | grep '_mutt_sub' | grep -q 'd_'
# pimping # pimping
rm -rf "${tmps}"/* rm -rf "${tmps:?}"/*
cat > "${cfg}" << _EOF cat > "${cfg}" << _EOF
config: config:

View File

@@ -104,6 +104,7 @@ echo "tail" >> "${tmpd}"/abc
set +e set +e
patch=$(cd "${ddpath}" | ${bin} update -P -p p1 -k f_abc --cfg "${cfg}" 2>&1 | grep 'try patching with' | sed 's/"//g') patch=$(cd "${ddpath}" | ${bin} update -P -p p1 -k f_abc --cfg "${cfg}" 2>&1 | grep 'try patching with' | sed 's/"//g')
set -e set -e
# shellcheck disable=SC2001
patch=$(echo "${patch}" | sed 's/^.*: //g') patch=$(echo "${patch}" | sed 's/^.*: //g')
echo "patching with: ${patch}" echo "patching with: ${patch}"
eval "${patch}" eval "${patch}"