1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 19:09:44 +00:00

shellcheck fixes

This commit is contained in:
deadc0de6
2023-01-27 16:44:19 +01:00
committed by deadc0de
parent fd26eb89b3
commit 2f1bbeacee
135 changed files with 4083 additions and 3950 deletions

View File

@@ -28,30 +28,33 @@ cur=$(dirname "$(${rl} "${0}")")
# dotdrop path can be pass as argument
ddpath="${cur}/../"
[ "${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}"
bin="python3 -m dotdrop.dotdrop"
hash coverage 2>/dev/null && bin="coverage run -a --source=dotdrop -m dotdrop.dotdrop" || true
if hash coverage 2>/dev/null; then
bin="coverage run -a --source=dotdrop -m dotdrop.dotdrop"
fi
echo "dotdrop path: ${ddpath}"
echo "pythonpath: ${PYTHONPATH}"
# get the helpers
source ${cur}/helpers
# shellcheck source=tests-ng/helpers
source "${cur}"/helpers
echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)"
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
################################################################
# this is the test
################################################################
# the dotfile source
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
mkdir -p ${tmps}/dotfiles
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
mkdir -p "${tmps}"/dotfiles
echo "dotfiles source (dotpath): ${tmps}"
# the dotfile destination
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
echo "dotfiles destination: ${tmpd}"
clear_on_exit "${tmps}"
@@ -60,7 +63,7 @@ clear_on_exit "${tmpd}"
# create the config file
cfg="${tmps}/config.yaml"
cat > ${cfg} << _EOF
cat > "${cfg}" << _EOF
trans_read:
r_echo_abs_src: echo "\$(cat {0}); {{@@ _dotfile_abs_src @@}}; {2}" > {1}
r_echo_var: echo "\$(cat {0}); {{@@ r_var @@}}; {2}" > {1}
@@ -98,43 +101,43 @@ _EOF
#cat ${cfg}
# create the dotfiles
echo 'abc' > ${tmps}/dotfiles/abc
echo 'marker' > ${tmps}/dotfiles/def
echo 'ghi' > ${tmps}/dotfiles/ghi
echo 'abc' > "${tmps}"/dotfiles/abc
echo 'marker' > "${tmps}"/dotfiles/def
echo 'ghi' > "${tmps}"/dotfiles/ghi
###########################
# test install and compare
###########################
# install
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -b -V
# check dotfile
[ ! -e ${tmpd}/def ] && exit 1
[ ! -e ${tmpd}/abc ] && exit 1
[ ! -e ${tmpd}/ghi ] && exit 1
grep marker ${tmpd}/def
cat ${tmpd}/abc
grep "^abc; ${tmps}/dotfiles/abc; arg1$" ${tmpd}/abc
cat ${tmpd}/ghi
grep "^ghi; readvar; p1$" ${tmpd}/ghi
[ ! -e "${tmpd}"/def ] && exit 1
[ ! -e "${tmpd}"/abc ] && exit 1
[ ! -e "${tmpd}"/ghi ] && exit 1
grep marker "${tmpd}"/def
cat "${tmpd}"/abc
grep "^abc; ${tmps}/dotfiles/abc; arg1$" "${tmpd}"/abc
cat "${tmpd}"/ghi
grep "^ghi; readvar; p1$" "${tmpd}"/ghi
###########################
# test update
###########################
# update single file
cd ${ddpath} | ${bin} update -f -k -c ${cfg} -p p1 -b -V
cd "${ddpath}" | ${bin} update -f -k -c "${cfg}" -p p1 -b -V
# checks
[ ! -e ${tmps}/dotfiles/def ] && exit 1
[ ! -e ${tmps}/dotfiles/abc ] && exit 1
[ ! -e ${tmps}/dotfiles/ghi ] && exit 1
grep marker ${tmps}/dotfiles/def
cat ${tmps}/dotfiles/abc
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
[ ! -e "${tmps}"/dotfiles/def ] && exit 1
[ ! -e "${tmps}"/dotfiles/abc ] && exit 1
[ ! -e "${tmps}"/dotfiles/ghi ] && exit 1
grep marker "${tmps}"/dotfiles/def
cat "${tmps}"/dotfiles/abc
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
echo "OK"
exit 0