mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-09 10:39:17 +00:00
shellcheck fixes
This commit is contained in:
15
completion/generate.sh
vendored
15
completion/generate.sh
vendored
@@ -34,11 +34,11 @@ dt_zsh="${compl}/_dotdrop-completion.zsh"
|
|||||||
dt_bash="${compl}/dotdrop-completion.bash"
|
dt_bash="${compl}/dotdrop-completion.bash"
|
||||||
|
|
||||||
# generate for dotdrop.sh
|
# generate for dotdrop.sh
|
||||||
cd ${cur}/..
|
cd "${cur}"/..
|
||||||
docopt-completion ./dotdrop.sh --manual-zsh
|
docopt-completion ./dotdrop.sh --manual-zsh
|
||||||
mv ./_dotdrop.sh ${dtsh_zsh}
|
mv ./_dotdrop.sh "${dtsh_zsh}"
|
||||||
docopt-completion ./dotdrop.sh --manual-bash
|
docopt-completion ./dotdrop.sh --manual-bash
|
||||||
mv ./dotdrop.sh.sh ${dtsh_bash}
|
mv ./dotdrop.sh.sh "${dtsh_bash}"
|
||||||
|
|
||||||
# generate for dotdrop
|
# generate for dotdrop
|
||||||
vbin="virtualenv"
|
vbin="virtualenv"
|
||||||
@@ -46,18 +46,19 @@ if ! hash ${vbin}; then
|
|||||||
echo "\"${vbin}\" not found!"
|
echo "\"${vbin}\" not found!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd ${cur}/..
|
cd "${cur}"/..
|
||||||
venv="/tmp/dotdrop-venv"
|
venv="/tmp/dotdrop-venv"
|
||||||
${vbin} -p python3 ${venv}
|
${vbin} -p python3 ${venv}
|
||||||
|
# shellcheck source=/dev/null
|
||||||
source ${venv}/bin/activate
|
source ${venv}/bin/activate
|
||||||
python setup.py install
|
python setup.py install
|
||||||
cd /tmp
|
cd /tmp
|
||||||
docopt-completion dotdrop --manual-zsh
|
docopt-completion dotdrop --manual-zsh
|
||||||
mv ./_dotdrop ${dt_zsh}
|
mv ./_dotdrop "${dt_zsh}"
|
||||||
docopt-completion dotdrop --manual-bash
|
docopt-completion dotdrop --manual-bash
|
||||||
mv ./dotdrop.sh ${dt_bash}
|
mv ./dotdrop.sh "${dt_bash}"
|
||||||
deactivate
|
deactivate
|
||||||
rm -rf ${venv}
|
rm -rf ${venv}
|
||||||
|
|
||||||
# pivot back
|
# pivot back
|
||||||
cd ${opwd}
|
cd "${opwd}"
|
||||||
|
|||||||
4
dotdrop.sh
vendored
4
dotdrop.sh
vendored
@@ -18,8 +18,6 @@ fi
|
|||||||
args=("$@")
|
args=("$@")
|
||||||
cur=$(dirname "$(${rl} "${0}")")
|
cur=$(dirname "$(${rl} "${0}")")
|
||||||
opwd=$(pwd)
|
opwd=$(pwd)
|
||||||
cfg="${cur}/config.yaml"
|
|
||||||
sub="dotdrop"
|
|
||||||
|
|
||||||
# pivot
|
# pivot
|
||||||
cd "${cur}" || { echo "Directory \"${cur}\" doesn't exist, aborting." && exit 1; }
|
cd "${cur}" || { echo "Directory \"${cur}\" doesn't exist, aborting." && exit 1; }
|
||||||
@@ -33,7 +31,7 @@ fi
|
|||||||
# check python executable
|
# check python executable
|
||||||
pybin="python3"
|
pybin="python3"
|
||||||
hash ${pybin} 2>/dev/null || pybin="python"
|
hash ${pybin} 2>/dev/null || pybin="python"
|
||||||
[[ "`${pybin} -V 2>&1`" =~ "Python 3" ]] || { echo "install Python 3" && exit 1; }
|
[[ "$(${pybin} -V 2>&1)" =~ "Python 3" ]] || { echo "install Python 3" && exit 1; }
|
||||||
|
|
||||||
# launch dotdrop
|
# launch dotdrop
|
||||||
PYTHONPATH=dotdrop:${PYTHONPATH} ${pybin} -m dotdrop.dotdrop "${args[@]}"
|
PYTHONPATH=dotdrop:${PYTHONPATH} ${pybin} -m dotdrop.dotdrop "${args[@]}"
|
||||||
|
|||||||
18
packages/genpkg.sh
vendored
18
packages/genpkg.sh
vendored
@@ -8,7 +8,7 @@
|
|||||||
up()
|
up()
|
||||||
{
|
{
|
||||||
# update pkgver
|
# update pkgver
|
||||||
[ "${1}" != "" ] && sed -i "s/^pkgver=.*$/pkgver=${1}/g" ${pkgfile}
|
[ "${1}" != "" ] && sed -i "s/^pkgver=.*$/pkgver=${1}/g" "${pkgfile}"
|
||||||
# create srcinfo
|
# create srcinfo
|
||||||
rm -f .SRCINFO
|
rm -f .SRCINFO
|
||||||
makepkg --printsrcinfo > .SRCINFO
|
makepkg --printsrcinfo > .SRCINFO
|
||||||
@@ -24,10 +24,10 @@ if ! ${rl} "${0}" >/dev/null 2>&1; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# cur
|
# cur
|
||||||
cur=`dirname $(${rl} "${0}")`
|
cur=$(dirname "$(${rl} "${0}")")
|
||||||
opwd=`pwd`
|
opwd=$(pwd)
|
||||||
pkgfile="PKGBUILD"
|
pkgfile="PKGBUILD"
|
||||||
cd ${cur}
|
cd "${cur}" || exit 1
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# update arch package
|
# update arch package
|
||||||
@@ -35,10 +35,10 @@ cd ${cur}
|
|||||||
########################
|
########################
|
||||||
dir="arch-dotdrop"
|
dir="arch-dotdrop"
|
||||||
echo "doing ${dir} ..."
|
echo "doing ${dir} ..."
|
||||||
cd ${dir}
|
cd ${dir} || exit 1
|
||||||
version="`git describe --abbrev=0 --tags | sed 's/^v//g'`"
|
version="$(git describe --abbrev=0 --tags | sed 's/^v//g')"
|
||||||
up ${version}
|
up "${version}"
|
||||||
cd ${OLDPWD}
|
cd "${OLDPWD}" || exit 1
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
## update arch package
|
## update arch package
|
||||||
@@ -53,4 +53,4 @@ cd ${OLDPWD}
|
|||||||
#cd ${OLDPWD}
|
#cd ${OLDPWD}
|
||||||
|
|
||||||
# pivot back
|
# pivot back
|
||||||
cd ${opwd}
|
cd "${opwd}" || exit
|
||||||
|
|||||||
1
scripts/dotdrop-version-manager.sh
vendored
1
scripts/dotdrop-version-manager.sh
vendored
@@ -104,6 +104,7 @@ need_update_stable()
|
|||||||
last=$(get_latest)
|
last=$(get_latest)
|
||||||
cur=$(get_current_tag)
|
cur=$(get_current_tag)
|
||||||
# get short tag if on a lightweight tag
|
# get short tag if on a lightweight tag
|
||||||
|
# shellcheck disable=SC2001
|
||||||
tag=$(echo "$cur" | sed 's/\(v.*\)-[0-9]*.-.*$/\1/g')
|
tag=$(echo "$cur" | sed 's/\(v.*\)-[0-9]*.-.*$/\1/g')
|
||||||
if [ "${tag}" != "${last}" ]; then
|
if [ "${tag}" != "${last}" ]; then
|
||||||
echo "new stable version available: ${last}" && exit 1
|
echo "new stable version available: ${last}" && exit 1
|
||||||
|
|||||||
8
test-ng.sh
vendored
8
test-ng.sh
vendored
@@ -13,13 +13,13 @@ if ! ${rl} "${0}" >/dev/null 2>&1; then
|
|||||||
echo "\"${rl}\" not found!" && exit 1
|
echo "\"${rl}\" not found!" && exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cur=`dirname $(${rl} "${0}")`
|
cur=$(dirname "$(${rl} "${0}")")
|
||||||
|
|
||||||
tmpworkdir="/tmp/dotdrop-tests-workdir"
|
tmpworkdir="/tmp/dotdrop-tests-workdir"
|
||||||
export DOTDROP_WORKDIR="${tmpworkdir}"
|
export DOTDROP_WORKDIR="${tmpworkdir}"
|
||||||
|
|
||||||
workers=${DOTDROP_WORKERS}
|
workers=${DOTDROP_WORKERS}
|
||||||
if [ ! -z ${workers} ]; then
|
if [ -n "${workers}" ]; then
|
||||||
DOTDROP_WORKERS=${workers}
|
DOTDROP_WORKERS=${workers}
|
||||||
echo "ENABLE workers: ${workers}"
|
echo "ENABLE workers: ${workers}"
|
||||||
fi
|
fi
|
||||||
@@ -28,8 +28,8 @@ fi
|
|||||||
export DOTDROP_DEBUG="yes"
|
export DOTDROP_DEBUG="yes"
|
||||||
unset DOTDROP_FORCE_NODEBUG
|
unset DOTDROP_FORCE_NODEBUG
|
||||||
workdir_tmp_exists="no"
|
workdir_tmp_exists="no"
|
||||||
[ -d "~/.config/dotdrop/tmp" ] && workdir_tmp_exists="yes"
|
[ -d "${HOME}/.config/dotdrop/tmp" ] && workdir_tmp_exists="yes"
|
||||||
if [ -z ${GITHUB_WORKFLOW} ]; then
|
if [ -z "${GITHUB_WORKFLOW}" ]; then
|
||||||
## local
|
## local
|
||||||
export COVERAGE_FILE=
|
export COVERAGE_FILE=
|
||||||
tests-ng/tests-launcher.py
|
tests-ng/tests-launcher.py
|
||||||
|
|||||||
31
test-syntax.sh
vendored
31
test-syntax.sh
vendored
@@ -6,7 +6,27 @@
|
|||||||
#set -ev
|
#set -ev
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# versions
|
# test shell scripts
|
||||||
|
if ! which shellcheck >/dev/null 2>&1; then
|
||||||
|
echo "Install shellcheck"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "shellcheck version:"
|
||||||
|
shellcheck --version
|
||||||
|
# SC2002: Useless cat
|
||||||
|
# SC2126: Consider using grep -c instead of grep|wc -l
|
||||||
|
# SC2129: Consider using { cmd1; cmd2; } >> file instead of individual redirects
|
||||||
|
# SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?
|
||||||
|
find . -iname '*.sh' | while read -r script; do
|
||||||
|
shellcheck -x \
|
||||||
|
-e SC2002 \
|
||||||
|
-e SC2126 \
|
||||||
|
-e SC2129 \
|
||||||
|
-e SC2181 \
|
||||||
|
"${script}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# python tools versions
|
||||||
echo "pylint version:"
|
echo "pylint version:"
|
||||||
pylint --version
|
pylint --version
|
||||||
echo "pycodestyle version:"
|
echo "pycodestyle version:"
|
||||||
@@ -16,7 +36,10 @@ pyflakes --version
|
|||||||
|
|
||||||
# PEP8 tests
|
# PEP8 tests
|
||||||
which pycodestyle >/dev/null 2>&1
|
which pycodestyle >/dev/null 2>&1
|
||||||
[ "$?" != "0" ] && echo "Install pycodestyle" && exit 1
|
if ! which pycodestyle >/dev/null 2>&1; then
|
||||||
|
echo "Install pycodestyle"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
echo "testing with pycodestyle"
|
echo "testing with pycodestyle"
|
||||||
# W503: Line break occurred before a binary operator
|
# W503: Line break occurred before a binary operator
|
||||||
# W504: Line break occurred after a binary operator
|
# W504: Line break occurred after a binary operator
|
||||||
@@ -68,8 +91,8 @@ pylint \
|
|||||||
set +e
|
set +e
|
||||||
exceptions="save_uservariables_name\|@@\|diff_cmd\|original,\|modified,"
|
exceptions="save_uservariables_name\|@@\|diff_cmd\|original,\|modified,"
|
||||||
# f-string errors and missing f literal
|
# f-string errors and missing f literal
|
||||||
find dotdrop/ -iname '*.py' -exec grep --with-filename -n -v "f'" {} \; | grep -v "{'" | grep -v "${exceptions}" | grep "'.*}" && echo "bad string format (1): ${errs}" && exit 1
|
find dotdrop/ -iname '*.py' -exec grep --with-filename -n -v "f'" {} \; | grep -v "{'" | grep -v "${exceptions}" | grep "'.*}" && echo "bad string format (1)" && exit 1
|
||||||
find dotdrop/ -iname '*.py' -exec grep --with-filename -n -v 'f"' {} \; | grep -v "f'" | grep -v '{"' | grep -v "${exceptions}" | grep '".*}' && echo "bad string format (2): ${errs}" && exit 1
|
find dotdrop/ -iname '*.py' -exec grep --with-filename -n -v 'f"' {} \; | grep -v "f'" | grep -v '{"' | grep -v "${exceptions}" | grep '".*}' && echo "bad string format (2)" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "syntax OK"
|
echo "syntax OK"
|
||||||
7
test-unittest.sh
vendored
7
test-unittest.sh
vendored
@@ -13,16 +13,15 @@ if ! ${rl} "${0}" >/dev/null 2>&1; then
|
|||||||
echo "\"${rl}\" not found!" && exit 1
|
echo "\"${rl}\" not found!" && exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cur=`dirname $(${rl} "${0}")`
|
cur=$(dirname "$(${rl} "${0}")")
|
||||||
|
|
||||||
workers=${DOTDROP_WORKERS}
|
if [ -n "${DOTDROP_WORKERS}" ]; then
|
||||||
if [ ! -z ${workers} ]; then
|
|
||||||
unset DOTDROP_WORKERS
|
unset DOTDROP_WORKERS
|
||||||
echo "DISABLE workers"
|
echo "DISABLE workers"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# execute tests with coverage
|
# execute tests with coverage
|
||||||
if [ -z ${GITHUB_WORKFLOW} ]; then
|
if [ -z "${GITHUB_WORKFLOW}" ]; then
|
||||||
## local
|
## local
|
||||||
export COVERAGE_FILE=
|
export COVERAGE_FILE=
|
||||||
# do not print debugs when running tests (faster)
|
# do not print debugs when running tests (faster)
|
||||||
|
|||||||
47
tests-ng/actions-args-template.sh
vendored
47
tests-ng/actions-args-template.sh
vendored
@@ -28,19 +28,22 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
@@ -61,12 +64,12 @@ should_grep() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# the action temp
|
# the action temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
# 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}"
|
||||||
@@ -75,7 +78,7 @@ clear_on_exit "${tmpa}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
pre:
|
pre:
|
||||||
preaction: "echo {0} > {1}"
|
preaction: "echo {0} > {1}"
|
||||||
@@ -123,23 +126,23 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo 'test' > ${tmps}/dotfiles/abc
|
echo 'test' > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks action
|
# checks action
|
||||||
[ ! -e ${tmpa}/pre ] && echo 'pre action not executed' && exit 1
|
[ ! -e "${tmpa}"/pre ] && echo 'pre action not executed' && exit 1
|
||||||
[ ! -e ${tmpa}/post ] && echo 'post action not executed' && exit 1
|
[ ! -e "${tmpa}"/post ] && echo 'post action not executed' && exit 1
|
||||||
[ ! -e ${tmpa}/naked ] && echo 'naked action not executed' && exit 1
|
[ ! -e "${tmpa}"/naked ] && echo 'naked action not executed' && exit 1
|
||||||
[ ! -e ${tmpa}/profile ] && echo 'profile action not executed' && exit 1
|
[ ! -e "${tmpa}"/profile ] && echo 'profile action not executed' && exit 1
|
||||||
[ ! -e ${tmpa}/dyn ] && echo 'dynamic acton action not executed' && exit 1
|
[ ! -e "${tmpa}"/dyn ] && echo 'dynamic acton action not executed' && exit 1
|
||||||
should_grep pre_var ${tmpa}/pre
|
should_grep pre_var "${tmpa}"/pre
|
||||||
should_grep post_var ${tmpa}/post
|
should_grep post_var "${tmpa}"/post
|
||||||
should_grep naked_var ${tmpa}/naked
|
should_grep naked_var "${tmpa}"/naked
|
||||||
should_grep profile_var ${tmpa}/profile
|
should_grep profile_var "${tmpa}"/profile
|
||||||
should_grep profile_var_2 ${tmpa}/profile
|
should_grep profile_var_2 "${tmpa}"/profile
|
||||||
should_grep "$USER" ${tmpa}/dyn
|
should_grep "$USER" "${tmpa}"/dyn
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
51
tests-ng/actions-args.sh
vendored
51
tests-ng/actions-args.sh
vendored
@@ -28,31 +28,34 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# the action temp
|
# the action temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
# 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 "${tmpa}"
|
clear_on_exit "${tmpa}"
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
pre:
|
pre:
|
||||||
preaction: echo '{0} {1}' > ${tmpa}/pre
|
preaction: echo '{0} {1}' > ${tmpa}/pre
|
||||||
@@ -92,29 +95,29 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 --verbose
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --verbose
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpa}/pre ] && echo "pre arg action not found" && exit 1
|
[ ! -e "${tmpa}"/pre ] && echo "pre arg action not found" && exit 1
|
||||||
grep test1 ${tmpa}/pre >/dev/null
|
grep test1 "${tmpa}"/pre >/dev/null
|
||||||
grep test2 ${tmpa}/pre >/dev/null
|
grep test2 "${tmpa}"/pre >/dev/null
|
||||||
|
|
||||||
[ ! -e ${tmpa}/post ] && echo "post arg action not found" && exit 1
|
[ ! -e "${tmpa}"/post ] && echo "post arg action not found" && exit 1
|
||||||
grep test3 ${tmpa}/post >/dev/null
|
grep test3 "${tmpa}"/post >/dev/null
|
||||||
grep test4 ${tmpa}/post >/dev/null
|
grep test4 "${tmpa}"/post >/dev/null
|
||||||
grep test5 ${tmpa}/post >/dev/null
|
grep test5 "${tmpa}"/post >/dev/null
|
||||||
|
|
||||||
[ ! -e ${tmpa}/naked ] && echo "naked arg action not found" && exit 1
|
[ ! -e "${tmpa}"/naked ] && echo "naked arg action not found" && exit 1
|
||||||
grep "test6 something" ${tmpa}/naked >/dev/null
|
grep "test6 something" "${tmpa}"/naked >/dev/null
|
||||||
|
|
||||||
[ ! -e ${tmpa}/empty ] && echo "empty arg action not found" && exit 1
|
[ ! -e "${tmpa}"/empty ] && echo "empty arg action not found" && exit 1
|
||||||
grep empty ${tmpa}/empty >/dev/null
|
grep empty "${tmpa}"/empty >/dev/null
|
||||||
|
|
||||||
[ ! -e ${tmpa}/tgt ] && echo "tgt arg action not found" && exit 1
|
[ ! -e "${tmpa}"/tgt ] && echo "tgt arg action not found" && exit 1
|
||||||
grep tgt ${tmpa}/tgt >/dev/null
|
grep tgt "${tmpa}"/tgt >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
61
tests-ng/actions-default.sh
vendored
61
tests-ng/actions-default.sh
vendored
@@ -28,31 +28,34 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# the action temp
|
# the action temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
# 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}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpa}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
pre:
|
pre:
|
||||||
failpre: "false"
|
failpre: "false"
|
||||||
@@ -99,37 +102,37 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo 'test' > ${tmps}/dotfiles/abc
|
echo 'test' > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks pre action
|
# checks pre action
|
||||||
[ ! -e ${tmpa}/pre ] && echo 'pre action not executed' && exit 1
|
[ ! -e "${tmpa}"/pre ] && echo 'pre action not executed' && exit 1
|
||||||
[ ! -e ${tmpa}/preinside ] && echo 'pre action not executed' && exit 1
|
[ ! -e "${tmpa}"/preinside ] && echo 'pre action not executed' && exit 1
|
||||||
grep pre ${tmpa}/pre >/dev/null
|
grep pre "${tmpa}"/pre >/dev/null
|
||||||
grep preinside ${tmpa}/preinside >/dev/null
|
grep preinside "${tmpa}"/preinside >/dev/null
|
||||||
# checks post action
|
# checks post action
|
||||||
[ ! -e ${tmpa}/post ] && echo 'post action not executed' && exit 1
|
[ ! -e "${tmpa}"/post ] && echo 'post action not executed' && exit 1
|
||||||
[ ! -e ${tmpa}/postinside ] && echo 'post action not executed' && exit 1
|
[ ! -e "${tmpa}"/postinside ] && echo 'post action not executed' && exit 1
|
||||||
grep post ${tmpa}/post >/dev/null
|
grep post "${tmpa}"/post >/dev/null
|
||||||
grep postinside ${tmpa}/postinside >/dev/null
|
grep postinside "${tmpa}"/postinside >/dev/null
|
||||||
# checks naked action
|
# checks naked action
|
||||||
[ ! -e ${tmpa}/naked ] && echo 'naked action not executed' && exit 1
|
[ ! -e "${tmpa}"/naked ] && echo 'naked action not executed' && exit 1
|
||||||
[ ! -e ${tmpa}/nakedinside ] && echo 'naked action not executed' && exit 1
|
[ ! -e "${tmpa}"/nakedinside ] && echo 'naked action not executed' && exit 1
|
||||||
grep naked ${tmpa}/naked >/dev/null
|
grep naked "${tmpa}"/naked >/dev/null
|
||||||
grep nakedinside ${tmpa}/nakedinside >/dev/null
|
grep nakedinside "${tmpa}"/nakedinside >/dev/null
|
||||||
|
|
||||||
# test default action run
|
# test default action run
|
||||||
cd ${ddpath} | ${bin} install -fa -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -fa -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
cnt=`cat ${tmpa}/append | wc -l`
|
cnt=$(cat "${tmpa}"/append | wc -l)
|
||||||
[ "${cnt}" != "2" ] && echo "default_actions not run on -a" && exit 1
|
[ "${cnt}" != "2" ] && echo "default_actions not run on -a" && exit 1
|
||||||
|
|
||||||
# clear
|
# clear
|
||||||
rm -f ${tmpa}/naked* ${tmpa}/pre* ${tmpa}/post* ${tmpd}/abc
|
rm -f "${tmpa}"/naked* "${tmpa}"/pre* "${tmpa}"/post* "${tmpd}"/abc
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
pre:
|
pre:
|
||||||
failpre: "false"
|
failpre: "false"
|
||||||
@@ -152,9 +155,9 @@ _EOF
|
|||||||
# ensure failing actions make the installation fail
|
# ensure failing actions make the installation fail
|
||||||
# install
|
# install
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
set -e
|
set -e
|
||||||
[ -e ${tmpd}/abc ] && exit 1
|
[ -e "${tmpd}"/abc ] && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
143
tests-ng/actions-empty-dir.sh
vendored
143
tests-ng/actions-empty-dir.sh
vendored
@@ -28,31 +28,34 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# the action temp
|
# the action temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
# 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}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpa}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
clearemptydir: find -L '{0}' -empty -xtype d -delete
|
clearemptydir: find -L '{0}' -empty -xtype d -delete
|
||||||
config:
|
config:
|
||||||
@@ -105,87 +108,87 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir ${tmps}/dotfiles/dir1
|
mkdir "${tmps}"/dotfiles/dir1
|
||||||
mkdir ${tmps}/dotfiles/dir1/empty
|
mkdir "${tmps}"/dotfiles/dir1/empty
|
||||||
echo "to-ignore" > ${tmps}/dotfiles/dir1/empty/this.ignore
|
echo "to-ignore" > "${tmps}"/dotfiles/dir1/empty/this.ignore
|
||||||
mkdir ${tmps}/dotfiles/dir1/not-empty
|
mkdir "${tmps}"/dotfiles/dir1/not-empty
|
||||||
echo "file" > ${tmps}/dotfiles/dir1/not-empty/file
|
echo "file" > "${tmps}"/dotfiles/dir1/not-empty/file
|
||||||
mkdir ${tmps}/dotfiles/dir1/sub
|
mkdir "${tmps}"/dotfiles/dir1/sub
|
||||||
mkdir ${tmps}/dotfiles/dir1/sub/empty
|
mkdir "${tmps}"/dotfiles/dir1/sub/empty
|
||||||
echo "to-ignore-too" > ${tmps}/dotfiles/dir1/sub/empty/that.ignore
|
echo "to-ignore-too" > "${tmps}"/dotfiles/dir1/sub/empty/that.ignore
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir ${tmps}/dotfiles/dir2
|
mkdir "${tmps}"/dotfiles/dir2
|
||||||
mkdir ${tmps}/dotfiles/dir2/empty
|
mkdir "${tmps}"/dotfiles/dir2/empty
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dir2/empty/this.ignore
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dir2/empty/this.ignore
|
||||||
mkdir ${tmps}/dotfiles/dir2/not-empty
|
mkdir "${tmps}"/dotfiles/dir2/not-empty
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dir2/not-empty/file
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dir2/not-empty/file
|
||||||
mkdir ${tmps}/dotfiles/dir2/sub
|
mkdir "${tmps}"/dotfiles/dir2/sub
|
||||||
mkdir ${tmps}/dotfiles/dir2/sub/empty
|
mkdir "${tmps}"/dotfiles/dir2/sub/empty
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dir2/sub/empty/that.ignore
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dir2/sub/empty/that.ignore
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir ${tmps}/dotfiles/dir3
|
mkdir "${tmps}"/dotfiles/dir3
|
||||||
mkdir ${tmps}/dotfiles/dir3/empty
|
mkdir "${tmps}"/dotfiles/dir3/empty
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dir3/empty/this.ignore
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dir3/empty/this.ignore
|
||||||
mkdir ${tmps}/dotfiles/dir3/not-empty
|
mkdir "${tmps}"/dotfiles/dir3/not-empty
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dir3/not-empty/file
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dir3/not-empty/file
|
||||||
mkdir ${tmps}/dotfiles/dir3/sub
|
mkdir "${tmps}"/dotfiles/dir3/sub
|
||||||
mkdir ${tmps}/dotfiles/dir3/sub/empty
|
mkdir "${tmps}"/dotfiles/dir3/sub/empty
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dir3/sub/empty/that.ignore
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dir3/sub/empty/that.ignore
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks normal
|
# checks normal
|
||||||
[ ! -d ${tmpd}/dir1 ] && exit 1
|
[ ! -d "${tmpd}"/dir1 ] && exit 1
|
||||||
[ -d ${tmpd}/dir1/empty ] && exit 1
|
[ -d "${tmpd}"/dir1/empty ] && exit 1
|
||||||
[ -e ${tmpd}/dir1/empty/this.ignore ] && exit 1
|
[ -e "${tmpd}"/dir1/empty/this.ignore ] && exit 1
|
||||||
[ ! -d ${tmpd}/dir1/not-empty ] && exit 1
|
[ ! -d "${tmpd}"/dir1/not-empty ] && exit 1
|
||||||
[ ! -e ${tmpd}/dir1/not-empty/file ] && exit 1
|
[ ! -e "${tmpd}"/dir1/not-empty/file ] && exit 1
|
||||||
[ -d ${tmpd}/dir1/sub ] && exit 1
|
[ -d "${tmpd}"/dir1/sub ] && exit 1
|
||||||
[ -d ${tmpd}/dir1/sub/empty ] && exit 1
|
[ -d "${tmpd}"/dir1/sub/empty ] && exit 1
|
||||||
[ -e ${tmpd}/dir1/sub/empty/that.ignore ] && exit 1
|
[ -e "${tmpd}"/dir1/sub/empty/that.ignore ] && exit 1
|
||||||
grep "file" ${tmpd}/dir1/not-empty/file
|
grep "file" "${tmpd}"/dir1/not-empty/file
|
||||||
|
|
||||||
# checks link_children
|
# checks link_children
|
||||||
[ ! -d ${tmpd}/dir2 ] && exit 1
|
[ ! -d "${tmpd}"/dir2 ] && exit 1
|
||||||
[ ! -h ${tmpd}/dir2/empty ] && exit 1
|
[ ! -h "${tmpd}"/dir2/empty ] && exit 1
|
||||||
[ -e ${tmpd}/dir2/empty/this.ignore ] && exit 1
|
[ -e "${tmpd}"/dir2/empty/this.ignore ] && exit 1
|
||||||
[ ! -d ${tmpd}/dir2/not-empty ] && exit 1
|
[ ! -d "${tmpd}"/dir2/not-empty ] && exit 1
|
||||||
[ ! -h ${tmpd}/dir2/not-empty ] && exit 1
|
[ ! -h "${tmpd}"/dir2/not-empty ] && exit 1
|
||||||
[ ! -e ${tmpd}/dir2/not-empty/file ] && exit 1
|
[ ! -e "${tmpd}"/dir2/not-empty/file ] && exit 1
|
||||||
[ -d ${tmpd}/dir2/sub ] && exit 1
|
[ -d "${tmpd}"/dir2/sub ] && exit 1
|
||||||
[ -d ${tmpd}/dir2/sub/empty ] && exit 1
|
[ -d "${tmpd}"/dir2/sub/empty ] && exit 1
|
||||||
[ -e ${tmpd}/dir2/sub/empty/that.ignore ] && exit 1
|
[ -e "${tmpd}"/dir2/sub/empty/that.ignore ] && exit 1
|
||||||
grep "p1" ${tmpd}/dir2/not-empty/file
|
grep "p1" "${tmpd}"/dir2/not-empty/file
|
||||||
|
|
||||||
# checks link
|
# checks link
|
||||||
[ ! -d ${tmpd}/dir3 ] && exit 1
|
[ ! -d "${tmpd}"/dir3 ] && exit 1
|
||||||
[ ! -h ${tmpd}/dir3 ] && exit 1
|
[ ! -h "${tmpd}"/dir3 ] && exit 1
|
||||||
[ -d ${tmpd}/dir3/empty ] && exit 1
|
[ -d "${tmpd}"/dir3/empty ] && exit 1
|
||||||
[ -e ${tmpd}/dir3/empty/this.ignore ] && exit 1
|
[ -e "${tmpd}"/dir3/empty/this.ignore ] && exit 1
|
||||||
[ ! -d ${tmpd}/dir3/not-empty ] && exit 1
|
[ ! -d "${tmpd}"/dir3/not-empty ] && exit 1
|
||||||
[ ! -e ${tmpd}/dir3/not-empty/file ] && exit 1
|
[ ! -e "${tmpd}"/dir3/not-empty/file ] && exit 1
|
||||||
[ -d ${tmpd}/dir3/sub ] && exit 1
|
[ -d "${tmpd}"/dir3/sub ] && exit 1
|
||||||
[ -d ${tmpd}/dir3/sub/empty ] && exit 1
|
[ -d "${tmpd}"/dir3/sub/empty ] && exit 1
|
||||||
[ -e ${tmpd}/dir3/sub/empty/that.ignore ] && exit 1
|
[ -e "${tmpd}"/dir3/sub/empty/that.ignore ] && exit 1
|
||||||
grep "p1" ${tmpd}/dir3/not-empty/file
|
grep "p1" "${tmpd}"/dir3/not-empty/file
|
||||||
|
|
||||||
# second install won't trigger the action
|
# second install won't trigger the action
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V # 2>&1 | tee ${tmpa}/log
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V # 2>&1 | tee ${tmpa}/log
|
||||||
|
|
||||||
# check normal
|
# check normal
|
||||||
[ -d ${tmpd}/dir1/empty ] && echo "empty directory not cleaned" && exit 1
|
[ -d "${tmpd}"/dir1/empty ] && echo "empty directory not cleaned" && exit 1
|
||||||
[ -d ${tmpd}/dir1/sub/empty ] && echo "empty directory not cleaned" && exit 1
|
[ -d "${tmpd}"/dir1/sub/empty ] && echo "empty directory not cleaned" && exit 1
|
||||||
|
|
||||||
# check link_children
|
# check link_children
|
||||||
[ -d ${tmpd}/dir2/empty ] && echo "empty directory not cleaned" && exit 1
|
[ -d "${tmpd}"/dir2/empty ] && echo "empty directory not cleaned" && exit 1
|
||||||
[ -d ${tmpd}/dir2/sub/empty ] && echo "empty directory not cleaned" && exit 1
|
[ -d "${tmpd}"/dir2/sub/empty ] && echo "empty directory not cleaned" && exit 1
|
||||||
|
|
||||||
# check link
|
# check link
|
||||||
[ -d ${tmpd}/dir3/empty ] && echo "empty directory not cleaned" && exit 1
|
[ -d "${tmpd}"/dir3/empty ] && echo "empty directory not cleaned" && exit 1
|
||||||
[ -d ${tmpd}/dir3/sub/empty ] && echo "empty directory not cleaned" && exit 1
|
[ -d "${tmpd}"/dir3/sub/empty ] && echo "empty directory not cleaned" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
83
tests-ng/actions-pre.sh
vendored
83
tests-ng/actions-pre.sh
vendored
@@ -28,19 +28,22 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
@@ -54,12 +57,12 @@ grep_or_fail()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# the action temp
|
# the action temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
# 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}"
|
||||||
@@ -68,7 +71,7 @@ clear_on_exit "${tmpa}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
pre:
|
pre:
|
||||||
failpre: "false"
|
failpre: "false"
|
||||||
@@ -130,53 +133,53 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo 'test' > ${tmps}/dotfiles/abc
|
echo 'test' > "${tmps}"/dotfiles/abc
|
||||||
echo 'link' > ${tmps}/dotfiles/link
|
echo 'link' > "${tmps}"/dotfiles/link
|
||||||
echo 'fail' > ${tmps}/dotfiles/fail
|
echo 'fail' > "${tmps}"/dotfiles/fail
|
||||||
|
|
||||||
mkdir -p ${tmps}/dotfiles/dir
|
mkdir -p "${tmps}"/dotfiles/dir
|
||||||
echo 'test1' > ${tmps}/dotfiles/dir/file1
|
echo 'test1' > "${tmps}"/dotfiles/dir/file1
|
||||||
echo 'test2' > ${tmps}/dotfiles/dir/file2
|
echo 'test2' > "${tmps}"/dotfiles/dir/file2
|
||||||
|
|
||||||
mkdir -p ${tmps}/dotfiles/dlink
|
mkdir -p "${tmps}"/dotfiles/dlink
|
||||||
echo 'test3' > ${tmps}/dotfiles/dlink/dfile1
|
echo 'test3' > "${tmps}"/dotfiles/dlink/dfile1
|
||||||
echo 'test4' > ${tmps}/dotfiles/dlink/dfile2
|
echo 'test4' > "${tmps}"/dotfiles/dlink/dfile2
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpa}/pre ] && echo 'pre action not executed' && exit 1
|
[ ! -e "${tmpa}"/pre ] && echo 'pre action not executed' && exit 1
|
||||||
grep_or_fail pre ${tmpa}/pre
|
grep_or_fail pre "${tmpa}"/pre
|
||||||
[ ! -e ${tmpa}/naked ] && echo 'naked action not executed' && exit 1
|
[ ! -e "${tmpa}"/naked ] && echo 'naked action not executed' && exit 1
|
||||||
grep_or_fail naked ${tmpa}/naked
|
grep_or_fail naked "${tmpa}"/naked
|
||||||
|
|
||||||
[ ! -e ${tmpa}/multiple ] && echo 'pre action multiple not executed' && exit 1
|
[ ! -e "${tmpa}"/multiple ] && echo 'pre action multiple not executed' && exit 1
|
||||||
grep_or_fail multiple ${tmpa}/multiple
|
grep_or_fail multiple "${tmpa}"/multiple
|
||||||
[ "`wc -l ${tmpa}/multiple | awk '{print $1}'`" -gt "1" ] && echo 'pre action multiple executed twice' && exit 1
|
[ "$(wc -l "${tmpa}"/multiple | awk '{print $1}')" -gt "1" ] && echo 'pre action multiple executed twice' && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/pre2 ] && echo 'pre action 2 not executed' && exit 1
|
[ ! -e "${tmpa}"/pre2 ] && echo 'pre action 2 not executed' && exit 1
|
||||||
grep_or_fail pre2 ${tmpa}/pre2
|
grep_or_fail pre2 "${tmpa}"/pre2
|
||||||
[ ! -e ${tmpa}/naked2 ] && echo 'naked action 2 not executed' && exit 1
|
[ ! -e "${tmpa}"/naked2 ] && echo 'naked action 2 not executed' && exit 1
|
||||||
grep_or_fail naked2 ${tmpa}/naked2
|
grep_or_fail naked2 "${tmpa}"/naked2
|
||||||
|
|
||||||
[ ! -e ${tmpa}/multiple2 ] && echo 'pre action multiple 2 not executed' && exit 1
|
[ ! -e "${tmpa}"/multiple2 ] && echo 'pre action multiple 2 not executed' && exit 1
|
||||||
grep_or_fail multiple2 ${tmpa}/multiple2
|
grep_or_fail multiple2 "${tmpa}"/multiple2
|
||||||
[ "`wc -l ${tmpa}/multiple2 | awk '{print $1}'`" -gt "1" ] && echo 'pre action multiple 2 executed twice' && exit 1
|
[ "$(wc -l "${tmpa}"/multiple2 | awk '{print $1}')" -gt "1" ] && echo 'pre action multiple 2 executed twice' && exit 1
|
||||||
[ ! -e ${tmpa}/naked3 ] && echo 'naked action 3 not executed' && exit 1
|
[ ! -e "${tmpa}"/naked3 ] && echo 'naked action 3 not executed' && exit 1
|
||||||
grep_or_fail naked3 ${tmpa}/naked3
|
grep_or_fail naked3 "${tmpa}"/naked3
|
||||||
|
|
||||||
# remove the pre action result and re-install
|
# remove the pre action result and re-install
|
||||||
rm ${tmpa}/pre
|
rm "${tmpa}"/pre
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
[ -e ${tmpa}/pre ] && echo "pre exists" && exit 1
|
[ -e "${tmpa}"/pre ] && echo "pre exists" && exit 1
|
||||||
|
|
||||||
# ensure failing actions make the installation fail
|
# ensure failing actions make the installation fail
|
||||||
# install
|
# install
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p2 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p2 -V
|
||||||
set -e
|
set -e
|
||||||
[ -e ${tmpd}/fail ] && echo "fail exists" && exit 1
|
[ -e "${tmpd}"/fail ] && echo "fail exists" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
55
tests-ng/actions-template.sh
vendored
55
tests-ng/actions-template.sh
vendored
@@ -28,31 +28,34 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# the action temp
|
# the action temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
# 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}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpa}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
pre:
|
pre:
|
||||||
preaction: "echo {{@@ _dotfile_abs_src @@}} > {0}"
|
preaction: "echo {{@@ _dotfile_abs_src @@}} > {0}"
|
||||||
@@ -88,23 +91,23 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo 'test' > ${tmps}/dotfiles/abc
|
echo 'test' > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks action
|
# checks action
|
||||||
[ ! -e ${tmpa}/pre ] && echo 'pre action not executed' && exit 1
|
[ ! -e "${tmpa}"/pre ] && echo 'pre action not executed' && exit 1
|
||||||
[ ! -e ${tmpa}/post ] && echo 'post action not executed' && exit 1
|
[ ! -e "${tmpa}"/post ] && echo 'post action not executed' && exit 1
|
||||||
[ ! -e ${tmpa}/naked ] && echo 'naked action not executed' && exit 1
|
[ ! -e "${tmpa}"/naked ] && echo 'naked action not executed' && exit 1
|
||||||
grep abc ${tmpa}/pre >/dev/null
|
grep abc "${tmpa}"/pre >/dev/null
|
||||||
grep abc ${tmpa}/post >/dev/null
|
grep abc "${tmpa}"/post >/dev/null
|
||||||
grep abc ${tmpa}/naked >/dev/null
|
grep abc "${tmpa}"/naked >/dev/null
|
||||||
|
|
||||||
# clear
|
# clear
|
||||||
rm -f ${tmpa}/naked* ${tmpa}/pre* ${tmpa}/post* ${tmpd}/abc
|
rm -f "${tmpa}"/naked* "${tmpa}"/pre* "${tmpa}"/post* "${tmpd}"/abc
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
pre:
|
pre:
|
||||||
preaction: "echo {{@@ _dotfile_abs_dst @@}} > ${tmpa}/pre"
|
preaction: "echo {{@@ _dotfile_abs_dst @@}} > ${tmpa}/pre"
|
||||||
@@ -130,15 +133,15 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks action
|
# checks action
|
||||||
[ ! -e ${tmpa}/pre ] && echo 'pre action not executed' && exit 1
|
[ ! -e "${tmpa}"/pre ] && echo 'pre action not executed' && exit 1
|
||||||
[ ! -e ${tmpa}/post ] && echo 'post action not executed' && exit 1
|
[ ! -e "${tmpa}"/post ] && echo 'post action not executed' && exit 1
|
||||||
[ ! -e ${tmpa}/naked ] && echo 'naked action not executed' && exit 1
|
[ ! -e "${tmpa}"/naked ] && echo 'naked action not executed' && exit 1
|
||||||
grep "${tmpd}/abc" ${tmpa}/pre >/dev/null
|
grep "${tmpd}/abc" "${tmpa}"/pre >/dev/null
|
||||||
grep "${tmpd}/abc" ${tmpa}/post >/dev/null
|
grep "${tmpd}/abc" "${tmpa}"/post >/dev/null
|
||||||
grep "${tmpd}/abc" ${tmpa}/naked >/dev/null
|
grep "${tmpd}/abc" "${tmpa}"/naked >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
65
tests-ng/actions.sh
vendored
65
tests-ng/actions.sh
vendored
@@ -28,31 +28,34 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# the action temp
|
# the action temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
# 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}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpa}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
pre:
|
pre:
|
||||||
preaction: echo 'pre' > ${tmpa}/pre
|
preaction: echo 'pre' > ${tmpa}/pre
|
||||||
@@ -105,34 +108,34 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V 2>&1 | tee ${tmpa}/log
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V 2>&1 | tee "${tmpa}"/log
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpa}/pre ] && exit 1
|
[ ! -e "${tmpa}"/pre ] && exit 1
|
||||||
grep pre ${tmpa}/pre >/dev/null
|
grep pre "${tmpa}"/pre >/dev/null
|
||||||
[ ! -e ${tmpa}/post ] && exit 1
|
[ ! -e "${tmpa}"/post ] && exit 1
|
||||||
grep post ${tmpa}/post >/dev/null
|
grep post "${tmpa}"/post >/dev/null
|
||||||
[ ! -e ${tmpa}/naked ] && exit 1
|
[ ! -e "${tmpa}"/naked ] && exit 1
|
||||||
grep naked ${tmpa}/naked >/dev/null
|
grep naked "${tmpa}"/naked >/dev/null
|
||||||
[ ! -e ${tmpa}/pre2 ] && exit 1
|
[ ! -e "${tmpa}"/pre2 ] && exit 1
|
||||||
grep pre2 ${tmpa}/pre2 >/dev/null
|
grep pre2 "${tmpa}"/pre2 >/dev/null
|
||||||
[ ! -e ${tmpa}/post2 ] && exit 1
|
[ ! -e "${tmpa}"/post2 ] && exit 1
|
||||||
grep post ${tmpa}/post2 >/dev/null
|
grep post "${tmpa}"/post2 >/dev/null
|
||||||
[ ! -e ${tmpa}/log ] && exit 1
|
[ ! -e "${tmpa}"/log ] && exit 1
|
||||||
grep "executing \"echo 'naked' > ${tmpa}/naked" ${tmpa}/log >/dev/null
|
grep "executing \"echo 'naked' > ${tmpa}/naked" "${tmpa}"/log >/dev/null
|
||||||
grep "executing \"echo 'silent'" ${tmpa}/log >/dev/null && false
|
grep "executing \"echo 'silent'" "${tmpa}"/log >/dev/null && false
|
||||||
grep "executing silent action \"_silentaction\"" ${tmpa}/log >/dev/null
|
grep "executing silent action \"_silentaction\"" "${tmpa}"/log >/dev/null
|
||||||
[ ! -e ${tmpa}/expandvariable ] && exit 1
|
[ ! -e "${tmpa}"/expandvariable ] && exit 1
|
||||||
grep xxx ${tmpa}/expandvariable >/dev/null
|
grep xxx "${tmpa}"/expandvariable >/dev/null
|
||||||
|
|
||||||
# fake action
|
# fake action
|
||||||
[ ! -e ${tmpa}/fake ] && echo 'fake post action not executed' && exit 1
|
[ ! -e "${tmpa}"/fake ] && echo 'fake post action not executed' && exit 1
|
||||||
grep fake ${tmpa}/fake >/dev/null
|
grep fake "${tmpa}"/fake >/dev/null
|
||||||
[ ! -e ${tmpa}/fake_pre ] && echo 'fake pre action not executed' && exit 1
|
[ ! -e "${tmpa}"/fake_pre ] && echo 'fake pre action not executed' && exit 1
|
||||||
grep 'fake pre' ${tmpa}/fake_pre >/dev/null
|
grep 'fake pre' "${tmpa}"/fake_pre >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
25
tests-ng/bad-diff-cmd.sh
vendored
25
tests-ng/bad-diff-cmd.sh
vendored
@@ -28,31 +28,34 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -63,13 +66,13 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg}
|
cd "${ddpath}" | ${bin} compare -c "${cfg}"
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
|
|
||||||
out=$(cd ${ddpath} | ${bin} compare -c ${cfg})
|
out=$(cd "${ddpath}" | ${bin} compare -c "${cfg}")
|
||||||
echo "${out}" | grep -i 'traceback' && exit 1
|
echo "${out}" | grep -i 'traceback' && exit 1
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -80,10 +83,10 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg}
|
cd "${ddpath}" | ${bin} compare -c "${cfg}"
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
|
|
||||||
out=$(cd ${ddpath} | ${bin} compare -c ${cfg})
|
out=$(cd "${ddpath}" | ${bin} compare -c "${cfg}")
|
||||||
echo "${out}" | grep -i 'traceback' && exit 1
|
echo "${out}" | grep -i 'traceback' && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
73
tests-ng/chmod-compare.sh
vendored
73
tests-ng/chmod-compare.sh
vendored
@@ -27,29 +27,32 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -57,40 +60,40 @@ clear_on_exit "${tmpd}"
|
|||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
dnormal="${tmpd}/dir_normal"
|
dnormal="${tmpd}/dir_normal"
|
||||||
mkdir -p ${dnormal}
|
mkdir -p "${dnormal}"
|
||||||
echo "dir_normal/f1" > ${dnormal}/file1
|
echo "dir_normal/f1" > "${dnormal}"/file1
|
||||||
echo "dir_normal/f2" > ${dnormal}/file2
|
echo "dir_normal/f2" > "${dnormal}"/file2
|
||||||
chmod 777 ${dnormal}
|
chmod 777 "${dnormal}"
|
||||||
|
|
||||||
dlink="${tmpd}/dir_link"
|
dlink="${tmpd}/dir_link"
|
||||||
mkdir -p ${dlink}
|
mkdir -p "${dlink}"
|
||||||
echo "dir_link/f1" > ${dlink}/file1
|
echo "dir_link/f1" > "${dlink}"/file1
|
||||||
echo "dir_link/f2" > ${dlink}/file2
|
echo "dir_link/f2" > "${dlink}"/file2
|
||||||
chmod 777 ${dlink}
|
chmod 777 "${dlink}"
|
||||||
|
|
||||||
dlinkchildren="${tmpd}/dir_link_children"
|
dlinkchildren="${tmpd}/dir_link_children"
|
||||||
mkdir -p ${dlinkchildren}
|
mkdir -p "${dlinkchildren}"
|
||||||
echo "dir_linkchildren/f1" > ${dlinkchildren}/file1
|
echo "dir_linkchildren/f1" > "${dlinkchildren}"/file1
|
||||||
echo "dir_linkchildren/f2" > ${dlinkchildren}/file2
|
echo "dir_linkchildren/f2" > "${dlinkchildren}"/file2
|
||||||
chmod 777 ${dlinkchildren}
|
chmod 777 "${dlinkchildren}"
|
||||||
|
|
||||||
fnormal="${tmpd}/filenormal"
|
fnormal="${tmpd}/filenormal"
|
||||||
echo "filenormal" > ${fnormal}
|
echo "filenormal" > "${fnormal}"
|
||||||
chmod 777 ${fnormal}
|
chmod 777 "${fnormal}"
|
||||||
|
|
||||||
flink="${tmpd}/filelink"
|
flink="${tmpd}/filelink"
|
||||||
echo "filelink" > ${flink}
|
echo "filelink" > "${flink}"
|
||||||
chmod 777 ${flink}
|
chmod 777 "${flink}"
|
||||||
|
|
||||||
echo "f777" > ${tmps}/dotfiles/f777
|
echo "f777" > "${tmps}"/dotfiles/f777
|
||||||
chmod 700 ${tmps}/dotfiles/f777
|
chmod 700 "${tmps}"/dotfiles/f777
|
||||||
|
|
||||||
toimport="${dnormal} ${dlink} ${dlinkchildren} ${fnormal} ${flink}"
|
toimport="${dnormal} ${dlink} ${dlinkchildren} ${fnormal} ${flink}"
|
||||||
|
|
||||||
# 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
|
||||||
@@ -108,27 +111,27 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p1
|
||||||
|
|
||||||
# import
|
# import
|
||||||
for i in ${toimport}; do
|
for i in ${toimport}; do
|
||||||
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 ${i}
|
cd "${ddpath}" | ${bin} import -c "${cfg}" -f -p p1 "${i}"
|
||||||
done
|
done
|
||||||
|
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# patch rights
|
# patch rights
|
||||||
chmod 700 ${dnormal}
|
chmod 700 "${dnormal}"
|
||||||
chmod 700 ${dlink}
|
chmod 700 "${dlink}"
|
||||||
chmod 700 ${dlinkchildren}
|
chmod 700 "${dlinkchildren}"
|
||||||
chmod 700 ${fnormal}
|
chmod 700 "${fnormal}"
|
||||||
chmod 700 ${flink}
|
chmod 700 "${flink}"
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
out=`cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 2>&1`
|
out=$(cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p1 2>&1)
|
||||||
cnt=$(echo "${out}" | grep 'modes differ' | wc -l)
|
cnt=$(echo "${out}" | grep 'modes differ' | wc -l)
|
||||||
set -e
|
set -e
|
||||||
[ "${cnt}" != "5" ] && echo "${out}" && echo "compare modes failed (${cnt}, expecting 5)" && exit 1
|
[ "${cnt}" != "5" ] && echo "${out}" && echo "compare modes failed (${cnt}, expecting 5)" && exit 1
|
||||||
|
|||||||
143
tests-ng/chmod-import.sh
vendored
143
tests-ng/chmod-import.sh
vendored
@@ -29,19 +29,22 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
@@ -50,21 +53,21 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)"
|
|||||||
# $1 file
|
# $1 file
|
||||||
chmod_to_umask()
|
chmod_to_umask()
|
||||||
{
|
{
|
||||||
u=`umask`
|
u=$(umask)
|
||||||
u=`echo ${u} | sed 's/^0*//'`
|
u=$(echo "${u}" | sed 's/^0*//')
|
||||||
if [ -d ${1} ]; then
|
if [ -d "${1}" ]; then
|
||||||
v=$((777 - u))
|
v=$((777 - u))
|
||||||
else
|
else
|
||||||
v=$((666 - u))
|
v=$((666 - u))
|
||||||
fi
|
fi
|
||||||
chmod ${v} ${1}
|
chmod ${v} "${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -72,37 +75,37 @@ clear_on_exit "${tmpd}"
|
|||||||
|
|
||||||
# create the dotfiles
|
# create the dotfiles
|
||||||
dnormal="${tmpd}/dir_normal"
|
dnormal="${tmpd}/dir_normal"
|
||||||
mkdir -p ${dnormal}
|
mkdir -p "${dnormal}"
|
||||||
echo "dir_normal/f1" > ${dnormal}/file1
|
echo "dir_normal/f1" > "${dnormal}"/file1
|
||||||
echo "dir_normal/f2" > ${dnormal}/file2
|
echo "dir_normal/f2" > "${dnormal}"/file2
|
||||||
chmod 777 ${dnormal}
|
chmod 777 "${dnormal}"
|
||||||
|
|
||||||
dlink="${tmpd}/dir_link"
|
dlink="${tmpd}/dir_link"
|
||||||
mkdir -p ${dlink}
|
mkdir -p "${dlink}"
|
||||||
echo "dir_link/f1" > ${dlink}/file1
|
echo "dir_link/f1" > "${dlink}"/file1
|
||||||
echo "dir_link/f2" > ${dlink}/file2
|
echo "dir_link/f2" > "${dlink}"/file2
|
||||||
chmod 777 ${dlink}
|
chmod 777 "${dlink}"
|
||||||
|
|
||||||
dlinkchildren="${tmpd}/dir_link_children"
|
dlinkchildren="${tmpd}/dir_link_children"
|
||||||
mkdir -p ${dlinkchildren}
|
mkdir -p "${dlinkchildren}"
|
||||||
echo "dir_linkchildren/f1" > ${dlinkchildren}/file1
|
echo "dir_linkchildren/f1" > "${dlinkchildren}"/file1
|
||||||
echo "dir_linkchildren/f2" > ${dlinkchildren}/file2
|
echo "dir_linkchildren/f2" > "${dlinkchildren}"/file2
|
||||||
chmod 777 ${dlinkchildren}
|
chmod 777 "${dlinkchildren}"
|
||||||
|
|
||||||
fnormal="${tmpd}/filenormal"
|
fnormal="${tmpd}/filenormal"
|
||||||
echo "filenormal" > ${fnormal}
|
echo "filenormal" > "${fnormal}"
|
||||||
chmod 777 ${fnormal}
|
chmod 777 "${fnormal}"
|
||||||
|
|
||||||
flink="${tmpd}/filelink"
|
flink="${tmpd}/filelink"
|
||||||
echo "filelink" > ${flink}
|
echo "filelink" > "${flink}"
|
||||||
chmod 777 ${flink}
|
chmod 777 "${flink}"
|
||||||
|
|
||||||
toimport="${dnormal} ${dlink} ${dlinkchildren} ${fnormal} ${flink}"
|
toimport="${dnormal} ${dlink} ${dlinkchildren} ${fnormal} ${flink}"
|
||||||
|
|
||||||
# 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
|
||||||
@@ -114,20 +117,20 @@ _EOF
|
|||||||
|
|
||||||
# import without --preserve-mode
|
# import without --preserve-mode
|
||||||
for i in ${toimport}; do
|
for i in ${toimport}; do
|
||||||
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 -V ${i}
|
cd "${ddpath}" | ${bin} import -c "${cfg}" -f -p p1 -V "${i}"
|
||||||
done
|
done
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# list files
|
# list files
|
||||||
cd ${ddpath} | ${bin} detail -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} detail -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
tot=`echo ${toimport} | wc -w`
|
tot=$(echo "${toimport}" | wc -w)
|
||||||
cnt=`cat ${cfg} | grep "chmod: '777'" | wc -l`
|
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||||
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (1)" && exit 1
|
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (1)" && exit 1
|
||||||
|
|
||||||
## with link
|
## with link
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -137,29 +140,29 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# clean
|
# clean
|
||||||
rm -rf ${tmps}/dotfiles
|
rm -rf "${tmps}"/dotfiles
|
||||||
mkdir -p ${tmps}/dotfiles
|
mkdir -p "${tmps}"/dotfiles
|
||||||
|
|
||||||
# import without --preserve-mode and link
|
# import without --preserve-mode and link
|
||||||
for i in ${toimport}; do
|
for i in ${toimport}; do
|
||||||
cd ${ddpath} | ${bin} import -c ${cfg} -l absolute -f -p p1 -V ${i}
|
cd "${ddpath}" | ${bin} import -c "${cfg}" -l absolute -f -p p1 -V "${i}"
|
||||||
done
|
done
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# list files
|
# list files
|
||||||
cd ${ddpath} | ${bin} detail -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} detail -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
tot=`echo ${toimport} | wc -w`
|
tot=$(echo "${toimport}" | wc -w)
|
||||||
cnt=`cat ${cfg} | grep "chmod: '777'" | wc -l`
|
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||||
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (2)" && exit 1
|
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (2)" && exit 1
|
||||||
|
|
||||||
tot=`echo ${toimport} | wc -w`
|
tot=$(echo "${toimport}" | wc -w)
|
||||||
cnt=`cat ${cfg} | grep 'link: absolute' | wc -l`
|
cnt=$(cat "${cfg}" | grep 'link: absolute' | wc -l)
|
||||||
[ "${cnt}" != "${tot}" ] && echo "not all link inserted" && exit 1
|
[ "${cnt}" != "${tot}" ] && echo "not all link inserted" && exit 1
|
||||||
|
|
||||||
## --preserve-mode
|
## --preserve-mode
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -169,26 +172,26 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# clean
|
# clean
|
||||||
rm -rf ${tmps}/dotfiles
|
rm -rf "${tmps}"/dotfiles
|
||||||
mkdir -p ${tmps}/dotfiles
|
mkdir -p "${tmps}"/dotfiles
|
||||||
|
|
||||||
# import with --preserve-mode
|
# import with --preserve-mode
|
||||||
for i in ${toimport}; do
|
for i in ${toimport}; do
|
||||||
chmod_to_umask ${i}
|
chmod_to_umask "${i}"
|
||||||
cd ${ddpath} | ${bin} import -c ${cfg} -m -f -p p1 -V ${i}
|
cd "${ddpath}" | ${bin} import -c "${cfg}" -m -f -p p1 -V "${i}"
|
||||||
done
|
done
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# list files
|
# list files
|
||||||
cd ${ddpath} | ${bin} detail -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} detail -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
tot=`echo ${toimport} | wc -w`
|
tot=$(echo "${toimport}" | wc -w)
|
||||||
cnt=`cat ${cfg} | grep "chmod: " | wc -l`
|
cnt=$(cat "${cfg}" | grep "chmod: " | wc -l)
|
||||||
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (3)" && exit 1
|
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (3)" && exit 1
|
||||||
|
|
||||||
## import normal
|
## import normal
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -198,25 +201,25 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# clean
|
# clean
|
||||||
rm -rf ${tmps}/dotfiles
|
rm -rf "${tmps}"/dotfiles
|
||||||
mkdir -p ${tmps}/dotfiles
|
mkdir -p "${tmps}"/dotfiles
|
||||||
|
|
||||||
# import without --preserve-mode
|
# import without --preserve-mode
|
||||||
for i in ${toimport}; do
|
for i in ${toimport}; do
|
||||||
chmod_to_umask ${i}
|
chmod_to_umask "${i}"
|
||||||
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 -V ${i}
|
cd "${ddpath}" | ${bin} import -c "${cfg}" -f -p p1 -V "${i}"
|
||||||
done
|
done
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# list files
|
# list files
|
||||||
cd ${ddpath} | ${bin} detail -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} detail -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
cnt=`cat ${cfg} | grep chmod | wc -l`
|
cnt=$(cat "${cfg}" | grep chmod | wc -l)
|
||||||
[ "${cnt}" != "0" ] && echo "chmod inserted but not needed" && exit 1
|
[ "${cnt}" != "0" ] && echo "chmod inserted but not needed" && exit 1
|
||||||
|
|
||||||
## with config option chmod_on_import
|
## with config option chmod_on_import
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -227,23 +230,23 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# clean
|
# clean
|
||||||
rm -rf ${tmps}/dotfiles
|
rm -rf "${tmps}"/dotfiles
|
||||||
mkdir -p ${tmps}/dotfiles
|
mkdir -p "${tmps}"/dotfiles
|
||||||
|
|
||||||
# import
|
# import
|
||||||
for i in ${toimport}; do
|
for i in ${toimport}; do
|
||||||
chmod_to_umask ${i}
|
chmod_to_umask "${i}"
|
||||||
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 -V ${i}
|
cd "${ddpath}" | ${bin} import -c "${cfg}" -f -p p1 -V "${i}"
|
||||||
done
|
done
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# list files
|
# list files
|
||||||
cd ${ddpath} | ${bin} detail -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} detail -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
tot=`echo ${toimport} | wc -w`
|
tot=$(echo "${toimport}" | wc -w)
|
||||||
cnt=`cat ${cfg} | grep "chmod: " | wc -l`
|
cnt=$(cat "${cfg}" | grep "chmod: " | wc -l)
|
||||||
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (3)" && exit 1
|
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (3)" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
132
tests-ng/chmod-install.sh
vendored
132
tests-ng/chmod-install.sh
vendored
@@ -33,7 +33,9 @@ ddpath="${cur}/../"
|
|||||||
|
|
||||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||||
bin="python3 -m dotdrop.dotdrop"
|
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 "dotdrop path: ${ddpath}"
|
||||||
echo "pythonpath: ${PYTHONPATH}"
|
echo "pythonpath: ${PYTHONPATH}"
|
||||||
@@ -41,7 +43,7 @@ echo "pythonpath: ${PYTHONPATH}"
|
|||||||
# get the helpers
|
# get the helpers
|
||||||
source ${cur}/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
|
# this is the test
|
||||||
@@ -54,31 +56,31 @@ has_rights()
|
|||||||
echo "testing ${1} is ${2}"
|
echo "testing ${1} is ${2}"
|
||||||
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
|
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
|
||||||
local mode=`stat -L -c '%a' "$1"`
|
local mode=`stat -L -c '%a' "$1"`
|
||||||
[ "${mode}" != "$2" ] && echo "bad mode for `basename $1` (${mode} VS expected ${2})" && exit 1
|
[ "${mode}" != "$2" ] && echo "bad mode for `basename "$1"` (${mode} VS expected ${2})" && exit 1
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
get_file_mode()
|
get_file_mode()
|
||||||
{
|
{
|
||||||
u=`umask`
|
u=$(umask)
|
||||||
u=`echo ${u} | sed 's/^0*//'`
|
u=$(echo "${u}" | sed 's/^0*//')
|
||||||
v=$((666 - u))
|
v=$((666 - u))
|
||||||
echo "${v}"
|
echo "${v}"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_dir_mode()
|
get_dir_mode()
|
||||||
{
|
{
|
||||||
u=`umask`
|
u=$(umask)
|
||||||
u=`echo ${u} | sed 's/^0*//'`
|
u=$(echo "${u}" | sed 's/^0*//')
|
||||||
v=$((777 - u))
|
v=$((777 - u))
|
||||||
echo "${v}"
|
echo "${v}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -87,42 +89,42 @@ clear_on_exit "${tmpd}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
echo 'f777' > ${tmps}/dotfiles/f777
|
echo 'f777' > "${tmps}"/dotfiles/f777
|
||||||
chmod 700 ${tmps}/dotfiles/f777
|
chmod 700 "${tmps}"/dotfiles/f777
|
||||||
echo 'link' > ${tmps}/dotfiles/link
|
echo 'link' > "${tmps}"/dotfiles/link
|
||||||
chmod 777 ${tmps}/dotfiles/link
|
chmod 777 "${tmps}"/dotfiles/link
|
||||||
mkdir -p ${tmps}/dotfiles/dir
|
mkdir -p "${tmps}"/dotfiles/dir
|
||||||
echo "f1" > ${tmps}/dotfiles/dir/f1
|
echo "f1" > "${tmps}"/dotfiles/dir/f1
|
||||||
|
|
||||||
echo "exists" > ${tmps}/dotfiles/exists
|
echo "exists" > "${tmps}"/dotfiles/exists
|
||||||
chmod 644 ${tmps}/dotfiles/exists
|
chmod 644 "${tmps}"/dotfiles/exists
|
||||||
echo "exists" > ${tmpd}/exists
|
echo "exists" > "${tmpd}"/exists
|
||||||
chmod 644 ${tmpd}/exists
|
chmod 644 "${tmpd}"/exists
|
||||||
|
|
||||||
echo "existslink" > ${tmps}/dotfiles/existslink
|
echo "existslink" > "${tmps}"/dotfiles/existslink
|
||||||
chmod 777 ${tmps}/dotfiles/existslink
|
chmod 777 "${tmps}"/dotfiles/existslink
|
||||||
chmod 644 ${tmpd}/exists
|
chmod 644 "${tmpd}"/exists
|
||||||
|
|
||||||
mkdir -p ${tmps}/dotfiles/direxists
|
mkdir -p "${tmps}"/dotfiles/direxists
|
||||||
echo "f1" > ${tmps}/dotfiles/direxists/f1
|
echo "f1" > "${tmps}"/dotfiles/direxists/f1
|
||||||
mkdir -p ${tmpd}/direxists
|
mkdir -p "${tmpd}"/direxists
|
||||||
echo "f1" > ${tmpd}/direxists/f1
|
echo "f1" > "${tmpd}"/direxists/f1
|
||||||
chmod 644 ${tmpd}/direxists/f1
|
chmod 644 "${tmpd}"/direxists/f1
|
||||||
chmod 744 ${tmpd}/direxists
|
chmod 744 "${tmpd}"/direxists
|
||||||
|
|
||||||
mkdir -p ${tmps}/dotfiles/linkchildren
|
mkdir -p "${tmps}"/dotfiles/linkchildren
|
||||||
echo "f1" > ${tmps}/dotfiles/linkchildren/f1
|
echo "f1" > "${tmps}"/dotfiles/linkchildren/f1
|
||||||
mkdir -p ${tmps}/dotfiles/linkchildren/d1
|
mkdir -p "${tmps}"/dotfiles/linkchildren/d1
|
||||||
echo "f2" > ${tmps}/dotfiles/linkchildren/d1/f2
|
echo "f2" > "${tmps}"/dotfiles/linkchildren/d1/f2
|
||||||
|
|
||||||
echo '{{@@ profile @@}}' > ${tmps}/dotfiles/symlinktemplate
|
echo '{{@@ profile @@}}' > "${tmps}"/dotfiles/symlinktemplate
|
||||||
|
|
||||||
mkdir -p ${tmps}/dotfiles/symlinktemplatedir
|
mkdir -p "${tmps}"/dotfiles/symlinktemplatedir
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/symlinktemplatedir/t
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/symlinktemplatedir/t
|
||||||
|
|
||||||
echo 'nomode' > ${tmps}/dotfiles/nomode
|
echo 'nomode' > "${tmps}"/dotfiles/nomode
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -197,7 +199,7 @@ _EOF
|
|||||||
|
|
||||||
# install
|
# install
|
||||||
echo "first install round"
|
echo "first install round"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 -V
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p1 -V
|
||||||
echo "first install round"
|
echo "first install round"
|
||||||
|
|
||||||
has_rights "${tmpd}/f777" "777"
|
has_rights "${tmpd}/f777" "777"
|
||||||
@@ -212,24 +214,24 @@ has_rights "${tmpd}/linkchildren/f1" "644"
|
|||||||
has_rights "${tmpd}/linkchildren/d1" "755"
|
has_rights "${tmpd}/linkchildren/d1" "755"
|
||||||
has_rights "${tmpd}/linkchildren/d1/f2" "644"
|
has_rights "${tmpd}/linkchildren/d1/f2" "644"
|
||||||
has_rights "${tmpd}/symlinktemplate" "777"
|
has_rights "${tmpd}/symlinktemplate" "777"
|
||||||
m=`get_file_mode`
|
m=$(get_file_mode)
|
||||||
has_rights "${tmpd}/nomode" "${m}"
|
has_rights "${tmpd}/nomode" "${m}"
|
||||||
|
|
||||||
grep 'p1' ${tmpd}/symlinktemplate
|
grep 'p1' "${tmpd}"/symlinktemplate
|
||||||
grep 'p1' ${tmpd}/symlinktemplatedir/t
|
grep 'p1' "${tmpd}"/symlinktemplatedir/t
|
||||||
|
|
||||||
## second round
|
## second round
|
||||||
echo "exists" > ${tmps}/dotfiles/exists
|
echo "exists" > "${tmps}"/dotfiles/exists
|
||||||
chmod 600 ${tmps}/dotfiles/exists
|
chmod 600 "${tmps}"/dotfiles/exists
|
||||||
echo "exists" > ${tmpd}/exists
|
echo "exists" > "${tmpd}"/exists
|
||||||
chmod 600 ${tmpd}/exists
|
chmod 600 "${tmpd}"/exists
|
||||||
|
|
||||||
chmod 700 ${tmpd}/linkchildren
|
chmod 700 "${tmpd}"/linkchildren
|
||||||
|
|
||||||
chmod 600 ${tmpd}/symlinktemplate
|
chmod 600 "${tmpd}"/symlinktemplate
|
||||||
|
|
||||||
echo "second install round"
|
echo "second install round"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -p p2 -f -V
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -p p2 -f -V
|
||||||
echo "second install round"
|
echo "second install round"
|
||||||
|
|
||||||
has_rights "${tmpd}/exists" "777"
|
has_rights "${tmpd}/exists" "777"
|
||||||
@@ -237,39 +239,39 @@ has_rights "${tmpd}/linkchildren/f1" "644"
|
|||||||
has_rights "${tmpd}/linkchildren/d1" "755"
|
has_rights "${tmpd}/linkchildren/d1" "755"
|
||||||
has_rights "${tmpd}/linkchildren/d1/f2" "644"
|
has_rights "${tmpd}/linkchildren/d1/f2" "644"
|
||||||
has_rights "${tmpd}/symlinktemplate" "777"
|
has_rights "${tmpd}/symlinktemplate" "777"
|
||||||
m=`get_file_mode`
|
m=$(get_file_mode)
|
||||||
has_rights "${tmpd}/nomode" "${m}"
|
has_rights "${tmpd}/nomode" "${m}"
|
||||||
|
|
||||||
## no user confirmation expected
|
## no user confirmation expected
|
||||||
## same mode
|
## same mode
|
||||||
echo "same mode"
|
echo "same mode"
|
||||||
echo "nomode" > ${tmps}/dotfiles/nomode
|
echo "nomode" > "${tmps}"/dotfiles/nomode
|
||||||
chmod 600 ${tmps}/dotfiles/nomode
|
chmod 600 "${tmps}"/dotfiles/nomode
|
||||||
echo "nomode" > ${tmpd}/nomode
|
echo "nomode" > "${tmpd}"/nomode
|
||||||
chmod 600 ${tmpd}/nomode
|
chmod 600 "${tmpd}"/nomode
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p2 -V f_nomode
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p2 -V f_nomode
|
||||||
echo "same mode"
|
echo "same mode"
|
||||||
has_rights "${tmpd}/nomode" "600"
|
has_rights "${tmpd}/nomode" "600"
|
||||||
|
|
||||||
## no user confirmation with force
|
## no user confirmation with force
|
||||||
## different mode
|
## different mode
|
||||||
echo "different mode"
|
echo "different mode"
|
||||||
echo "nomode" > ${tmps}/dotfiles/nomode
|
echo "nomode" > "${tmps}"/dotfiles/nomode
|
||||||
chmod 600 ${tmps}/dotfiles/nomode
|
chmod 600 "${tmps}"/dotfiles/nomode
|
||||||
echo "nomode" > ${tmpd}/nomode
|
echo "nomode" > "${tmpd}"/nomode
|
||||||
chmod 700 ${tmpd}/nomode
|
chmod 700 "${tmpd}"/nomode
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p2 -V f_nomode
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p2 -V f_nomode
|
||||||
echo "different mode (1)"
|
echo "different mode (1)"
|
||||||
has_rights "${tmpd}/nomode" "600"
|
has_rights "${tmpd}/nomode" "600"
|
||||||
|
|
||||||
## user confirmation expected
|
## user confirmation expected
|
||||||
## different mode
|
## different mode
|
||||||
echo "different mode"
|
echo "different mode"
|
||||||
echo "nomode" > ${tmps}/dotfiles/nomode
|
echo "nomode" > "${tmps}"/dotfiles/nomode
|
||||||
chmod 600 ${tmps}/dotfiles/nomode
|
chmod 600 "${tmps}"/dotfiles/nomode
|
||||||
echo "nomode" > ${tmpd}/nomode
|
echo "nomode" > "${tmpd}"/nomode
|
||||||
chmod 700 ${tmpd}/nomode
|
chmod 700 "${tmpd}"/nomode
|
||||||
cd ${ddpath} | printf 'y\ny\n' | ${bin} install -f -c ${cfg} -p p2 -V f_nomode
|
cd "${ddpath}" | printf 'y\ny\n' | ${bin} install -f -c "${cfg}" -p p2 -V f_nomode
|
||||||
echo "different mode (2)"
|
echo "different mode (2)"
|
||||||
has_rights "${tmpd}/nomode" "600"
|
has_rights "${tmpd}/nomode" "600"
|
||||||
|
|
||||||
|
|||||||
44
tests-ng/chmod-more.sh
vendored
44
tests-ng/chmod-more.sh
vendored
@@ -33,7 +33,9 @@ ddpath="${cur}/../"
|
|||||||
|
|
||||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||||
bin="python3 -m dotdrop.dotdrop"
|
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 "dotdrop path: ${ddpath}"
|
||||||
echo "pythonpath: ${PYTHONPATH}"
|
echo "pythonpath: ${PYTHONPATH}"
|
||||||
@@ -41,7 +43,7 @@ echo "pythonpath: ${PYTHONPATH}"
|
|||||||
# get the helpers
|
# get the helpers
|
||||||
source ${cur}/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
|
# this is the test
|
||||||
@@ -54,28 +56,28 @@ has_rights()
|
|||||||
echo "testing ${1} is ${2}"
|
echo "testing ${1} is ${2}"
|
||||||
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
|
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
|
||||||
local mode=`stat -L -c '%a' "$1"`
|
local mode=`stat -L -c '%a' "$1"`
|
||||||
[ "${mode}" != "$2" ] && echo "bad mode for `basename $1` (${mode} instead of ${2})" && exit 1
|
[ "${mode}" != "$2" ] && echo "bad mode for `basename "$1"` (${mode} instead of ${2})" && exit 1
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 file
|
# $1 file
|
||||||
chmod_to_umask()
|
chmod_to_umask()
|
||||||
{
|
{
|
||||||
u=`umask`
|
u=$(umask)
|
||||||
u=`echo ${u} | sed 's/^0*//'`
|
u=$(echo "${u}" | sed 's/^0*//')
|
||||||
if [ -d ${1} ]; then
|
if [ -d "${1}" ]; then
|
||||||
v=$((777 - u))
|
v=$((777 - u))
|
||||||
else
|
else
|
||||||
v=$((666 - u))
|
v=$((666 - u))
|
||||||
fi
|
fi
|
||||||
chmod ${v} ${1}
|
chmod ${v} "${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -83,21 +85,21 @@ clear_on_exit "${tmpd}"
|
|||||||
|
|
||||||
# create the dotfiles
|
# create the dotfiles
|
||||||
f1="${tmpd}/f1"
|
f1="${tmpd}/f1"
|
||||||
touch ${f1}
|
touch "${f1}"
|
||||||
chmod 777 ${f1}
|
chmod 777 "${f1}"
|
||||||
stat -c '%a' ${f1}
|
stat -c '%a' "${f1}"
|
||||||
|
|
||||||
f2="${tmpd}/f2"
|
f2="${tmpd}/f2"
|
||||||
touch ${f2}
|
touch "${f2}"
|
||||||
chmod 644 ${f2}
|
chmod 644 "${f2}"
|
||||||
stat -c '%a' ${f2}
|
stat -c '%a' "${f2}"
|
||||||
|
|
||||||
toimport="${f1} ${f2}"
|
toimport="${f1} ${f2}"
|
||||||
|
|
||||||
# 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
|
||||||
@@ -109,11 +111,11 @@ _EOF
|
|||||||
|
|
||||||
# import without --preserve-mode
|
# import without --preserve-mode
|
||||||
for i in ${toimport}; do
|
for i in ${toimport}; do
|
||||||
stat -c '%a' ${i}
|
stat -c '%a' "${i}"
|
||||||
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 -V ${i}
|
cd "${ddpath}" | ${bin} import -c "${cfg}" -f -p p1 -V "${i}"
|
||||||
done
|
done
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
has_rights "${tmpd}/f1" "777"
|
has_rights "${tmpd}/f1" "777"
|
||||||
has_rights "${tmps}/dotfiles/${tmpd}/f1" "777"
|
has_rights "${tmps}/dotfiles/${tmpd}/f1" "777"
|
||||||
@@ -121,7 +123,7 @@ has_rights "${tmpd}/f2" "644"
|
|||||||
has_rights "${tmps}/dotfiles/${tmpd}/f2" "644"
|
has_rights "${tmps}/dotfiles/${tmpd}/f2" "644"
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 -V | grep '0 dotfile(s) installed' || (echo "should not install" && exit 1)
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p1 -V | grep '0 dotfile(s) installed' || (echo "should not install" && exit 1)
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
138
tests-ng/chmod-preserve-install.sh
vendored
138
tests-ng/chmod-preserve-install.sh
vendored
@@ -31,7 +31,9 @@ ddpath="${cur}/../"
|
|||||||
|
|
||||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||||
bin="python3 -m dotdrop.dotdrop"
|
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 "dotdrop path: ${ddpath}"
|
||||||
echo "pythonpath: ${PYTHONPATH}"
|
echo "pythonpath: ${PYTHONPATH}"
|
||||||
@@ -39,7 +41,7 @@ echo "pythonpath: ${PYTHONPATH}"
|
|||||||
# get the helpers
|
# get the helpers
|
||||||
source ${cur}/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
|
# this is the test
|
||||||
@@ -68,31 +70,31 @@ is_same_as()
|
|||||||
local mode2=`stat -L -c '%a' "$2"`
|
local mode2=`stat -L -c '%a' "$2"`
|
||||||
echo "$2: ${mode2}"
|
echo "$2: ${mode2}"
|
||||||
|
|
||||||
[ "${mode1}" != "${mode2}" ] && echo "`basename $1` (${mode1}) does not have same mode as `basename $2` (${mode2})" && exit 1
|
[ "${mode1}" != "${mode2}" ] && echo "`basename $1` (${mode1}) does not have same mode as `basename "$2"` (${mode2})" && exit 1
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
get_default_file_mode()
|
get_default_file_mode()
|
||||||
{
|
{
|
||||||
u=`umask`
|
u=$(umask)
|
||||||
u=`echo ${u} | sed 's/^0*//'`
|
u=$(echo "${u}" | sed 's/^0*//')
|
||||||
v=$((666 - u))
|
v=$((666 - u))
|
||||||
echo "${v}"
|
echo "${v}"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_default_dir_mode()
|
get_default_dir_mode()
|
||||||
{
|
{
|
||||||
u=`umask`
|
u=$(umask)
|
||||||
u=`echo ${u} | sed 's/^0*//'`
|
u=$(echo "${u}" | sed 's/^0*//')
|
||||||
v=$((777 - u))
|
v=$((777 - u))
|
||||||
echo "${v}"
|
echo "${v}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -106,70 +108,70 @@ cfg="${tmps}/config.yaml"
|
|||||||
##
|
##
|
||||||
|
|
||||||
# file
|
# file
|
||||||
echo 'f777' > ${tmps}/dotfiles/f777
|
echo 'f777' > "${tmps}"/dotfiles/f777
|
||||||
chmod 700 ${tmps}/dotfiles/f777
|
chmod 700 "${tmps}"/dotfiles/f777
|
||||||
|
|
||||||
# link
|
# link
|
||||||
echo 'link' > ${tmps}/dotfiles/link
|
echo 'link' > "${tmps}"/dotfiles/link
|
||||||
chmod 700 ${tmps}/dotfiles/link
|
chmod 700 "${tmps}"/dotfiles/link
|
||||||
|
|
||||||
# directory
|
# directory
|
||||||
mkdir -p ${tmps}/dotfiles/dir
|
mkdir -p "${tmps}"/dotfiles/dir
|
||||||
echo "f1" > ${tmps}/dotfiles/dir/f1
|
echo "f1" > "${tmps}"/dotfiles/dir/f1
|
||||||
chmod 700 ${tmps}/dotfiles/dir
|
chmod 700 "${tmps}"/dotfiles/dir
|
||||||
chmod 700 ${tmps}/dotfiles/dir/f1
|
chmod 700 "${tmps}"/dotfiles/dir/f1
|
||||||
|
|
||||||
# template
|
# template
|
||||||
echo '{{@@ profile @@}}' > ${tmps}/dotfiles/template
|
echo '{{@@ profile @@}}' > "${tmps}"/dotfiles/template
|
||||||
chmod 700 ${tmps}/dotfiles/template
|
chmod 700 "${tmps}"/dotfiles/template
|
||||||
|
|
||||||
# link template
|
# link template
|
||||||
echo '{{@@ profile @@}}' > ${tmps}/dotfiles/link-template
|
echo '{{@@ profile @@}}' > "${tmps}"/dotfiles/link-template
|
||||||
chmod 700 ${tmps}/dotfiles/link-template
|
chmod 700 "${tmps}"/dotfiles/link-template
|
||||||
|
|
||||||
##
|
##
|
||||||
# existing files
|
# existing files
|
||||||
##
|
##
|
||||||
|
|
||||||
# file
|
# file
|
||||||
echo "exists-original" > ${tmps}/dotfiles/exists
|
echo "exists-original" > "${tmps}"/dotfiles/exists
|
||||||
chmod 644 ${tmps}/dotfiles/exists
|
chmod 644 "${tmps}"/dotfiles/exists
|
||||||
echo "exists" > ${tmpd}/exists
|
echo "exists" > "${tmpd}"/exists
|
||||||
chmod 700 ${tmpd}/exists
|
chmod 700 "${tmpd}"/exists
|
||||||
|
|
||||||
# link
|
# link
|
||||||
echo "existslink" > ${tmps}/dotfiles/existslink
|
echo "existslink" > "${tmps}"/dotfiles/existslink
|
||||||
chmod 700 ${tmps}/dotfiles/existslink
|
chmod 700 "${tmps}"/dotfiles/existslink
|
||||||
ln -s ${tmps}/dotfiles/existslink ${tmpd}/existslink
|
ln -s "${tmps}"/dotfiles/existslink "${tmpd}"/existslink
|
||||||
|
|
||||||
# directory
|
# directory
|
||||||
mkdir -p ${tmps}/dotfiles/direxists
|
mkdir -p "${tmps}"/dotfiles/direxists
|
||||||
echo "f1-original" > ${tmps}/dotfiles/direxists/f1
|
echo "f1-original" > "${tmps}"/dotfiles/direxists/f1
|
||||||
mkdir -p ${tmpd}/direxists
|
mkdir -p "${tmpd}"/direxists
|
||||||
echo "f1" > ${tmpd}/direxists/f1
|
echo "f1" > "${tmpd}"/direxists/f1
|
||||||
chmod 700 ${tmpd}/direxists/f1
|
chmod 700 "${tmpd}"/direxists/f1
|
||||||
chmod 700 ${tmpd}/direxists
|
chmod 700 "${tmpd}"/direxists
|
||||||
|
|
||||||
# link children
|
# link children
|
||||||
mkdir -p ${tmps}/dotfiles/linkchildren
|
mkdir -p "${tmps}"/dotfiles/linkchildren
|
||||||
echo "f1-original" > ${tmps}/dotfiles/linkchildren/f1
|
echo "f1-original" > "${tmps}"/dotfiles/linkchildren/f1
|
||||||
chmod 700 ${tmps}/dotfiles/linkchildren/f1
|
chmod 700 "${tmps}"/dotfiles/linkchildren/f1
|
||||||
mkdir -p ${tmps}/dotfiles/linkchildren/d1
|
mkdir -p "${tmps}"/dotfiles/linkchildren/d1
|
||||||
chmod 700 ${tmps}/dotfiles/linkchildren/d1
|
chmod 700 "${tmps}"/dotfiles/linkchildren/d1
|
||||||
echo "f2-original" > ${tmps}/dotfiles/linkchildren/d1/f2
|
echo "f2-original" > "${tmps}"/dotfiles/linkchildren/d1/f2
|
||||||
chmod 700 ${tmps}/dotfiles/linkchildren/d1/f2
|
chmod 700 "${tmps}"/dotfiles/linkchildren/d1/f2
|
||||||
|
|
||||||
mkdir -p ${tmpd}/linkchildren
|
mkdir -p "${tmpd}"/linkchildren
|
||||||
chmod 700 ${tmpd}/linkchildren
|
chmod 700 "${tmpd}"/linkchildren
|
||||||
echo "f1" > ${tmpd}/linkchildren/f1
|
echo "f1" > "${tmpd}"/linkchildren/f1
|
||||||
mkdir -p ${tmpd}/linkchildren/d1
|
mkdir -p "${tmpd}"/linkchildren/d1
|
||||||
echo "f2" > ${tmpd}/linkchildren/d1/f2
|
echo "f2" > "${tmpd}"/linkchildren/d1/f2
|
||||||
|
|
||||||
# no mode
|
# no mode
|
||||||
echo 'nomode-original' > ${tmps}/dotfiles/nomode
|
echo 'nomode-original' > "${tmps}"/dotfiles/nomode
|
||||||
echo 'nomode' > ${tmpd}/nomode
|
echo 'nomode' > "${tmpd}"/nomode
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -235,23 +237,23 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
exists_before=`stat -L -c '%a' "${tmpd}/exists"`
|
exists_before=$(stat -L -c '%a' "${tmpd}/exists")
|
||||||
direxists_before=`stat -L -c '%a' "${tmpd}/direxists"`
|
direxists_before=$(stat -L -c '%a' "${tmpd}/direxists")
|
||||||
direxists_f1_before=`stat -L -c '%a' "${tmpd}/direxists/f1"`
|
direxists_f1_before=$(stat -L -c '%a' "${tmpd}/direxists/f1")
|
||||||
|
|
||||||
# install
|
# install
|
||||||
echo "first round"
|
echo "first round"
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
echo "first round"
|
echo "first round"
|
||||||
|
|
||||||
# non-existing but will create with "default" rights on preserve
|
# non-existing but will create with "default" rights on preserve
|
||||||
# 644 for file
|
# 644 for file
|
||||||
# 755 for directory
|
# 755 for directory
|
||||||
# link will get the rights of the file it points to
|
# link will get the rights of the file it points to
|
||||||
has_rights "${tmpd}/f777" "`get_default_file_mode`"
|
has_rights "${tmpd}/f777" "$(get_default_file_mode)"
|
||||||
has_rights "${tmpd}/link" "700"
|
has_rights "${tmpd}/link" "700"
|
||||||
has_rights "${tmpd}/dir" "`get_default_dir_mode`"
|
has_rights "${tmpd}/dir" "$(get_default_dir_mode)"
|
||||||
has_rights "${tmpd}/template" "`get_default_file_mode`"
|
has_rights "${tmpd}/template" "$(get_default_file_mode)"
|
||||||
# first install to workdir (def rights) and then symlink
|
# first install to workdir (def rights) and then symlink
|
||||||
has_rights "${tmpd}/link-template" "644"
|
has_rights "${tmpd}/link-template" "644"
|
||||||
[ -L "${tmpd}/link-template" ] && echo "link-template is not a symlink" && exit 1
|
[ -L "${tmpd}/link-template" ] && echo "link-template is not a symlink" && exit 1
|
||||||
@@ -275,20 +277,20 @@ has_rights "${tmpd}/linkchildren/d1" "700" # points back to dotpath
|
|||||||
has_rights "${tmpd}/linkchildren/d1/f2" "700"
|
has_rights "${tmpd}/linkchildren/d1/f2" "700"
|
||||||
|
|
||||||
# modify
|
# modify
|
||||||
echo 'f777-2' >> ${tmps}/dotfiles/f777
|
echo 'f777-2' >> "${tmps}"/dotfiles/f777
|
||||||
chmod 701 ${tmps}/dotfiles/f777
|
chmod 701 "${tmps}"/dotfiles/f777
|
||||||
echo 'link-2' >> ${tmps}/dotfiles/link
|
echo 'link-2' >> "${tmps}"/dotfiles/link
|
||||||
chmod 701 ${tmps}/dotfiles/link
|
chmod 701 "${tmps}"/dotfiles/link
|
||||||
echo "f1-2" >> ${tmps}/dotfiles/dir/f1
|
echo "f1-2" >> "${tmps}"/dotfiles/dir/f1
|
||||||
chmod 701 ${tmps}/dotfiles/dir
|
chmod 701 "${tmps}"/dotfiles/dir
|
||||||
chmod 701 ${tmps}/dotfiles/dir/f1
|
chmod 701 "${tmps}"/dotfiles/dir/f1
|
||||||
|
|
||||||
f777_before=`stat -L -c '%a' "${tmpd}/f777"`
|
f777_before=$(stat -L -c '%a' "${tmpd}/f777")
|
||||||
link_before=`stat -L -c '%a' "${tmpd}/link"`
|
link_before=$(stat -L -c '%a' "${tmpd}/link")
|
||||||
dir_before=`stat -L -c '%a' "${tmpd}/dir"`
|
dir_before=$(stat -L -c '%a' "${tmpd}/dir")
|
||||||
|
|
||||||
echo "second round"
|
echo "second round"
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
echo "second round"
|
echo "second round"
|
||||||
|
|
||||||
# existing
|
# existing
|
||||||
|
|||||||
85
tests-ng/chmod-preserve-update.sh
vendored
85
tests-ng/chmod-preserve-update.sh
vendored
@@ -27,29 +27,32 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -60,46 +63,46 @@ clear_on_exit "${tmpd}"
|
|||||||
##
|
##
|
||||||
|
|
||||||
# file
|
# file
|
||||||
echo "exists-original" > ${tmps}/dotfiles/exists
|
echo "exists-original" > "${tmps}"/dotfiles/exists
|
||||||
chmod 644 ${tmps}/dotfiles/exists
|
chmod 644 "${tmps}"/dotfiles/exists
|
||||||
echo "exists" > ${tmpd}/exists
|
echo "exists" > "${tmpd}"/exists
|
||||||
chmod 700 ${tmpd}/exists
|
chmod 700 "${tmpd}"/exists
|
||||||
|
|
||||||
# link
|
# link
|
||||||
echo "existslink" > ${tmps}/dotfiles/existslink
|
echo "existslink" > "${tmps}"/dotfiles/existslink
|
||||||
chmod 700 ${tmps}/dotfiles/existslink
|
chmod 700 "${tmps}"/dotfiles/existslink
|
||||||
ln -s ${tmps}/dotfiles/existslink ${tmpd}/existslink
|
ln -s "${tmps}"/dotfiles/existslink "${tmpd}"/existslink
|
||||||
|
|
||||||
# directory
|
# directory
|
||||||
mkdir -p ${tmps}/dotfiles/direxists
|
mkdir -p "${tmps}"/dotfiles/direxists
|
||||||
echo "f1-original" > ${tmps}/dotfiles/direxists/f1
|
echo "f1-original" > "${tmps}"/dotfiles/direxists/f1
|
||||||
mkdir -p ${tmpd}/direxists
|
mkdir -p "${tmpd}"/direxists
|
||||||
echo "f1" > ${tmpd}/direxists/f1
|
echo "f1" > "${tmpd}"/direxists/f1
|
||||||
chmod 700 ${tmpd}/direxists/f1
|
chmod 700 "${tmpd}"/direxists/f1
|
||||||
chmod 700 ${tmpd}/direxists
|
chmod 700 "${tmpd}"/direxists
|
||||||
|
|
||||||
# link children
|
# link children
|
||||||
mkdir -p ${tmps}/dotfiles/linkchildren
|
mkdir -p "${tmps}"/dotfiles/linkchildren
|
||||||
echo "f1-original" > ${tmps}/dotfiles/linkchildren/f1
|
echo "f1-original" > "${tmps}"/dotfiles/linkchildren/f1
|
||||||
chmod 700 ${tmps}/dotfiles/linkchildren/f1
|
chmod 700 "${tmps}"/dotfiles/linkchildren/f1
|
||||||
mkdir -p ${tmps}/dotfiles/linkchildren/d1
|
mkdir -p "${tmps}"/dotfiles/linkchildren/d1
|
||||||
chmod 700 ${tmps}/dotfiles/linkchildren/d1
|
chmod 700 "${tmps}"/dotfiles/linkchildren/d1
|
||||||
echo "f2-original" > ${tmps}/dotfiles/linkchildren/d1/f2
|
echo "f2-original" > "${tmps}"/dotfiles/linkchildren/d1/f2
|
||||||
chmod 700 ${tmps}/dotfiles/linkchildren/d1/f2
|
chmod 700 "${tmps}"/dotfiles/linkchildren/d1/f2
|
||||||
|
|
||||||
mkdir -p ${tmpd}/linkchildren
|
mkdir -p "${tmpd}"/linkchildren
|
||||||
chmod 700 ${tmpd}/linkchildren
|
chmod 700 "${tmpd}"/linkchildren
|
||||||
echo "f1" > ${tmpd}/linkchildren/f1
|
echo "f1" > "${tmpd}"/linkchildren/f1
|
||||||
mkdir -p ${tmpd}/linkchildren/d1
|
mkdir -p "${tmpd}"/linkchildren/d1
|
||||||
echo "f2" > ${tmpd}/linkchildren/d1/f2
|
echo "f2" > "${tmpd}"/linkchildren/d1/f2
|
||||||
|
|
||||||
# no mode
|
# no mode
|
||||||
echo 'nomode-original' > ${tmps}/dotfiles/nomode
|
echo 'nomode-original' > "${tmps}"/dotfiles/nomode
|
||||||
echo 'nomode' > ${tmpd}/nomode
|
echo 'nomode' > "${tmpd}"/nomode
|
||||||
|
|
||||||
# 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
|
||||||
@@ -140,13 +143,13 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
echo "update"
|
echo "update"
|
||||||
cd ${ddpath} | ${bin} update -f -c ${cfg} -p p1 -V ${tmpd}/exists
|
cd "${ddpath}" | ${bin} update -f -c "${cfg}" -p p1 -V "${tmpd}"/exists
|
||||||
cd ${ddpath} | ${bin} update -f -c ${cfg} -p p1 -V ${tmpd}/existslink
|
cd "${ddpath}" | ${bin} update -f -c "${cfg}" -p p1 -V "${tmpd}"/existslink
|
||||||
cd ${ddpath} | ${bin} update -f -c ${cfg} -p p1 -V ${tmpd}/direxists
|
cd "${ddpath}" | ${bin} update -f -c "${cfg}" -p p1 -V "${tmpd}"/direxists
|
||||||
cd ${ddpath} | ${bin} update -f -c ${cfg} -p p1 -V ${tmpd}/linkchildren
|
cd "${ddpath}" | ${bin} update -f -c "${cfg}" -p p1 -V "${tmpd}"/linkchildren
|
||||||
cd ${ddpath} | ${bin} update -f -c ${cfg} -p p1 -V ${tmpd}/nomode
|
cd "${ddpath}" | ${bin} update -f -c "${cfg}" -p p1 -V "${tmpd}"/nomode
|
||||||
|
|
||||||
count=$(cat ${cfg} | grep chmod | grep -v 'chmod: preserve\|force_chmod' | wc -l)
|
count=$(cat "${cfg}" | grep chmod | grep -v 'chmod: preserve\|force_chmod' | wc -l)
|
||||||
echo "${count}"
|
echo "${count}"
|
||||||
[ "${count}" != "0" ] && echo "chmod altered" && exit 1
|
[ "${count}" != "0" ] && echo "chmod altered" && exit 1
|
||||||
|
|
||||||
|
|||||||
87
tests-ng/chmod-update.sh
vendored
87
tests-ng/chmod-update.sh
vendored
@@ -27,29 +27,32 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -57,32 +60,32 @@ clear_on_exit "${tmpd}"
|
|||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
dnormal="${tmpd}/dir_normal"
|
dnormal="${tmpd}/dir_normal"
|
||||||
mkdir -p ${dnormal}
|
mkdir -p "${dnormal}"
|
||||||
echo "dir_normal/f1" > ${dnormal}/file1
|
echo "dir_normal/f1" > "${dnormal}"/file1
|
||||||
echo "dir_normal/f2" > ${dnormal}/file2
|
echo "dir_normal/f2" > "${dnormal}"/file2
|
||||||
|
|
||||||
dlink="${tmpd}/dir_link"
|
dlink="${tmpd}/dir_link"
|
||||||
mkdir -p ${dlink}
|
mkdir -p "${dlink}"
|
||||||
echo "dir_link/f1" > ${dlink}/file1
|
echo "dir_link/f1" > "${dlink}"/file1
|
||||||
echo "dir_link/f2" > ${dlink}/file2
|
echo "dir_link/f2" > "${dlink}"/file2
|
||||||
|
|
||||||
dlinkchildren="${tmpd}/dir_link_children"
|
dlinkchildren="${tmpd}/dir_link_children"
|
||||||
mkdir -p ${dlinkchildren}
|
mkdir -p "${dlinkchildren}"
|
||||||
echo "dir_linkchildren/f1" > ${dlinkchildren}/file1
|
echo "dir_linkchildren/f1" > "${dlinkchildren}"/file1
|
||||||
echo "dir_linkchildren/f2" > ${dlinkchildren}/file2
|
echo "dir_linkchildren/f2" > "${dlinkchildren}"/file2
|
||||||
|
|
||||||
fnormal="${tmpd}/filenormal"
|
fnormal="${tmpd}/filenormal"
|
||||||
echo "filenormal" > ${fnormal}
|
echo "filenormal" > "${fnormal}"
|
||||||
|
|
||||||
flink="${tmpd}/filelink"
|
flink="${tmpd}/filelink"
|
||||||
echo "filelink" > ${flink}
|
echo "filelink" > "${flink}"
|
||||||
|
|
||||||
toimport="${dnormal} ${dlink} ${dlinkchildren} ${fnormal} ${flink}"
|
toimport="${dnormal} ${dlink} ${dlinkchildren} ${fnormal} ${flink}"
|
||||||
|
|
||||||
# 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
|
||||||
@@ -93,64 +96,64 @@ _EOF
|
|||||||
|
|
||||||
# import
|
# import
|
||||||
for i in ${toimport}; do
|
for i in ${toimport}; do
|
||||||
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 -V ${i}
|
cd "${ddpath}" | ${bin} import -c "${cfg}" -f -p p1 -V "${i}"
|
||||||
done
|
done
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# test no chmod
|
# test no chmod
|
||||||
cnt=`cat ${cfg} | grep chmod | wc -l`
|
cnt=$(cat "${cfg}" | grep chmod | wc -l)
|
||||||
[ "${cnt}" != "0" ] && echo "chmod wrongly inserted" && exit 1
|
[ "${cnt}" != "0" ] && echo "chmod wrongly inserted" && exit 1
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# update dnormal
|
# update dnormal
|
||||||
chmod 777 ${dnormal}
|
chmod 777 "${dnormal}"
|
||||||
cd ${ddpath} | ${bin} update -c ${cfg} -f -p p1 -V ${dnormal}
|
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 -V "${dnormal}"
|
||||||
|
|
||||||
# check rights updated
|
# check rights updated
|
||||||
[ "`stat -c '%a' ${tmps}/dotfiles/${tmpd}/$(basename ${dnormal})`" != "777" ] && echo "rights not updated (1)" && exit 1
|
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/$(basename "${dnormal}"))" != "777" ] && echo "rights not updated (1)" && exit 1
|
||||||
|
|
||||||
cnt=`cat ${cfg} | grep "chmod: '777'" | wc -l`
|
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||||
[ "${cnt}" != "1" ] && echo "chmod not updated (1)" && exit 1
|
[ "${cnt}" != "1" ] && echo "chmod not updated (1)" && exit 1
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# update dlink
|
# update dlink
|
||||||
chmod 777 ${dlink}
|
chmod 777 "${dlink}"
|
||||||
cd ${ddpath} | ${bin} update -c ${cfg} -f -p p1 -V ${dlink}
|
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 -V "${dlink}"
|
||||||
|
|
||||||
# check rights updated
|
# check rights updated
|
||||||
[ "`stat -c '%a' ${tmps}/dotfiles/${tmpd}/$(basename ${dlink})`" != "777" ] && echo "rights not updated (2)" && exit 1
|
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/$(basename "${dlink}"))" != "777" ] && echo "rights not updated (2)" && exit 1
|
||||||
cnt=`cat ${cfg} | grep "chmod: '777'" | wc -l`
|
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||||
[ "${cnt}" != "2" ] && echo "chmod not updated (2)" && exit 1
|
[ "${cnt}" != "2" ] && echo "chmod not updated (2)" && exit 1
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# update dlinkchildren
|
# update dlinkchildren
|
||||||
chmod 777 ${dlinkchildren}
|
chmod 777 "${dlinkchildren}"
|
||||||
cd ${ddpath} | ${bin} update -c ${cfg} -f -p p1 -V ${dlinkchildren}
|
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 -V "${dlinkchildren}"
|
||||||
|
|
||||||
# check rights updated
|
# check rights updated
|
||||||
[ "`stat -c '%a' ${tmps}/dotfiles/${tmpd}/$(basename ${dlinkchildren})`" != "777" ] && echo "rights not updated (3)" && exit 1
|
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/$(basename "${dlinkchildren}"))" != "777" ] && echo "rights not updated (3)" && exit 1
|
||||||
cnt=`cat ${cfg} | grep "chmod: '777'" | wc -l`
|
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||||
[ "${cnt}" != "3" ] && echo "chmod not updated (3)" && exit 1
|
[ "${cnt}" != "3" ] && echo "chmod not updated (3)" && exit 1
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# update fnormal
|
# update fnormal
|
||||||
chmod 777 ${fnormal}
|
chmod 777 "${fnormal}"
|
||||||
cd ${ddpath} | ${bin} update -c ${cfg} -f -p p1 -V ${fnormal}
|
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 -V "${fnormal}"
|
||||||
|
|
||||||
# check rights updated
|
# check rights updated
|
||||||
[ "`stat -c '%a' ${tmps}/dotfiles/${tmpd}/$(basename ${fnormal})`" != "777" ] && echo "rights not updated (4)" && exit 1
|
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/$(basename "${fnormal}"))" != "777" ] && echo "rights not updated (4)" && exit 1
|
||||||
cnt=`cat ${cfg} | grep "chmod: '777'" | wc -l`
|
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||||
[ "${cnt}" != "4" ] && echo "chmod not updated (4)" && exit 1
|
[ "${cnt}" != "4" ] && echo "chmod not updated (4)" && exit 1
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# update flink
|
# update flink
|
||||||
chmod 777 ${flink}
|
chmod 777 "${flink}"
|
||||||
cd ${ddpath} | ${bin} update -c ${cfg} -f -p p1 -V ${flink}
|
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 -V "${flink}"
|
||||||
|
|
||||||
# check rights updated
|
# check rights updated
|
||||||
[ "`stat -c '%a' ${tmps}/dotfiles/${tmpd}/$(basename ${flink})`" != "777" ] && echo "rights not updated (5)" && exit 1
|
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/$(basename "${flink}"))" != "777" ] && echo "rights not updated (5)" && exit 1
|
||||||
cnt=`cat ${cfg} | grep "chmod: '777'" | wc -l`
|
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||||
[ "${cnt}" != "5" ] && echo "chmod not updated (5)" && exit 1
|
[ "${cnt}" != "5" ] && echo "chmod not updated (5)" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
57
tests-ng/clear-workdir.sh
vendored
57
tests-ng/clear-workdir.sh
vendored
@@ -28,32 +28,35 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
mkdir -p ${basedir}/dotfiles
|
mkdir -p "${basedir}"/dotfiles
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
if [ -z "${DOTDROP_WORKDIR}" ]; then
|
if [ -z "${DOTDROP_WORKDIR}" ]; then
|
||||||
tmpw=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpw=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
export DOTDROP_WORKDIR="${tmpw}"
|
export DOTDROP_WORKDIR="${tmpw}"
|
||||||
clear_on_exit "${tmpw}"
|
clear_on_exit "${tmpw}"
|
||||||
fi
|
fi
|
||||||
@@ -61,11 +64,11 @@ fi
|
|||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
echo "{{@@ profile @@}}" > ${basedir}/dotfiles/x
|
echo "{{@@ profile @@}}" > "${basedir}"/dotfiles/x
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -82,30 +85,30 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
echo "[+] install (1)"
|
echo "[+] install (1)"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 --verbose | grep '^1 dotfile(s) installed.$'
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p1 --verbose | grep '^1 dotfile(s) installed.$'
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpd}/x ] && echo "f_x not installed" && exit 1
|
[ ! -e "${tmpd}"/x ] && echo "f_x not installed" && exit 1
|
||||||
[ ! -h ${tmpd}/x ] && echo "f_x not symlink" && exit 1
|
[ ! -h "${tmpd}"/x ] && echo "f_x not symlink" && exit 1
|
||||||
[ ! -e ${DOTDROP_WORKDIR}/${tmpd}/x ] && echo "f_x not in workdir (${DOTDROP_WORKDIR}/${tmpd})" && exit 1
|
[ ! -e "${DOTDROP_WORKDIR}"/"${tmpd}"/x ] && echo "f_x not in workdir (${DOTDROP_WORKDIR}/${tmpd})" && exit 1
|
||||||
|
|
||||||
# add file
|
# add file
|
||||||
touch ${DOTDROP_WORKDIR}/new
|
touch "${DOTDROP_WORKDIR}"/new
|
||||||
|
|
||||||
echo "[+] re-install with clear-workdir in cli"
|
echo "[+] re-install with clear-workdir in cli"
|
||||||
cd ${ddpath} | printf "y\n" | ${bin} install -W -c ${cfg} -p p1 --verbose
|
cd "${ddpath}" | printf "y\n" | ${bin} install -W -c "${cfg}" -p p1 --verbose
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpd}/x ] && echo "f_x not installed" && exit 1
|
[ ! -e "${tmpd}"/x ] && echo "f_x not installed" && exit 1
|
||||||
[ ! -h ${tmpd}/x ] && echo "f_x not symlink" && exit 1
|
[ ! -h "${tmpd}"/x ] && echo "f_x not symlink" && exit 1
|
||||||
[ ! -e ${DOTDROP_WORKDIR}/${tmpd}/x ] && echo "f_x not in workdir (${DOTDROP_WORKDIR}/${tmpd})" && exit 1
|
[ ! -e "${DOTDROP_WORKDIR}"/"${tmpd}"/x ] && echo "f_x not in workdir (${DOTDROP_WORKDIR}/${tmpd})" && exit 1
|
||||||
[ -e ${DOTDROP_WORKDIR}/new ] && echo "workdir not cleared (1)" && exit 1
|
[ -e "${DOTDROP_WORKDIR}"/new ] && echo "workdir not cleared (1)" && exit 1
|
||||||
|
|
||||||
# add file
|
# add file
|
||||||
touch ${DOTDROP_WORKDIR}/new
|
touch "${DOTDROP_WORKDIR}"/new
|
||||||
|
|
||||||
echo "[+] re-install with config clear-workdir in config"
|
echo "[+] re-install with config clear-workdir in config"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -121,13 +124,13 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_x
|
- f_x
|
||||||
_EOF
|
_EOF
|
||||||
cd ${ddpath} | printf "y\n" | ${bin} install -W -c ${cfg} -p p1 --verbose
|
cd "${ddpath}" | printf "y\n" | ${bin} install -W -c "${cfg}" -p p1 --verbose
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpd}/x ] && echo "f_x not installed" && exit 1
|
[ ! -e "${tmpd}"/x ] && echo "f_x not installed" && exit 1
|
||||||
[ ! -h ${tmpd}/x ] && echo "f_x not symlink" && exit 1
|
[ ! -h "${tmpd}"/x ] && echo "f_x not symlink" && exit 1
|
||||||
[ ! -e ${DOTDROP_WORKDIR}/${tmpd}/x ] && echo "f_x not in workdir (${DOTDROP_WORKDIR}/${tmpd})" && exit 1
|
[ ! -e "${DOTDROP_WORKDIR}"/"${tmpd}"/x ] && echo "f_x not in workdir (${DOTDROP_WORKDIR}/${tmpd})" && exit 1
|
||||||
[ -e ${DOTDROP_WORKDIR}/new ] && echo "workdir not cleared (2)" && exit 1
|
[ -e "${DOTDROP_WORKDIR}"/new ] && echo "workdir not cleared (2)" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
41
tests-ng/compare-ignore-missing.sh
vendored
41
tests-ng/compare-ignore-missing.sh
vendored
@@ -23,47 +23,50 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
dt="${basedir}/dotfiles"
|
dt="${basedir}/dotfiles"
|
||||||
mkdir -p ${dt}/folder
|
mkdir -p "${dt}"/folder
|
||||||
touch ${dt}/folder/a
|
touch "${dt}"/folder/a
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# some files
|
# some files
|
||||||
cp -r ${dt}/folder ${tmpd}/
|
cp -r "${dt}"/folder "${tmpd}"/
|
||||||
mkdir -p ${tmpd}/folder
|
mkdir -p "${tmpd}"/folder
|
||||||
touch ${tmpd}/folder/b
|
touch "${tmpd}"/folder/b
|
||||||
mkdir ${tmpd}/folder/c
|
mkdir "${tmpd}"/folder/c
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: false
|
backup: false
|
||||||
create: true
|
create: true
|
||||||
@@ -85,7 +88,7 @@ _EOF
|
|||||||
# Expect diff
|
# Expect diff
|
||||||
echo "[+] test with no ignore-missing setting"
|
echo "[+] test with no ignore-missing setting"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --profile=p1
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose --profile=p1
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -96,7 +99,7 @@ set -e
|
|||||||
# Expect no diff
|
# Expect no diff
|
||||||
echo "[+] test with command-line flag"
|
echo "[+] test with command-line flag"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --profile=p1 --ignore-missing
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose --profile=p1 --ignore-missing
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -104,7 +107,7 @@ set -e
|
|||||||
# Test with global option
|
# Test with global option
|
||||||
#
|
#
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: false
|
backup: false
|
||||||
create: true
|
create: true
|
||||||
@@ -123,7 +126,7 @@ _EOF
|
|||||||
# Expect no diff
|
# Expect no diff
|
||||||
echo "[+] test global option"
|
echo "[+] test global option"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --profile=p1
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose --profile=p1
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -131,7 +134,7 @@ set -e
|
|||||||
# Test with dotfile option
|
# Test with dotfile option
|
||||||
#
|
#
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: false
|
backup: false
|
||||||
create: true
|
create: true
|
||||||
@@ -150,7 +153,7 @@ _EOF
|
|||||||
# Expect no diff
|
# Expect no diff
|
||||||
echo "[+] test dotfile option"
|
echo "[+] test dotfile option"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --profile=p1
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose --profile=p1
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|||||||
85
tests-ng/compare-ignore-relative.sh
vendored
85
tests-ng/compare-ignore-relative.sh
vendored
@@ -28,61 +28,64 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# some files
|
# some files
|
||||||
mkdir -p ${tmpd}/{program,config,vscode}
|
mkdir -p "${tmpd}"/{program,config,vscode}
|
||||||
touch ${tmpd}/program/a
|
touch "${tmpd}"/program/a
|
||||||
touch ${tmpd}/config/a
|
touch "${tmpd}"/config/a
|
||||||
touch ${tmpd}/vscode/extensions.txt
|
touch "${tmpd}"/vscode/extensions.txt
|
||||||
touch ${tmpd}/vscode/keybindings.json
|
touch "${tmpd}"/vscode/keybindings.json
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f --verbose -c ${cfg} ${tmpd}/program || exit 1
|
cd "${ddpath}" | ${bin} import -f --verbose -c "${cfg}" "${tmpd}"/program || exit 1
|
||||||
cd ${ddpath} | ${bin} import -f --verbose -c ${cfg} ${tmpd}/config || exit 1
|
cd "${ddpath}" | ${bin} import -f --verbose -c "${cfg}" "${tmpd}"/config || exit 1
|
||||||
cd ${ddpath} | ${bin} import -f --verbose -c ${cfg} ${tmpd}/vscode || exit 1
|
cd "${ddpath}" | ${bin} import -f --verbose -c "${cfg}" "${tmpd}"/vscode || exit 1
|
||||||
|
|
||||||
# add files on filesystem
|
# add files on filesystem
|
||||||
echo "[+] add files"
|
echo "[+] add files"
|
||||||
touch ${tmpd}/program/b
|
touch "${tmpd}"/program/b
|
||||||
touch ${tmpd}/config/b
|
touch "${tmpd}"/config/b
|
||||||
|
|
||||||
# expects diff
|
# expects diff
|
||||||
echo "[+] comparing normal - diffs expected"
|
echo "[+] comparing normal - diffs expected"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose
|
||||||
ret="$?"
|
ret="$?"
|
||||||
echo ${ret}
|
echo ${ret}
|
||||||
[ "${ret}" = "0" ] && exit 1
|
[ "${ret}" = "0" ] && exit 1
|
||||||
@@ -92,78 +95,78 @@ set -e
|
|||||||
patt="b"
|
patt="b"
|
||||||
echo "[+] comparing with ignore (pattern: ${patt}) - no diff expected"
|
echo "[+] comparing with ignore (pattern: ${patt}) - no diff expected"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --ignore=${patt}
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose --ignore=${patt}
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# adding ignore in dotfile
|
# adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "b"' ${cfg} > ${cfg2}
|
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "b"' "${cfg}" > "${cfg2}"
|
||||||
#cat ${cfg2}
|
#cat ${cfg2}
|
||||||
|
|
||||||
# expects one diff
|
# expects one diff
|
||||||
echo "[+] comparing with ignore in dotfile - diff expected"
|
echo "[+] comparing with ignore in dotfile - diff expected"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# adding ignore in dotfile
|
# adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "b"' ${cfg} > ${cfg2}
|
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "b"' "${cfg}" > "${cfg2}"
|
||||||
sed -i '/d_program:/a \ \ \ \ cmpignore:\n\ \ \ \ - "b"' ${cfg2}
|
sed -i '/d_program:/a \ \ \ \ cmpignore:\n\ \ \ \ - "b"' "${cfg2}"
|
||||||
#cat ${cfg2}
|
#cat ${cfg2}
|
||||||
|
|
||||||
# expects no diff
|
# expects no diff
|
||||||
echo "[+] comparing with ignore in dotfile - no diff expected"
|
echo "[+] comparing with ignore in dotfile - no diff expected"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# update files
|
# update files
|
||||||
echo touched > ${tmpd}/vscode/extensions.txt
|
echo touched > "${tmpd}"/vscode/extensions.txt
|
||||||
echo touched > ${tmpd}/vscode/keybindings.json
|
echo touched > "${tmpd}"/vscode/keybindings.json
|
||||||
|
|
||||||
# expect two diffs
|
# expect two diffs
|
||||||
echo "[+] comparing - diff expected"
|
echo "[+] comparing - diff expected"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -C ${tmpd}/vscode
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -C "${tmpd}"/vscode
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# expects no diff
|
# expects no diff
|
||||||
echo "[+] comparing with ignore in dotfile - no diff expected"
|
echo "[+] comparing with ignore in dotfile - no diff expected"
|
||||||
sed '/d_vscode:/a \ \ \ \ cmpignore:\n\ \ \ \ - "extensions.txt"\n\ \ \ \ - "keybindings.json"' ${cfg} > ${cfg2}
|
sed '/d_vscode:/a \ \ \ \ cmpignore:\n\ \ \ \ - "extensions.txt"\n\ \ \ \ - "keybindings.json"' "${cfg}" > "${cfg2}"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose -C ${tmpd}/vscode
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose -C "${tmpd}"/vscode
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# test for #149
|
# test for #149
|
||||||
####################
|
####################
|
||||||
mkdir -p ${tmpd}/.zsh
|
mkdir -p "${tmpd}"/.zsh
|
||||||
touch ${tmpd}/.zsh/somefile
|
touch "${tmpd}"/.zsh/somefile
|
||||||
mkdir -p ${tmpd}/.zsh/plugins
|
mkdir -p "${tmpd}"/.zsh/plugins
|
||||||
touch ${tmpd}/.zsh/plugins/someplugin
|
touch "${tmpd}"/.zsh/plugins/someplugin
|
||||||
|
|
||||||
echo "[+] import .zsh"
|
echo "[+] import .zsh"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/.zsh
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/.zsh
|
||||||
|
|
||||||
# no diff expected
|
# no diff expected
|
||||||
echo "[+] comparing .zsh"
|
echo "[+] comparing .zsh"
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -C ${tmpd}/.zsh --ignore=${patt}
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -C "${tmpd}"/.zsh --ignore=${patt}
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
# add some files
|
# add some files
|
||||||
touch ${tmpd}/.zsh/plugins/ignore-1.zsh
|
touch "${tmpd}"/.zsh/plugins/ignore-1.zsh
|
||||||
touch ${tmpd}/.zsh/plugins/ignore-2.zsh
|
touch "${tmpd}"/.zsh/plugins/ignore-2.zsh
|
||||||
|
|
||||||
# expects diff
|
# expects diff
|
||||||
echo "[+] comparing .zsh with new files"
|
echo "[+] comparing .zsh with new files"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -C ${tmpd}/.zsh
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -C "${tmpd}"/.zsh
|
||||||
ret="$?"
|
ret="$?"
|
||||||
echo ${ret}
|
echo ${ret}
|
||||||
[ "${ret}" = "0" ] && exit 1
|
[ "${ret}" = "0" ] && exit 1
|
||||||
@@ -173,15 +176,15 @@ set -e
|
|||||||
patt="plugins/ignore-*.zsh"
|
patt="plugins/ignore-*.zsh"
|
||||||
echo "[+] comparing with ignore (pattern: ${patt}) - no diff expected"
|
echo "[+] comparing with ignore (pattern: ${patt}) - no diff expected"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -C ${tmpd}/.zsh --ignore=${patt}
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -C "${tmpd}"/.zsh --ignore="${patt}"
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# expects no diff
|
# expects no diff
|
||||||
echo "[+] comparing with ignore in dotfile - no diff expected"
|
echo "[+] comparing with ignore in dotfile - no diff expected"
|
||||||
sed '/d_zsh:/a \ \ \ \ cmpignore:\n\ \ \ \ - "plugins/ignore-*.zsh"' ${cfg} > ${cfg2}
|
sed '/d_zsh:/a \ \ \ \ cmpignore:\n\ \ \ \ - "plugins/ignore-*.zsh"' "${cfg}" > "${cfg2}"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose -C ${tmpd}/.zsh
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose -C "${tmpd}"/.zsh
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|||||||
103
tests-ng/compare-ignore.sh
vendored
103
tests-ng/compare-ignore.sh
vendored
@@ -28,62 +28,65 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# some files
|
# some files
|
||||||
mkdir -p ${tmpd}/{program,config}
|
mkdir -p "${tmpd}"/{program,config}
|
||||||
touch ${tmpd}/program/a
|
touch "${tmpd}"/program/a
|
||||||
touch ${tmpd}/config/a
|
touch "${tmpd}"/config/a
|
||||||
mkdir ${tmpd}/vscode
|
mkdir "${tmpd}"/vscode
|
||||||
touch ${tmpd}/vscode/extensions.txt
|
touch "${tmpd}"/vscode/extensions.txt
|
||||||
touch ${tmpd}/vscode/keybindings.json
|
touch "${tmpd}"/vscode/keybindings.json
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/program
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/program
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/config
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/config
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/vscode
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/vscode
|
||||||
|
|
||||||
# add files
|
# add files
|
||||||
echo "[+] add files"
|
echo "[+] add files"
|
||||||
touch ${tmpd}/program/b
|
touch "${tmpd}"/program/b
|
||||||
touch ${tmpd}/config/b
|
touch "${tmpd}"/config/b
|
||||||
|
|
||||||
# expects diff
|
# expects diff
|
||||||
echo "[+] comparing normal - 2 diffs"
|
echo "[+] comparing normal - 2 diffs"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -91,7 +94,7 @@ set -e
|
|||||||
patt="${tmpd}/config/b"
|
patt="${tmpd}/config/b"
|
||||||
echo "[+] comparing with ignore (pattern: ${patt}) - 1 diff"
|
echo "[+] comparing with ignore (pattern: ${patt}) - 1 diff"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --ignore=${patt}
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose --ignore="${patt}"
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -99,7 +102,7 @@ set -e
|
|||||||
patt="*b"
|
patt="*b"
|
||||||
echo "[+] comparing with ignore (pattern: ${patt}) - 0 diff"
|
echo "[+] comparing with ignore (pattern: ${patt}) - 0 diff"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --ignore=${patt}
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose --ignore="${patt}"
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -107,7 +110,7 @@ set -e
|
|||||||
patt="*/config/*b"
|
patt="*/config/*b"
|
||||||
echo "[+] comparing with ignore (pattern: ${patt}) - 1 diff"
|
echo "[+] comparing with ignore (pattern: ${patt}) - 1 diff"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --ignore=${patt}
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose --ignore="${patt}"
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -115,86 +118,86 @@ set -e
|
|||||||
|
|
||||||
# adding ignore in dotfile
|
# adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*/config/b"' ${cfg} > ${cfg2}
|
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*/config/b"' "${cfg}" > "${cfg2}"
|
||||||
#cat ${cfg2}
|
#cat ${cfg2}
|
||||||
|
|
||||||
# expects one diff
|
# expects one diff
|
||||||
echo "[+] comparing with ignore in dotfile - 1 diff"
|
echo "[+] comparing with ignore in dotfile - 1 diff"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# adding ignore in dotfile
|
# adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*b"' ${cfg} > ${cfg2}
|
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*b"' "${cfg}" > "${cfg2}"
|
||||||
sed -i '/d_program:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*b"' ${cfg2}
|
sed -i '/d_program:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*b"' "${cfg2}"
|
||||||
#cat ${cfg2}
|
#cat ${cfg2}
|
||||||
|
|
||||||
# expects no diff
|
# expects no diff
|
||||||
patt="*b"
|
patt="*b"
|
||||||
echo "[+] comparing with ignore in dotfile - 0 diff"
|
echo "[+] comparing with ignore in dotfile - 0 diff"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# update files
|
# update files
|
||||||
echo touched > ${tmpd}/vscode/extensions.txt
|
echo touched > "${tmpd}"/vscode/extensions.txt
|
||||||
echo touched > ${tmpd}/vscode/keybindings.json
|
echo touched > "${tmpd}"/vscode/keybindings.json
|
||||||
|
|
||||||
# expect two diffs
|
# expect two diffs
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -C ${tmpd}/vscode
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -C "${tmpd}"/vscode
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# expects no diff
|
# expects no diff
|
||||||
sed '/d_vscode:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*extensions.txt"\n\ \ \ \ - "*keybindings.json"' ${cfg} > ${cfg2}
|
sed '/d_vscode:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*extensions.txt"\n\ \ \ \ - "*keybindings.json"' "${cfg}" > "${cfg2}"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose -C ${tmpd}/vscode
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose -C "${tmpd}"/vscode
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# clean
|
# clean
|
||||||
rm -rf ${basedir}/dotfiles
|
rm -rf "${basedir}"/dotfiles
|
||||||
mkdir -p ${basedir}/dotfiles
|
mkdir -p "${basedir}"/dotfiles
|
||||||
|
|
||||||
# create dotfiles/dirs
|
# create dotfiles/dirs
|
||||||
mkdir -p ${tmpd}/{program,config,vscode}
|
mkdir -p "${tmpd}"/{program,config,vscode}
|
||||||
touch ${tmpd}/program/a
|
touch "${tmpd}"/program/a
|
||||||
touch ${tmpd}/config/a
|
touch "${tmpd}"/config/a
|
||||||
touch ${tmpd}/vscode/extensions.txt
|
touch "${tmpd}"/vscode/extensions.txt
|
||||||
touch ${tmpd}/vscode/keybindings.json
|
touch "${tmpd}"/vscode/keybindings.json
|
||||||
touch ${tmpd}/vscode/keybindings.json
|
touch "${tmpd}"/vscode/keybindings.json
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config3.yaml"
|
cfg="${basedir}/config3.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/program ${tmpd}/config ${tmpd}/vscode
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/program "${tmpd}"/config "${tmpd}"/vscode
|
||||||
|
|
||||||
# create the files to ignore
|
# create the files to ignore
|
||||||
touch ${tmpd}/program/.DS_Store
|
touch "${tmpd}"/program/.DS_Store
|
||||||
touch ${tmpd}/config/.DS_Store
|
touch "${tmpd}"/config/.DS_Store
|
||||||
touch ${tmpd}/vscode/.DS_Store
|
touch "${tmpd}"/vscode/.DS_Store
|
||||||
|
|
||||||
# ensure not imported
|
# ensure not imported
|
||||||
found=`find ${basedir}/dotfiles/ -iname '.DS_Store'`
|
found=$(find "${basedir}"/dotfiles/ -iname '.DS_Store')
|
||||||
[ "${found}" != "" ] && echo "imported ???" && exit 1
|
[ "${found}" != "" ] && echo "imported ???" && exit 1
|
||||||
|
|
||||||
# general ignore
|
# general ignore
|
||||||
echo "[+] comparing ..."
|
echo "[+] comparing ..."
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -i '*/.DS_Store'
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -i '*/.DS_Store'
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
# general ignore
|
# general ignore
|
||||||
echo "[+] comparing2 ..."
|
echo "[+] comparing2 ..."
|
||||||
sed '/^config:$/a\ \ cmpignore:\n\ \ - "*/.DS_Store"' ${cfg} > ${cfg2}
|
sed '/^config:$/a\ \ cmpignore:\n\ \ - "*/.DS_Store"' "${cfg}" > "${cfg2}"
|
||||||
cat ${cfg2}
|
cat "${cfg2}"
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
57
tests-ng/compare-include.sh
vendored
57
tests-ng/compare-include.sh
vendored
@@ -27,41 +27,44 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
|
|
||||||
# create the dotfiles already imported
|
# create the dotfiles already imported
|
||||||
echo "already in" > ${tmps}/dotfiles/abc
|
echo "already in" > "${tmps}"/dotfiles/abc
|
||||||
cp ${tmps}/dotfiles/abc ${tmpd}/abc
|
cp "${tmps}"/dotfiles/abc "${tmpd}"/abc
|
||||||
|
|
||||||
# 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
|
||||||
@@ -84,36 +87,36 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p0
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p0
|
||||||
|
|
||||||
cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p0 | grep '^f_' | wc -l`
|
cnt=$(cd "${ddpath}" | ${bin} files -c "${cfg}" -p p0 | grep '^f_' | wc -l)
|
||||||
[ "${cnt}" != "1" ] && echo "this is bad" && exit 1
|
[ "${cnt}" != "1" ] && echo "this is bad" && exit 1
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p0
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p0
|
||||||
|
|
||||||
echo "modifying"
|
echo "modifying"
|
||||||
echo 'modified' > ${tmpd}/abc
|
echo 'modified' > "${tmpd}"/abc
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p0
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p0
|
||||||
ret=$?
|
ret=$?
|
||||||
[ "${ret}" = "0" ] && echo "compare should fail (returned ${ret})" && exit 1
|
[ "${ret}" = "0" ] && echo "compare should fail (returned ${ret})" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# count
|
# count
|
||||||
cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p0 -b | grep '^f_' | wc -l`
|
cnt=$(cd "${ddpath}" | ${bin} files -c "${cfg}" -p p0 -b | grep '^f_' | wc -l)
|
||||||
[ "${cnt}" != "2" ] && echo "not enough dotfile" exit 1
|
[ "${cnt}" != "2" ] && echo "not enough dotfile" exit 1
|
||||||
|
|
||||||
## without dotfiles: entry
|
## without dotfiles: entry
|
||||||
# reset dotfile content
|
# reset dotfile content
|
||||||
echo "already in" > ${tmps}/dotfiles/abc
|
echo "already in" > "${tmps}"/dotfiles/abc
|
||||||
cp ${tmps}/dotfiles/abc ${tmpd}/abc
|
cp "${tmps}"/dotfiles/abc "${tmpd}"/abc
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -134,28 +137,28 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p0
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p0
|
||||||
|
|
||||||
cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p0 | grep '^f_' | wc -l`
|
cnt=$(cd "${ddpath}" | ${bin} files -c "${cfg}" -p p0 | grep '^f_' | wc -l)
|
||||||
[ "${cnt}" != "1" ] && echo "this is bad" && exit 1
|
[ "${cnt}" != "1" ] && echo "this is bad" && exit 1
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p0
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p0
|
||||||
|
|
||||||
echo "modifying"
|
echo "modifying"
|
||||||
echo 'modified' > ${tmpd}/abc
|
echo 'modified' > "${tmpd}"/abc
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p0
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p0
|
||||||
ret=$?
|
ret=$?
|
||||||
[ "${ret}" = "0" ] && echo "compare should fail (returned ${ret})" && exit 1
|
[ "${ret}" = "0" ] && echo "compare should fail (returned ${ret})" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# count
|
# count
|
||||||
cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p0 -b | grep '^f_' | wc -l`
|
cnt=$(cd "${ddpath}" | ${bin} files -c "${cfg}" -p p0 -b | grep '^f_' | wc -l)
|
||||||
[ "${cnt}" != "2" ] && echo "not enough dotfile" exit 1
|
[ "${cnt}" != "2" ] && echo "not enough dotfile" exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
94
tests-ng/compare-negative-ignore-relative.sh
vendored
94
tests-ng/compare-negative-ignore-relative.sh
vendored
@@ -9,41 +9,12 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# all this crap to get current path
|
# all this crap to get current path
|
||||||
if [ $(uname) = Darwin ]; then
|
rl="readlink -f"
|
||||||
# Unfortunately, readlink works differently on macOS than it does on GNU/Linux
|
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
||||||
# (the -f option behaves differently) and the realpath command does not exist.
|
rl="realpath"
|
||||||
# Workarounds I find on the Internet suggest just using Homebrew to install coreutils
|
|
||||||
# so you can get the GNU coreutils on your Mac. But, I don't want this script to
|
|
||||||
# assume (a) users have Homebrew installed and (b) if they have Homebrew installed, that
|
|
||||||
# they then installed the GNU coreutils.
|
|
||||||
readlink() {
|
|
||||||
TARGET_FILE=$1
|
|
||||||
|
|
||||||
cd `dirname $TARGET_FILE`
|
if ! hash ${rl}; then
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
echo "\"${rl}\" not found !" && exit 1
|
||||||
|
|
||||||
# Iterate down a (possible) chain of symlinks
|
|
||||||
while [ -L "$TARGET_FILE" ]; do
|
|
||||||
TARGET_FILE=`readlink $TARGET_FILE`
|
|
||||||
cd `dirname $TARGET_FILE`
|
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
|
||||||
done
|
|
||||||
|
|
||||||
# Compute the canonicalized name by finding the physical path
|
|
||||||
# for the directory we're in and appending the target file.
|
|
||||||
PHYS_DIR=`pwd -P`
|
|
||||||
RESULT=$PHYS_DIR/$TARGET_FILE
|
|
||||||
echo $RESULT
|
|
||||||
}
|
|
||||||
rl="readlink"
|
|
||||||
else
|
|
||||||
rl="readlink -f"
|
|
||||||
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
|
||||||
rl="realpath"
|
|
||||||
|
|
||||||
if ! hash ${rl}; then
|
|
||||||
echo "\"${rl}\" not found !" && exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cur=$(dirname "$(${rl} "${0}")")
|
cur=$(dirname "$(${rl} "${0}")")
|
||||||
@@ -51,60 +22,63 @@ cur=$(dirname "$(${rl} "${0}")")
|
|||||||
# dotdrop path can be pass as argument
|
# dotdrop path can be pass as argument
|
||||||
ddpath="${cur}/../"
|
ddpath="${cur}/../"
|
||||||
[ -n "${1}" ] && ddpath="${1}"
|
[ -n "${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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# some files
|
# some files
|
||||||
mkdir -p ${tmpd}/program/ignore_me
|
mkdir -p "${tmpd}"/program/ignore_me
|
||||||
echo "some data" > ${tmpd}/program/a
|
echo "some data" > "${tmpd}"/program/a
|
||||||
echo "some data" > ${tmpd}/program/ignore_me/b
|
echo "some data" > "${tmpd}"/program/ignore_me/b
|
||||||
echo "some data" > ${tmpd}/program/ignore_me/c
|
echo "some data" > "${tmpd}"/program/ignore_me/c
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/program
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/program
|
||||||
|
|
||||||
# make some changes to generate a diff
|
# make some changes to generate a diff
|
||||||
echo "some other data" > ${tmpd}/program/a
|
echo "some other data" > "${tmpd}"/program/a
|
||||||
echo "some other data" > ${tmpd}/program/ignore_me/b
|
echo "some other data" > "${tmpd}"/program/ignore_me/b
|
||||||
echo "some other data" > ${tmpd}/program/ignore_me/c
|
echo "some other data" > "${tmpd}"/program/ignore_me/c
|
||||||
|
|
||||||
# expects two diffs (no need to test comparing normal - 3 diffs, as that is taken care of in compare-negative-ignore.sh)
|
# expects two diffs (no need to test comparing normal - 3 diffs, as that is taken care of in compare-negative-ignore.sh)
|
||||||
patt0="ignore_me/*"
|
patt0="ignore_me/*"
|
||||||
patt1="!ignore_me/c"
|
patt1="!ignore_me/c"
|
||||||
echo "[+] comparing with ignore (patterns: ${patt0} and ${patt1}) - 2 diffs"
|
echo "[+] comparing with ignore (patterns: ${patt0} and ${patt1}) - 2 diffs"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --ignore=${patt0} --ignore=${patt1}
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose --ignore="${patt0}" --ignore=${patt1}
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -112,16 +86,16 @@ set -e
|
|||||||
# Test ignores specified in config.yaml
|
# Test ignores specified in config.yaml
|
||||||
########################################
|
########################################
|
||||||
# add some files
|
# add some files
|
||||||
mkdir -p ${tmpd}/.zsh
|
mkdir -p "${tmpd}"/.zsh
|
||||||
echo "some data" > ${tmpd}/.zsh/somefile
|
echo "some data" > "${tmpd}"/.zsh/somefile
|
||||||
mkdir -p ${tmpd}/.zsh/plugins
|
mkdir -p "${tmpd}"/.zsh/plugins
|
||||||
echo "some data" > ${tmpd}/.zsh/plugins/someplugin
|
echo "some data" > "${tmpd}"/.zsh/plugins/someplugin
|
||||||
|
|
||||||
echo "[+] import .zsh"
|
echo "[+] import .zsh"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/.zsh
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/.zsh
|
||||||
|
|
||||||
touch ${tmpd}/.zsh/plugins/ignore-1.zsh
|
touch "${tmpd}"/.zsh/plugins/ignore-1.zsh
|
||||||
touch ${tmpd}/.zsh/plugins/ignore-2.zsh
|
touch "${tmpd}"/.zsh/plugins/ignore-2.zsh
|
||||||
|
|
||||||
# adding ignore in config.yaml
|
# adding ignore in config.yaml
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
@@ -129,21 +103,21 @@ sed '/d_zsh:/a\
|
|||||||
\ \ \ \ cmpignore:\
|
\ \ \ \ cmpignore:\
|
||||||
\ \ \ \ - "plugins/ignore-?.zsh"\
|
\ \ \ \ - "plugins/ignore-?.zsh"\
|
||||||
\ \ \ \ - "!plugins/ignore-2.zsh"
|
\ \ \ \ - "!plugins/ignore-2.zsh"
|
||||||
' ${cfg} > ${cfg2}
|
' "${cfg}" > "${cfg2}"
|
||||||
|
|
||||||
# expects one diff
|
# expects one diff
|
||||||
patt0="plugins/ignore-?.zsh"
|
patt0="plugins/ignore-?.zsh"
|
||||||
patt1="!plugins/ignore-2.zsh"
|
patt1="!plugins/ignore-2.zsh"
|
||||||
echo "[+] comparing with ignore (patterns: ${patt0} and ${patt1}) - 1 diff"
|
echo "[+] comparing with ignore (patterns: ${patt0} and ${patt1}) - 1 diff"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -C ${tmpd}/.zsh --ignore=${patt0} --ignore=${patt1}
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -C "${tmpd}"/.zsh --ignore="${patt0}" --ignore=${patt1}
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# expects one diff
|
# expects one diff
|
||||||
echo "[+] comparing .zsh with ignore in dotfile - 1 diff expected"
|
echo "[+] comparing .zsh with ignore in dotfile - 1 diff expected"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose -C ${tmpd}/.zsh
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose -C "${tmpd}"/.zsh
|
||||||
ret="$?"
|
ret="$?"
|
||||||
echo ${ret}
|
echo ${ret}
|
||||||
[ "${ret}" = "0" ] && exit 1
|
[ "${ret}" = "0" ] && exit 1
|
||||||
|
|||||||
77
tests-ng/compare-negative-ignore.sh
vendored
77
tests-ng/compare-negative-ignore.sh
vendored
@@ -9,41 +9,12 @@
|
|||||||
#set -e
|
#set -e
|
||||||
|
|
||||||
# all this crap to get current path
|
# all this crap to get current path
|
||||||
if [ $(uname) = Darwin ]; then
|
rl="readlink -f"
|
||||||
# Unfortunately, readlink works differently on macOS than it does on GNU/Linux
|
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
||||||
# (the -f option behaves differently) and the realpath command does not exist.
|
rl="realpath"
|
||||||
# Workarounds I find on the Internet suggest just using Homebrew to install coreutils
|
|
||||||
# so you can get the GNU coreutils on your Mac. But, I don't want this script to
|
|
||||||
# assume (a) users have Homebrew installed and (b) if they have Homebrew installed, that
|
|
||||||
# they then installed the GNU coreutils.
|
|
||||||
readlink() {
|
|
||||||
TARGET_FILE=$1
|
|
||||||
|
|
||||||
cd `dirname $TARGET_FILE`
|
if ! hash ${rl}; then
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
echo "\"${rl}\" not found !" && exit 1
|
||||||
|
|
||||||
# Iterate down a (possible) chain of symlinks
|
|
||||||
while [ -L "$TARGET_FILE" ]; do
|
|
||||||
TARGET_FILE=`readlink $TARGET_FILE`
|
|
||||||
cd `dirname $TARGET_FILE`
|
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
|
||||||
done
|
|
||||||
|
|
||||||
# Compute the canonicalized name by finding the physical path
|
|
||||||
# for the directory we're in and appending the target file.
|
|
||||||
PHYS_DIR=`pwd -P`
|
|
||||||
RESULT=$PHYS_DIR/$TARGET_FILE
|
|
||||||
echo $RESULT
|
|
||||||
}
|
|
||||||
rl="readlink"
|
|
||||||
else
|
|
||||||
rl="readlink -f"
|
|
||||||
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
|
||||||
rl="realpath"
|
|
||||||
|
|
||||||
if ! hash ${rl}; then
|
|
||||||
echo "\"${rl}\" not found !" && exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cur=$(dirname "$(${rl} "${0}")")
|
cur=$(dirname "$(${rl} "${0}")")
|
||||||
@@ -51,7 +22,7 @@ cur=$(dirname "$(${rl} "${0}")")
|
|||||||
# dotdrop path can be pass as argument
|
# dotdrop path can be pass as argument
|
||||||
ddpath="${cur}/../"
|
ddpath="${cur}/../"
|
||||||
[ -n "${1}" ] && ddpath="${1}"
|
[ -n "${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"
|
||||||
@@ -60,47 +31,48 @@ 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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# some files
|
# some files
|
||||||
mkdir -p ${tmpd}/program/ignore_me
|
mkdir -p "${tmpd}"/program/ignore_me
|
||||||
echo "some data" > ${tmpd}/program/a
|
echo "some data" > "${tmpd}"/program/a
|
||||||
echo "some data" > ${tmpd}/program/ignore_me/b
|
echo "some data" > "${tmpd}"/program/ignore_me/b
|
||||||
echo "some data" > ${tmpd}/program/ignore_me/c
|
echo "some data" > "${tmpd}"/program/ignore_me/c
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/program
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/program
|
||||||
|
|
||||||
# make some changes to generate a diff
|
# make some changes to generate a diff
|
||||||
echo "some other data" > ${tmpd}/program/a
|
echo "some other data" > "${tmpd}"/program/a
|
||||||
echo "some other data" > ${tmpd}/program/ignore_me/b
|
echo "some other data" > "${tmpd}"/program/ignore_me/b
|
||||||
echo "some other data" > ${tmpd}/program/ignore_me/c
|
echo "some other data" > "${tmpd}"/program/ignore_me/c
|
||||||
|
|
||||||
echo "[+] comparing normal - 3 diffs"
|
echo "[+] comparing normal - 3 diffs"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose
|
||||||
[ "$?" = 0 ] && exit 1 # We don't want an exit status of 0
|
[ "$?" = 0 ] && exit 1 # We don't want an exit status of 0
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -109,22 +81,23 @@ patt0="*/ignore_me/*"
|
|||||||
patt1="!*/ignore_me/c"
|
patt1="!*/ignore_me/c"
|
||||||
echo "[+] comparing with ignore (patterns: ${patt0} and ${patt1}) - 2 diffs"
|
echo "[+] comparing with ignore (patterns: ${patt0} and ${patt1}) - 2 diffs"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --ignore=${patt0} --ignore=${patt1}
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose --ignore="${patt0}" --ignore="${patt1}"
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Adding ignore in dotfile
|
# Adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
|
# shellcheck disable=SC1004
|
||||||
sed '/d_program:/a\
|
sed '/d_program:/a\
|
||||||
\ \ \ \ cmpignore:\
|
\ \ \ \ cmpignore:\
|
||||||
\ \ \ \ - "*/ignore_me/*"\
|
\ \ \ \ - "*/ignore_me/*"\
|
||||||
\ \ \ \ - "!*/ignore_me/c"
|
\ \ \ \ - "!*/ignore_me/c"
|
||||||
' ${cfg} > ${cfg2}
|
' "${cfg}" > "${cfg2}"
|
||||||
|
|
||||||
# still expects two diffs
|
# still expects two diffs
|
||||||
echo "[+] comparing with ignore in dotfile - 2 diffs"
|
echo "[+] comparing with ignore in dotfile - 2 diffs"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|||||||
63
tests-ng/compare-profile-check.sh
vendored
63
tests-ng/compare-profile-check.sh
vendored
@@ -23,19 +23,22 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
@@ -43,25 +46,25 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)"
|
|||||||
|
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
tmps=`mktemp -d --suffix='-dotdrop-tests-source' || mktemp -d`
|
tmps=$(mktemp -d --suffix='-dotdrop-tests-source' || mktemp -d)
|
||||||
dt="${tmps}/dotfiles"
|
dt="${tmps}/dotfiles"
|
||||||
mkdir -p ${dt}
|
mkdir -p "${dt}"
|
||||||
|
|
||||||
xori="profile x"
|
xori="profile x"
|
||||||
xori="profile y"
|
xori="profile y"
|
||||||
echo "${xori}" > ${dt}/file_x
|
echo "${xori}" > "${dt}"/file_x
|
||||||
echo "${yori}" > ${dt}/file_y
|
echo "${yori}" > "${dt}"/file_y
|
||||||
|
|
||||||
# fs dotfiles
|
# fs dotfiles
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests-dest' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests-dest' || mktemp -d)
|
||||||
touch ${tmpd}/file
|
touch "${tmpd}"/file
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# 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: false
|
backup: false
|
||||||
create: true
|
create: true
|
||||||
@@ -81,65 +84,65 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_file_y
|
- f_file_y
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# reset
|
# reset
|
||||||
echo "${xori}" > ${dt}/file_x
|
echo "${xori}" > "${dt}"/file_x
|
||||||
echo "${yori}" > ${dt}/file_y
|
echo "${yori}" > "${dt}"/file_y
|
||||||
|
|
||||||
echo "test compare profile x (ok)"
|
echo "test compare profile x (ok)"
|
||||||
echo "${xori}" > ${tmpd}/file
|
echo "${xori}" > "${tmpd}"/file
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -p x -C ${tmpd}/file
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -p x -C "${tmpd}"/file
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "test compare profile x (not ok)"
|
echo "test compare profile x (not ok)"
|
||||||
echo "${yori}" > ${tmpd}/file
|
echo "${yori}" > "${tmpd}"/file
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -p x -C ${tmpd}/file
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -p x -C "${tmpd}"/file
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "test compare profile y (ok)"
|
echo "test compare profile y (ok)"
|
||||||
echo "${yori}" > ${tmpd}/file
|
echo "${yori}" > "${tmpd}"/file
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -p y -C ${tmpd}/file
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -p y -C "${tmpd}"/file
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "test compare profile y (not ok)"
|
echo "test compare profile y (not ok)"
|
||||||
echo "${xori}" > ${tmpd}/file
|
echo "${xori}" > "${tmpd}"/file
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -p y -C ${tmpd}/file
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -p y -C "${tmpd}"/file
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "test compare profile x generic (ok)"
|
echo "test compare profile x generic (ok)"
|
||||||
echo "${xori}" > ${tmpd}/file
|
echo "${xori}" > "${tmpd}"/file
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -p x
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -p x
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "test compare profile x generic (not ok)"
|
echo "test compare profile x generic (not ok)"
|
||||||
echo "${yori}" > ${tmpd}/file
|
echo "${yori}" > "${tmpd}"/file
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -p x
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -p x
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "test compare profile y generic (ok)"
|
echo "test compare profile y generic (ok)"
|
||||||
echo "${yori}" > ${tmpd}/file
|
echo "${yori}" > "${tmpd}"/file
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -p y
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -p y
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "test compare profile y generic (not ok)"
|
echo "test compare profile y generic (not ok)"
|
||||||
echo "${xori}" > ${tmpd}/file
|
echo "${xori}" > "${tmpd}"/file
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -p y
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose -p y
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|||||||
75
tests-ng/compare.sh
vendored
75
tests-ng/compare.sh
vendored
@@ -28,99 +28,102 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# single file
|
# single file
|
||||||
echo 'unique' > ${tmpd}/uniquefile
|
echo 'unique' > "${tmpd}"/uniquefile
|
||||||
|
|
||||||
# hierarchy from https://pymotw.com/2/filecmp/
|
# hierarchy from https://pymotw.com/2/filecmp/
|
||||||
# create the hierarchy
|
# create the hierarchy
|
||||||
# for dir1 (originally imported directory))))
|
# for dir1 (originally imported directory))))
|
||||||
mkdir ${tmpd}/dir1
|
mkdir "${tmpd}"/dir1
|
||||||
touch ${tmpd}/dir1/file_only_in_dir1
|
touch "${tmpd}"/dir1/file_only_in_dir1
|
||||||
mkdir -p ${tmpd}/dir1/dir_only_in_dir1
|
mkdir -p "${tmpd}"/dir1/dir_only_in_dir1
|
||||||
mkdir -p ${tmpd}/dir1/common_dir
|
mkdir -p "${tmpd}"/dir1/common_dir
|
||||||
echo 'this file is the same' > ${tmpd}/dir1/common_file
|
echo 'this file is the same' > "${tmpd}"/dir1/common_file
|
||||||
echo 'in dir1' > ${tmpd}/dir1/not_the_same
|
echo 'in dir1' > "${tmpd}"/dir1/not_the_same
|
||||||
echo 'This is a file in dir1' > ${tmpd}/dir1/file_in_dir1
|
echo 'This is a file in dir1' > "${tmpd}"/dir1/file_in_dir1
|
||||||
mkdir -p ${tmpd}/dir1/sub/sub2
|
mkdir -p "${tmpd}"/dir1/sub/sub2
|
||||||
mkdir -p ${tmpd}/dir1/notindir2/notindir2
|
mkdir -p "${tmpd}"/dir1/notindir2/notindir2
|
||||||
echo 'first' > ${tmpd}/dir1/sub/sub2/different
|
echo 'first' > "${tmpd}"/dir1/sub/sub2/different
|
||||||
#tree ${tmpd}/dir1
|
#tree ${tmpd}/dir1
|
||||||
|
|
||||||
# create the hierarchy
|
# create the hierarchy
|
||||||
# for dir2 (modified original for update)
|
# for dir2 (modified original for update)
|
||||||
mkdir ${tmpd}/dir2
|
mkdir "${tmpd}"/dir2
|
||||||
touch ${tmpd}/dir2/file_only_in_dir2
|
touch "${tmpd}"/dir2/file_only_in_dir2
|
||||||
mkdir -p ${tmpd}/dir2/dir_only_in_dir2
|
mkdir -p "${tmpd}"/dir2/dir_only_in_dir2
|
||||||
mkdir -p ${tmpd}/dir2/common_dir
|
mkdir -p "${tmpd}"/dir2/common_dir
|
||||||
echo 'this file is the same' > ${tmpd}/dir2/common_file
|
echo 'this file is the same' > "${tmpd}"/dir2/common_file
|
||||||
echo 'in dir2' > ${tmpd}/dir2/not_the_same
|
echo 'in dir2' > "${tmpd}"/dir2/not_the_same
|
||||||
mkdir -p ${tmpd}/dir2/file_in_dir1
|
mkdir -p "${tmpd}"/dir2/file_in_dir1
|
||||||
mkdir -p ${tmpd}/dir2/sub/sub2
|
mkdir -p "${tmpd}"/dir2/sub/sub2
|
||||||
echo 'modified' > ${tmpd}/dir2/sub/sub2/different
|
echo 'modified' > "${tmpd}"/dir2/sub/sub2/different
|
||||||
mkdir -p ${tmpd}/dir2/new/new2
|
mkdir -p "${tmpd}"/dir2/new/new2
|
||||||
#tree ${tmpd}/dir2
|
#tree ${tmpd}/dir2
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
|
|
||||||
# import dir1
|
# import dir1
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/dir1
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/dir1
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/uniquefile
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/uniquefile
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# let's see the dotpath
|
# let's see the dotpath
|
||||||
#tree ${basedir}/dotfiles
|
#tree ${basedir}/dotfiles
|
||||||
|
|
||||||
# change dir1 to dir2 in deployed
|
# change dir1 to dir2 in deployed
|
||||||
echo "[+] change dir"
|
echo "[+] change dir"
|
||||||
rm -rf ${tmpd}/dir1
|
rm -rf "${tmpd}"/dir1
|
||||||
mv ${tmpd}/dir2 ${tmpd}/dir1
|
mv "${tmpd}"/dir2 "${tmpd}"/dir1
|
||||||
#tree ${tmpd}/dir1
|
#tree ${tmpd}/dir1
|
||||||
|
|
||||||
# change unique file
|
# change unique file
|
||||||
echo 'changed' > ${tmpd}/uniquefile
|
echo 'changed' > "${tmpd}"/uniquefile
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
echo "[+] comparing"
|
echo "[+] comparing"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" --verbose
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "[+] comparing with file-only"
|
echo "[+] comparing with file-only"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -L
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -L
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|||||||
27
tests-ng/corner-case.sh
vendored
27
tests-ng/corner-case.sh
vendored
@@ -33,26 +33,29 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
@@ -62,7 +65,7 @@ export DOTDROP_WORKERS=1
|
|||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -83,24 +86,24 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
echo "[+] test install dry"
|
echo "[+] test install dry"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} --dry -p p1 --verbose f_x
|
cd "${ddpath}" | ${bin} install -c "${cfg}" --dry -p p1 --verbose f_x
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
echo "[+] test install show-diff"
|
echo "[+] test install show-diff"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -p p1 --verbose f_x
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -p p1 --verbose f_x
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
cd ${ddpath} | ${bin} install -D -c ${cfg} -p p1 --verbose f_x
|
cd "${ddpath}" | ${bin} install -D -c "${cfg}" -p p1 --verbose f_x
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
echo "[+] test install not existing src"
|
echo "[+] test install not existing src"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f --dry -p p1 --verbose f_y
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -f --dry -p p1 --verbose f_y
|
||||||
|
|
||||||
echo "[+] test install to temp"
|
echo "[+] test install to temp"
|
||||||
cd ${ddpath} | ${bin} install -t -c ${cfg} -p p1 --verbose f_x > ${basedir}/log 2>&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
|
[ "$?" != "0" ] && echo "install to tmp failed" && exit 1
|
||||||
|
|
||||||
# cleaning
|
# cleaning
|
||||||
tmpfile=`cat ${basedir}/log | grep 'installed to tmp ' | sed 's/^.*to tmp "\(.*\)"./\1/'`
|
tmpfile=$(cat "${basedir}"/log | grep 'installed to tmp ' | sed 's/^.*to tmp "\(.*\)"./\1/')
|
||||||
echo "tmpfile: ${tmpfile}"
|
echo "tmpfile: ${tmpfile}"
|
||||||
rm -rf "${tmpfile}"
|
rm -rf "${tmpfile}"
|
||||||
|
|
||||||
|
|||||||
53
tests-ng/deprecated-link.sh
vendored
53
tests-ng/deprecated-link.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
@@ -58,7 +61,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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: false
|
backup: false
|
||||||
create: true
|
create: true
|
||||||
@@ -103,38 +106,38 @@ profiles:
|
|||||||
- f_children2
|
- f_children2
|
||||||
- f_children3
|
- f_children3
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# create the dotfiles
|
# create the dotfiles
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > "${tmps}"/dotfiles/abc
|
||||||
echo "test" > ${tmpd}/abc
|
echo "test" > "${tmpd}"/abc
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p1
|
||||||
# install
|
# install
|
||||||
#cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
#cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# fail if find some of these entries
|
# fail if find some of these entries
|
||||||
echo "========> test for bad entries"
|
echo "========> test for bad entries"
|
||||||
set +e
|
set +e
|
||||||
grep 'link_children: true' ${cfg} >/dev/null && exit 1
|
grep 'link_children: true' "${cfg}" >/dev/null && exit 1
|
||||||
grep 'link_children: false' ${cfg} >/dev/null && exit 1
|
grep 'link_children: false' "${cfg}" >/dev/null && exit 1
|
||||||
grep 'link: true' ${cfg} >/dev/null && exit 1
|
grep 'link: true' "${cfg}" >/dev/null && exit 1
|
||||||
grep 'link: false' ${cfg} >/dev/null && exit 1
|
grep 'link: false' "${cfg}" >/dev/null && exit 1
|
||||||
grep 'link_by_default: true' ${cfg} >/dev/null && exit 1
|
grep 'link_by_default: true' "${cfg}" >/dev/null && exit 1
|
||||||
grep 'link_by_default: false' ${cfg} >/dev/null && exit 1
|
grep 'link_by_default: false' "${cfg}" >/dev/null && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# test values have been correctly updated
|
# test values have been correctly updated
|
||||||
echo "========> test for updated entries"
|
echo "========> test for updated entries"
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_link' | head -1 | grep ',link:absolute,'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | grep '^f_link' | head -1 | grep ',link:absolute,'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_nolink' | head -1 | grep ',link:nolink,'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | grep '^f_nolink' | head -1 | grep ',link:nolink,'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_nolink1' | head -1 | grep ',link:nolink,'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | grep '^f_nolink1' | head -1 | grep ',link:nolink,'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_children' | head -1 | grep ',link:link_children,'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | grep '^f_children' | head -1 | grep ',link:link_children,'
|
||||||
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_children2' | head -1 | grep ',link:link_children,'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_children3' | head -1 | grep ',link:nolink,'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | grep '^f_children3' | head -1 | grep ',link:nolink,'
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
43
tests-ng/diff-cmd.sh
vendored
43
tests-ng/diff-cmd.sh
vendored
@@ -28,41 +28,44 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# some files
|
# some files
|
||||||
echo "original" > ${tmpd}/singlefile
|
echo "original" > "${tmpd}"/singlefile
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -73,52 +76,52 @@ _EOF
|
|||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/singlefile
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/singlefile
|
||||||
|
|
||||||
# modify the file
|
# modify the file
|
||||||
echo "modified" > ${tmpd}/singlefile
|
echo "modified" > "${tmpd}"/singlefile
|
||||||
|
|
||||||
# default diff (unified)
|
# default diff (unified)
|
||||||
echo "[+] comparing with default diff (unified)"
|
echo "[+] comparing with default diff (unified)"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -b -c ${cfg} 2>/dev/null | grep -v '=>' | grep -v '\->' | grep -v 'dotfile(s) compared' | sed '$d' | grep -v '^+++\|^---' > ${tmpd}/normal
|
cd "${ddpath}" | ${bin} compare -b -c "${cfg}" 2>/dev/null | grep -v '=>' | grep -v '\->' | grep -v 'dotfile(s) compared' | sed '$d' | grep -v '^+++\|^---' > "${tmpd}"/normal
|
||||||
diff -u -r ${tmpd}/singlefile ${basedir}/dotfiles/${tmpd}/singlefile | grep -v '^+++\|^---' > ${tmpd}/real
|
diff -u -r "${tmpd}"/singlefile "${basedir}"/dotfiles/"${tmpd}"/singlefile | grep -v '^+++\|^---' > "${tmpd}"/real
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# verify
|
# verify
|
||||||
diff ${tmpd}/normal ${tmpd}/real || exit 1
|
diff "${tmpd}"/normal "${tmpd}"/real || exit 1
|
||||||
|
|
||||||
# adding normal diff
|
# adding normal diff
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/dotpath: dotfiles/a \ \ diff_command: "diff -r {0} {1}"' ${cfg} > ${cfg2}
|
sed '/dotpath: dotfiles/a \ \ diff_command: "diff -r {0} {1}"' "${cfg}" > "${cfg2}"
|
||||||
#cat ${cfg2}
|
#cat ${cfg2}
|
||||||
|
|
||||||
# normal diff
|
# normal diff
|
||||||
echo "[+] comparing with normal diff"
|
echo "[+] comparing with normal diff"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -b -c ${cfg2} 2>/dev/null | grep -v '=>' | grep -v '\->' | grep -v 'dotfile(s) compared' | sed '$d' > ${tmpd}/unified
|
cd "${ddpath}" | ${bin} compare -b -c "${cfg2}" 2>/dev/null | grep -v '=>' | grep -v '\->' | grep -v 'dotfile(s) compared' | sed '$d' > "${tmpd}"/unified
|
||||||
diff -r ${tmpd}/singlefile ${basedir}/dotfiles/${tmpd}/singlefile > ${tmpd}/real
|
diff -r "${tmpd}"/singlefile "${basedir}"/dotfiles/"${tmpd}"/singlefile > "${tmpd}"/real
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# verify
|
# verify
|
||||||
#cat ${tmpd}/unified
|
#cat ${tmpd}/unified
|
||||||
#cat ${tmpd}/real
|
#cat ${tmpd}/real
|
||||||
diff ${tmpd}/unified ${tmpd}/real || exit 1
|
diff "${tmpd}"/unified "${tmpd}"/real || exit 1
|
||||||
|
|
||||||
# adding fake diff
|
# adding fake diff
|
||||||
cfg3="${basedir}/config3.yaml"
|
cfg3="${basedir}/config3.yaml"
|
||||||
sed '/dotpath: dotfiles/a \ \ diff_command: "echo fakediff"' ${cfg} > ${cfg3}
|
sed '/dotpath: dotfiles/a \ \ diff_command: "echo fakediff"' "${cfg}" > "${cfg3}"
|
||||||
#cat ${cfg3}
|
#cat ${cfg3}
|
||||||
|
|
||||||
# fake diff
|
# fake diff
|
||||||
echo "[+] comparing with fake diff"
|
echo "[+] comparing with fake diff"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -b -c ${cfg3} 2>/dev/null | grep -v '=>' | grep -v '\->' | grep -v 'dotfile(s) compared' | sed '$d' > ${tmpd}/fake
|
cd "${ddpath}" | ${bin} compare -b -c "${cfg3}" 2>/dev/null | grep -v '=>' | grep -v '\->' | grep -v 'dotfile(s) compared' | sed '$d' > "${tmpd}"/fake
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# verify
|
# verify
|
||||||
#cat ${tmpd}/fake
|
#cat ${tmpd}/fake
|
||||||
grep fakediff ${tmpd}/fake &> /dev/null || exit 1
|
grep fakediff "${tmpd}"/fake &> /dev/null || exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
27
tests-ng/dir-import-update.sh
vendored
27
tests-ng/dir-import-update.sh
vendored
@@ -28,49 +28,52 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
dotfiles="${basedir}/dotfiles"
|
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)
|
||||||
create_dir ${tmpd}
|
create_dir "${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
|
|
||||||
# import the dir
|
# import the dir
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"
|
||||||
|
|
||||||
# change token
|
# change token
|
||||||
echo "changed" > ${token}
|
echo "changed" > "${token}"
|
||||||
|
|
||||||
# update
|
# update
|
||||||
cd ${ddpath} | ${bin} update -f -c ${cfg} ${tmpd} --verbose
|
cd "${ddpath}" | ${bin} update -f -c "${cfg}" "${tmpd}" --verbose
|
||||||
|
|
||||||
grep 'changed' ${token} >/dev/null 2>&1
|
grep 'changed' "${token}" >/dev/null 2>&1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
35
tests-ng/dotdrop-variables.sh
vendored
35
tests-ng/dotdrop-variables.sh
vendored
@@ -28,30 +28,33 @@ 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"
|
||||||
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 "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) <==$(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
|
||||||
#echo "dotfile source: ${tmps}"
|
#echo "dotfile source: ${tmps}"
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -60,7 +63,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -78,18 +81,18 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "dotpath: {{@@ _dotdrop_dotpath @@}}" > ${tmps}/dotfiles/abc
|
echo "dotpath: {{@@ _dotdrop_dotpath @@}}" > "${tmps}"/dotfiles/abc
|
||||||
echo "cfgpath: {{@@ _dotdrop_cfgpath @@}}" >> ${tmps}/dotfiles/abc
|
echo "cfgpath: {{@@ _dotdrop_cfgpath @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "workdir: {{@@ _dotdrop_workdir @@}}" >> ${tmps}/dotfiles/abc
|
echo "workdir: {{@@ _dotdrop_workdir @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
cat ${tmpd}/abc
|
cat "${tmpd}"/abc
|
||||||
|
|
||||||
grep "^dotpath: ${tmps}/dotfiles$" ${tmpd}/abc >/dev/null
|
grep "^dotpath: ${tmps}/dotfiles$" "${tmpd}"/abc >/dev/null
|
||||||
grep "^cfgpath: ${tmps}/config.yaml$" ${tmpd}/abc >/dev/null
|
grep "^cfgpath: ${tmps}/config.yaml$" "${tmpd}"/abc >/dev/null
|
||||||
grep "^workdir: /tmp/xxx$" ${tmpd}/abc >/dev/null
|
grep "^workdir: /tmp/xxx$" "${tmpd}"/abc >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
27
tests-ng/dotfile-no-src.sh
vendored
27
tests-ng/dotfile-no-src.sh
vendored
@@ -29,30 +29,33 @@ 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"
|
||||||
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 "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) <==$(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
|
||||||
echo "dotfiles source (dotpath): ${tmps}"
|
echo "dotfiles source (dotpath): ${tmps}"
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "dotfiles destination: ${tmpd}"
|
echo "dotfiles destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -77,19 +80,19 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfiles
|
# create the dotfiles
|
||||||
echo "abc" > ${tmps}/dotfiles/abc
|
echo "abc" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# test install and compare
|
# test install and compare
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -b -V
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpd}/abc ] && exit 1
|
[ ! -e "${tmpd}"/abc ] && exit 1
|
||||||
grep 'abc' ${tmpd}/abc
|
grep 'abc' "${tmpd}"/abc
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
51
tests-ng/dotfile-sub-variables.sh
vendored
51
tests-ng/dotfile-sub-variables.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
@@ -58,7 +61,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -75,32 +78,32 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmps}/dotfiles/abc
|
mkdir -p "${tmps}"/dotfiles/abc
|
||||||
# file1
|
# file1
|
||||||
echo 'src:{{@@ _dotfile_sub_abs_src @@}}' > ${tmps}/dotfiles/abc/file1
|
echo 'src:{{@@ _dotfile_sub_abs_src @@}}' > "${tmps}"/dotfiles/abc/file1
|
||||||
echo 'dst:{{@@ _dotfile_sub_abs_dst @@}}' >> ${tmps}/dotfiles/abc/file1
|
echo 'dst:{{@@ _dotfile_sub_abs_dst @@}}' >> "${tmps}"/dotfiles/abc/file1
|
||||||
|
|
||||||
# file2
|
# file2
|
||||||
mkdir -p ${tmps}/dotfiles/abc/subdir
|
mkdir -p "${tmps}"/dotfiles/abc/subdir
|
||||||
echo 'src:{{@@ _dotfile_sub_abs_src @@}}' > ${tmps}/dotfiles/abc/subdir/file2
|
echo 'src:{{@@ _dotfile_sub_abs_src @@}}' > "${tmps}"/dotfiles/abc/subdir/file2
|
||||||
echo 'dst:{{@@ _dotfile_sub_abs_dst @@}}' >> ${tmps}/dotfiles/abc/subdir/file2
|
echo 'dst:{{@@ _dotfile_sub_abs_dst @@}}' >> "${tmps}"/dotfiles/abc/subdir/file2
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -d ${tmpd}/abc ] && echo 'dotfile not installed' && exit 1
|
[ ! -d "${tmpd}"/abc ] && echo 'dotfile not installed' && exit 1
|
||||||
[ ! -e ${tmpd}/abc/file1 ] && echo 'dotfile sub src not installed' && exit 1
|
[ ! -e "${tmpd}"/abc/file1 ] && echo 'dotfile sub src not installed' && exit 1
|
||||||
[ ! -e ${tmpd}/abc/subdir/file2 ] && echo 'dotfile sub dst not installed' && exit 1
|
[ ! -e "${tmpd}"/abc/subdir/file2 ] && echo 'dotfile sub dst not installed' && exit 1
|
||||||
|
|
||||||
cat ${tmpd}/abc/file1
|
cat "${tmpd}"/abc/file1
|
||||||
cat ${tmpd}/abc/subdir/file2
|
cat "${tmpd}"/abc/subdir/file2
|
||||||
|
|
||||||
grep "src:${tmps}/dotfiles/abc/file1" ${tmpd}/abc/file1 >/dev/null
|
grep "src:${tmps}/dotfiles/abc/file1" "${tmpd}"/abc/file1 >/dev/null
|
||||||
grep "dst:${tmpd}/abc/file1" ${tmpd}/abc/file1>/dev/null
|
grep "dst:${tmpd}/abc/file1" "${tmpd}"/abc/file1>/dev/null
|
||||||
|
|
||||||
grep "src:${tmps}/dotfiles/abc/subdir/file2" ${tmpd}/abc/subdir/file2 >/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
|
grep "dst:${tmpd}/abc/subdir/file2" "${tmpd}"/abc/subdir/file2 >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
41
tests-ng/dotfile-variables.sh
vendored
41
tests-ng/dotfile-variables.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
@@ -58,7 +61,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -75,21 +78,21 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo 'src:{{@@ _dotfile_abs_src @@}}' > ${tmps}/dotfiles/abc
|
echo 'src:{{@@ _dotfile_abs_src @@}}' > "${tmps}"/dotfiles/abc
|
||||||
echo 'dst:{{@@ _dotfile_abs_dst @@}}' >> ${tmps}/dotfiles/abc
|
echo 'dst:{{@@ _dotfile_abs_dst @@}}' >> "${tmps}"/dotfiles/abc
|
||||||
echo 'key:{{@@ _dotfile_key @@}}' >> ${tmps}/dotfiles/abc
|
echo 'key:{{@@ _dotfile_key @@}}' >> "${tmps}"/dotfiles/abc
|
||||||
echo 'link:{{@@ _dotfile_link @@}}' >> ${tmps}/dotfiles/abc
|
echo 'link:{{@@ _dotfile_link @@}}' >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpd}/abc ] && echo 'dotfile not installed' && exit 1
|
[ ! -e "${tmpd}"/abc ] && echo 'dotfile not installed' && exit 1
|
||||||
cat ${tmpd}/abc
|
cat "${tmpd}"/abc
|
||||||
grep "src:${tmps}/dotfiles/abc" ${tmpd}/abc >/dev/null
|
grep "src:${tmps}/dotfiles/abc" "${tmpd}"/abc >/dev/null
|
||||||
grep "dst:${tmpd}/abc" ${tmpd}/abc >/dev/null
|
grep "dst:${tmpd}/abc" "${tmpd}"/abc >/dev/null
|
||||||
grep "key:f_abc" ${tmpd}/abc >/dev/null
|
grep "key:f_abc" "${tmpd}"/abc >/dev/null
|
||||||
grep "link:nolink" ${tmpd}/abc >/dev/null
|
grep "link:nolink" "${tmpd}"/abc >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
41
tests-ng/dotfiles-all.sh
vendored
41
tests-ng/dotfiles-all.sh
vendored
@@ -29,30 +29,33 @@ 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"
|
||||||
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 "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) <==$(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
|
||||||
echo "dotfiles source (dotpath): ${tmps}"
|
echo "dotfiles source (dotpath): ${tmps}"
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "dotfiles destination: ${tmpd}"
|
echo "dotfiles destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -84,31 +87,31 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfiles
|
# create the dotfiles
|
||||||
echo "abc" > ${tmps}/dotfiles/abc
|
echo "abc" > "${tmps}"/dotfiles/abc
|
||||||
echo "def" > ${tmps}/dotfiles/def
|
echo "def" > "${tmps}"/dotfiles/def
|
||||||
echo "ghi" > ${tmps}/dotfiles/ghi
|
echo "ghi" > "${tmps}"/dotfiles/ghi
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# test install and compare
|
# test install and compare
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -b -V
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpd}/abc ] && exit 1
|
[ ! -e "${tmpd}"/abc ] && exit 1
|
||||||
[ ! -e ${tmpd}/def ] && exit 1
|
[ ! -e "${tmpd}"/def ] && exit 1
|
||||||
[ ! -e ${tmpd}/ghi ] && exit 1
|
[ ! -e "${tmpd}"/ghi ] && exit 1
|
||||||
|
|
||||||
# modify the dotfiles
|
# modify the dotfiles
|
||||||
echo "abc-modified" > ${tmps}/dotfiles/abc
|
echo "abc-modified" > "${tmps}"/dotfiles/abc
|
||||||
echo "def-modified" > ${tmps}/dotfiles/def
|
echo "def-modified" > "${tmps}"/dotfiles/def
|
||||||
echo "ghi-modified" > ${tmps}/dotfiles/ghi
|
echo "ghi-modified" > "${tmps}"/dotfiles/ghi
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 -b -V
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p1 -b -V
|
||||||
ret="$?"
|
ret="$?"
|
||||||
set -e
|
set -e
|
||||||
[ "$ret" = "0" ] && exit 1
|
[ "$ret" = "0" ] && exit 1
|
||||||
|
|||||||
25
tests-ng/dotfiles-dyn-paths.sh
vendored
25
tests-ng/dotfiles-dyn-paths.sh
vendored
@@ -29,30 +29,33 @@ 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"
|
||||||
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 "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) <==$(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
|
||||||
echo "dotfiles source (dotpath): ${tmps}"
|
echo "dotfiles source (dotpath): ${tmps}"
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "dotfiles destination: ${tmpd}"
|
echo "dotfiles destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -82,18 +85,18 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfiles
|
# create the dotfiles
|
||||||
echo "abc" > ${tmps}/dotfiles/abc
|
echo "abc" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# test install and compare
|
# test install and compare
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -b -V
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpd}/abc ] && exit 1
|
[ ! -e "${tmpd}"/abc ] && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
19
tests-ng/double-config-import.sh
vendored
19
tests-ng/double-config-import.sh
vendored
@@ -27,19 +27,22 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
@@ -57,7 +60,7 @@ error_log="${dst}/error.log"
|
|||||||
|
|
||||||
# bottom-level
|
# bottom-level
|
||||||
bottom_level_cfg="${src}/bottom-level.yaml"
|
bottom_level_cfg="${src}/bottom-level.yaml"
|
||||||
cat > ${bottom_level_cfg} << _EOF
|
cat > "${bottom_level_cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -70,7 +73,7 @@ touch "${src}/dotfiles/bottom"
|
|||||||
|
|
||||||
# mid-level
|
# mid-level
|
||||||
mid_level_cfg="${src}/mid-level.yaml"
|
mid_level_cfg="${src}/mid-level.yaml"
|
||||||
cat > ${mid_level_cfg} << _EOF
|
cat > "${mid_level_cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -85,7 +88,7 @@ _EOF
|
|||||||
|
|
||||||
# top-level
|
# top-level
|
||||||
top_level_cfg="${src}/top-level.yaml"
|
top_level_cfg="${src}/top-level.yaml"
|
||||||
cat > ${top_level_cfg} << _EOF
|
cat > "${top_level_cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -101,7 +104,7 @@ _EOF
|
|||||||
|
|
||||||
# install
|
# install
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} install -f -c ${top_level_cfg} -p top-level 2> "${error_log}"
|
cd "${ddpath}" | ${bin} install -f -c "${top_level_cfg}" -p top-level 2> "${error_log}"
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
|
|||||||
203
tests-ng/dry.sh
vendored
203
tests-ng/dry.sh
vendored
@@ -27,34 +27,37 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
# workdir
|
# workdir
|
||||||
tmpw=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpw=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
export DOTDROP_WORKDIR="${tmpw}"
|
export DOTDROP_WORKDIR="${tmpw}"
|
||||||
# temp
|
# temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
@@ -65,23 +68,23 @@ clear_on_exit "${tmpa}"
|
|||||||
# test install
|
# test install
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# cleaning
|
# cleaning
|
||||||
rm -rf ${tmps}/*
|
rm -rf "${tmps:?}"/*
|
||||||
mkdir -p ${tmps}/dotfiles
|
mkdir -p "${tmps}"/dotfiles
|
||||||
rm -rf ${tmpw}/*
|
rm -rf "${tmpw:?}"/*
|
||||||
rm -rf ${tmpd}/*
|
rm -rf "${tmpd:?}"/*
|
||||||
rm -rf ${tmpa}/*
|
rm -rf "${tmpa:?}"/*
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
echo '{{@@ profile @@}}' > ${tmps}/dotfiles/file
|
echo '{{@@ profile @@}}' > "${tmps}"/dotfiles/file
|
||||||
echo '{{@@ profile @@}}' > ${tmps}/dotfiles/link
|
echo '{{@@ profile @@}}' > "${tmps}"/dotfiles/link
|
||||||
mkdir -p ${tmps}/dotfiles/dir
|
mkdir -p "${tmps}"/dotfiles/dir
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dir/f1
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dir/f1
|
||||||
mkdir -p ${tmps}/dotfiles/dirchildren
|
mkdir -p "${tmps}"/dotfiles/dirchildren
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dirchildren/f1
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dirchildren/f1
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dirchildren/f2
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dirchildren/f2
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -130,33 +133,33 @@ _EOF
|
|||||||
|
|
||||||
# install
|
# install
|
||||||
echo "dry install"
|
echo "dry install"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 -V --dry
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p1 -V --dry
|
||||||
|
|
||||||
cnt=`ls -1 ${tmpd} | wc -l`
|
cnt=$(find "${tmpd}" -type f | wc -l)
|
||||||
ls -1 ${tmpd}
|
ls -1 "${tmpd}"
|
||||||
[ "${cnt}" != "0" ] && echo "dry install failed (1)" && exit 1
|
[ "${cnt}" != "0" ] && echo "dry install failed (1)" && exit 1
|
||||||
|
|
||||||
cnt=`ls -1 ${tmpw} | wc -l`
|
cnt=$(find "${tmpw}" -type f | wc -l)
|
||||||
ls -1 ${tmpw}
|
ls -1 "${tmpw}"
|
||||||
[ "${cnt}" != "0" ] && echo "dry install failed (2)" && exit 1
|
[ "${cnt}" != "0" ] && echo "dry install failed (2)" && exit 1
|
||||||
|
|
||||||
cnt=`ls -1 ${tmpa} | wc -l`
|
cnt=$(find "${tmpa}" -type f | wc -l)
|
||||||
ls -1 ${tmpa}
|
ls -1 "${tmpa}"
|
||||||
[ "${cnt}" != "0" ] && echo "dry install failed (3)" && exit 1
|
[ "${cnt}" != "0" ] && echo "dry install failed (3)" && exit 1
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# test import
|
# test import
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# cleaning
|
# cleaning
|
||||||
rm -rf ${tmps}/*
|
rm -rf "${tmps:?}"/*
|
||||||
mkdir -p ${tmps}/dotfiles
|
mkdir -p "${tmps}"/dotfiles
|
||||||
rm -rf ${tmpw}/*
|
rm -rf "${tmpw:?}"/*
|
||||||
rm -rf ${tmpd}/*
|
rm -rf "${tmpd:?}"/*
|
||||||
rm -rf ${tmpa}/*
|
rm -rf "${tmpa:?}"/*
|
||||||
|
|
||||||
# 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
|
||||||
@@ -165,54 +168,52 @@ config:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
profiles:
|
profiles:
|
||||||
_EOF
|
_EOF
|
||||||
cp ${cfg} ${tmpa}/config.yaml
|
cp "${cfg}" "${tmpa}"/config.yaml
|
||||||
|
|
||||||
echo 'content' > ${tmpd}/file
|
echo 'content' > "${tmpd}"/file
|
||||||
echo 'content' > ${tmpd}/link
|
echo 'content' > "${tmpd}"/link
|
||||||
mkdir -p ${tmpd}/dir
|
mkdir -p "${tmpd}"/dir
|
||||||
echo "content" > ${tmpd}/dir/f1
|
echo "content" > "${tmpd}"/dir/f1
|
||||||
mkdir -p ${tmpd}/dirchildren
|
mkdir -p "${tmpd}"/dirchildren
|
||||||
echo "content" > ${tmpd}/dirchildren/f1
|
echo "content" > "${tmpd}"/dirchildren/f1
|
||||||
echo "content" > ${tmpd}/dirchildren/f2
|
echo "content" > "${tmpd}"/dirchildren/f2
|
||||||
|
|
||||||
dotfiles="${tmpd}/file ${tmpd}/link ${tmpd}/dir ${tmpd}/dirchildren"
|
|
||||||
|
|
||||||
echo "dry import"
|
echo "dry import"
|
||||||
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 -V --dry ${dotfiles}
|
cd "${ddpath}" | ${bin} import -c "${cfg}" -f -p p1 -V --dry "${tmpd}"/file "${tmpd}"/link "${tmpd}"/dir "${tmpd}"/dirchildren
|
||||||
|
|
||||||
cnt=`ls -1 ${tmps}/dotfiles | wc -l`
|
cnt=$(find "${tmps}"/dotfiles | wc -l)
|
||||||
ls -1 ${tmps}/dotfiles
|
ls -1 "${tmps}"/dotfiles
|
||||||
[ "${cnt}" != "0" ] && echo "dry import failed (1)" && exit 1
|
[ "${cnt}" != "0" ] && echo "dry import failed (1)" && exit 1
|
||||||
|
|
||||||
diff ${cfg} ${tmpa}/config.yaml || (echo "dry import failed (2)" && exit 1)
|
diff "${cfg}" "${tmpa}"/config.yaml || (echo "dry import failed (2)" && exit 1)
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# test update
|
# test update
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# cleaning
|
# cleaning
|
||||||
rm -rf ${tmps}/*
|
rm -rf "${tmps:?}"/*
|
||||||
mkdir -p ${tmps}/dotfiles
|
mkdir -p "${tmps}"/dotfiles
|
||||||
rm -rf ${tmpw}/*
|
rm -rf "${tmpw:?}"/*
|
||||||
rm -rf ${tmpd}/*
|
rm -rf "${tmpd:?}"/*
|
||||||
rm -rf ${tmpa}/*
|
rm -rf "${tmpa:?}"/*
|
||||||
|
|
||||||
echo 'original' > ${tmps}/dotfiles/file
|
echo 'original' > "${tmps}"/dotfiles/file
|
||||||
echo 'original' > ${tmps}/dotfiles/link
|
echo 'original' > "${tmps}"/dotfiles/link
|
||||||
mkdir -p ${tmps}/dotfiles/dir
|
mkdir -p "${tmps}"/dotfiles/dir
|
||||||
echo "original" > ${tmps}/dotfiles/dir/f1
|
echo "original" > "${tmps}"/dotfiles/dir/f1
|
||||||
mkdir -p ${tmps}/dotfiles/dirchildren
|
mkdir -p "${tmps}"/dotfiles/dirchildren
|
||||||
echo "original" > ${tmps}/dotfiles/dirchildren/f1
|
echo "original" > "${tmps}"/dotfiles/dirchildren/f1
|
||||||
echo "original" > ${tmps}/dotfiles/dirchildren/f2
|
echo "original" > "${tmps}"/dotfiles/dirchildren/f2
|
||||||
|
|
||||||
echo 'modified' > ${tmpd}/file
|
echo 'modified' > "${tmpd}"/file
|
||||||
echo 'modified' > ${tmpd}/link
|
echo 'modified' > "${tmpd}"/link
|
||||||
mkdir -p ${tmpd}/dir
|
mkdir -p "${tmpd}"/dir
|
||||||
echo "modified" > ${tmpd}/dir/f1
|
echo "modified" > "${tmpd}"/dir/f1
|
||||||
mkdir -p ${tmpd}/dirchildren
|
mkdir -p "${tmpd}"/dirchildren
|
||||||
echo "modified" > ${tmpd}/dirchildren/f1
|
echo "modified" > "${tmpd}"/dirchildren/f1
|
||||||
echo "modified" > ${tmpd}/dirchildren/f2
|
echo "modified" > "${tmpd}"/dirchildren/f2
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -241,39 +242,38 @@ profiles:
|
|||||||
- d_dir
|
- d_dir
|
||||||
- d_dirchildren
|
- d_dirchildren
|
||||||
_EOF
|
_EOF
|
||||||
cp ${cfg} ${tmpa}/config.yaml
|
cp "${cfg}" "${tmpa}"/config.yaml
|
||||||
|
|
||||||
echo "dry update"
|
echo "dry update"
|
||||||
dotfiles="${tmpd}/file ${tmpd}/link ${tmpd}/dir ${tmpd}/dirchildren"
|
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 -V --dry "${tmpd}"/file "${tmpd}"/link "${tmpd}"/dir "${tmpd}"/dirchildren
|
||||||
cd ${ddpath} | ${bin} update -c ${cfg} -f -p p1 -V --dry ${dotfiles}
|
|
||||||
|
|
||||||
grep 'modified' ${tmps}/dotfiles/file && echo "dry update failed (1)" && exit 1
|
grep 'modified' "${tmps}"/dotfiles/file && echo "dry update failed (1)" && exit 1
|
||||||
grep 'modified' ${tmps}/dotfiles/link && echo "dry update failed (2)" && exit 1
|
grep 'modified' "${tmps}"/dotfiles/link && echo "dry update failed (2)" && exit 1
|
||||||
grep "modified" ${tmps}/dotfiles/dir/f1 && echo "dry update failed (3)" && exit 1
|
grep "modified" "${tmps}"/dotfiles/dir/f1 && echo "dry update failed (3)" && exit 1
|
||||||
grep "modified" ${tmps}/dotfiles/dirchildren/f1 && echo "dry update failed (4)" && exit 1
|
grep "modified" "${tmps}"/dotfiles/dirchildren/f1 && echo "dry update failed (4)" && exit 1
|
||||||
grep "modified" ${tmps}/dotfiles/dirchildren/f2 && echo "dry update failed (5)" && exit 1
|
grep "modified" "${tmps}"/dotfiles/dirchildren/f2 && echo "dry update failed (5)" && exit 1
|
||||||
|
|
||||||
diff ${cfg} ${tmpa}/config.yaml || (echo "dry update failed (6)" && exit 1)
|
diff "${cfg}" "${tmpa}"/config.yaml || (echo "dry update failed (6)" && exit 1)
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# test remove
|
# test remove
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# cleaning
|
# cleaning
|
||||||
rm -rf ${tmps}/*
|
rm -rf "${tmps:?}"/*
|
||||||
mkdir -p ${tmps}/dotfiles
|
mkdir -p "${tmps}"/dotfiles
|
||||||
rm -rf ${tmpw}/*
|
rm -rf "${tmpw:?}"/*
|
||||||
rm -rf ${tmpd}/*
|
rm -rf "${tmpd:?}"/*
|
||||||
rm -rf ${tmpa}/*
|
rm -rf "${tmpa:?}"/*
|
||||||
|
|
||||||
echo '{{@@ profile @@}}' > ${tmps}/dotfiles/file
|
echo '{{@@ profile @@}}' > "${tmps}"/dotfiles/file
|
||||||
echo '{{@@ profile @@}}' > ${tmps}/dotfiles/link
|
echo '{{@@ profile @@}}' > "${tmps}"/dotfiles/link
|
||||||
mkdir -p ${tmps}/dotfiles/dir
|
mkdir -p "${tmps}"/dotfiles/dir
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dir/f1
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dir/f1
|
||||||
mkdir -p ${tmps}/dotfiles/dirchildren
|
mkdir -p "${tmps}"/dotfiles/dirchildren
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dirchildren/f1
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dirchildren/f1
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dirchildren/f2
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dirchildren/f2
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -302,21 +302,20 @@ profiles:
|
|||||||
- d_dir
|
- d_dir
|
||||||
- d_dirchildren
|
- d_dirchildren
|
||||||
_EOF
|
_EOF
|
||||||
cp ${cfg} ${tmpa}/config.yaml
|
cp "${cfg}" "${tmpa}"/config.yaml
|
||||||
|
|
||||||
echo "dry remove"
|
echo "dry remove"
|
||||||
dotfiles="${tmpd}/file ${tmpd}/link ${tmpd}/dir ${tmpd}/dirchildren"
|
cd "${ddpath}" | ${bin} remove -c "${cfg}" -f -p p1 -V --dry "${tmpd}"/file "${tmpd}"/link "${tmpd}"/dir "${tmpd}"/dirchildren
|
||||||
cd ${ddpath} | ${bin} remove -c ${cfg} -f -p p1 -V --dry ${dotfiles}
|
|
||||||
|
|
||||||
[ ! -e ${tmps}/dotfiles/file ] && echo "dry remove failed (1)" && exit 1
|
[ ! -e "${tmps}"/dotfiles/file ] && echo "dry remove failed (1)" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/link ] && echo "dry remove failed (2)" && exit 1
|
[ ! -e "${tmps}"/dotfiles/link ] && echo "dry remove failed (2)" && exit 1
|
||||||
[ ! -d ${tmps}/dotfiles/dir ] && echo "dry remove failed (3)" && exit 1
|
[ ! -d "${tmps}"/dotfiles/dir ] && echo "dry remove failed (3)" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/dir/f1 ] && echo "dry remove failed (4)" && exit 1
|
[ ! -e "${tmps}"/dotfiles/dir/f1 ] && echo "dry remove failed (4)" && exit 1
|
||||||
[ ! -d ${tmps}/dotfiles/dirchildren ] && echo "dry remove failed (5)" && exit 1
|
[ ! -d "${tmps}"/dotfiles/dirchildren ] && echo "dry remove failed (5)" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/dirchildren/f1 ] && echo "dry remove failed (6)" && exit 1
|
[ ! -e "${tmps}"/dotfiles/dirchildren/f1 ] && echo "dry remove failed (6)" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/dirchildren/f2 ] && echo "dry remove failed (7)" && exit 1
|
[ ! -e "${tmps}"/dotfiles/dirchildren/f2 ] && echo "dry remove failed (7)" && exit 1
|
||||||
|
|
||||||
diff ${cfg} ${tmpa}/config.yaml || (echo "dry remove failed (8)" && exit 1)
|
diff "${cfg}" "${tmpa}"/config.yaml || (echo "dry remove failed (8)" && exit 1)
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
51
tests-ng/duplicate-key.sh
vendored
51
tests-ng/duplicate-key.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
@@ -58,7 +61,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -75,30 +78,30 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the imported one
|
# create the imported one
|
||||||
mkdir -p ${tmps}/dotfiles/${tmpd}
|
mkdir -p "${tmps}"/dotfiles/"${tmpd}"
|
||||||
echo "test" > ${tmps}/dotfiles/${tmpd}/abc
|
echo "test" > "${tmps}"/dotfiles/"${tmpd}"/abc
|
||||||
echo "test" > ${tmpd}/abc
|
echo "test" > "${tmpd}"/abc
|
||||||
|
|
||||||
# create the to-be-imported
|
# create the to-be-imported
|
||||||
mkdir -p ${tmpd}/sub
|
mkdir -p "${tmpd}"/sub
|
||||||
echo "test2" > ${tmpd}/sub/abc
|
echo "test2" > "${tmpd}"/sub/abc
|
||||||
|
|
||||||
mkdir -p ${tmpd}/sub/sub2
|
mkdir -p "${tmpd}"/sub/sub2
|
||||||
echo "test2" > ${tmpd}/sub/sub2/abc
|
echo "test2" > "${tmpd}"/sub/sub2/abc
|
||||||
|
|
||||||
mkdir -p ${tmpd}/sub/sub
|
mkdir -p "${tmpd}"/sub/sub
|
||||||
echo "test2" > ${tmpd}/sub/sub/abc
|
echo "test2" > "${tmpd}"/sub/sub/abc
|
||||||
|
|
||||||
# import
|
# import
|
||||||
cd ${ddpath} | ${bin} import -f --verbose -c ${cfg} -p p2 \
|
cd "${ddpath}" | ${bin} import -f --verbose -c "${cfg}" -p p2 \
|
||||||
${tmpd}/abc \
|
"${tmpd}"/abc \
|
||||||
${tmpd}/sub/abc \
|
"${tmpd}"/sub/abc \
|
||||||
${tmpd}/sub/abc \
|
"${tmpd}"/sub/abc \
|
||||||
${tmpd}/sub/sub/abc \
|
"${tmpd}"/sub/sub/abc \
|
||||||
${tmpd}/sub/sub2/abc
|
"${tmpd}"/sub/sub2/abc
|
||||||
|
|
||||||
# count dotfiles for p2
|
# count dotfiles for p2
|
||||||
cnt=`cd ${ddpath} | ${bin} files --verbose -c ${cfg} -p p2 -b | grep '^f_' | wc -l`
|
cnt=$(cd "${ddpath}" | ${bin} files --verbose -c "${cfg}" -p p2 -b | grep '^f_' | wc -l)
|
||||||
[ "${cnt}" != "4" ] && echo "bad count for p2: ${cnt} != 4" && exit 1
|
[ "${cnt}" != "4" ] && echo "bad count for p2: ${cnt} != 4" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
49
tests-ng/dynactions.sh
vendored
49
tests-ng/dynactions.sh
vendored
@@ -28,31 +28,34 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# the action temp
|
# the action temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
# 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}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpa}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
variables:
|
variables:
|
||||||
var1: "var1"
|
var1: "var1"
|
||||||
var2: "{{@@ var1 @@}} var2"
|
var2: "{{@@ var1 @@}} var2"
|
||||||
@@ -104,25 +107,25 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 --verbose
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --verbose
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpa}/preaction1 ] && exit 1
|
[ ! -e "${tmpa}"/preaction1 ] && exit 1
|
||||||
[ ! -e ${tmpa}/preaction2 ] && exit 1
|
[ ! -e "${tmpa}"/preaction2 ] && exit 1
|
||||||
[ ! -e ${tmpa}/postaction1 ] && exit 1
|
[ ! -e "${tmpa}"/postaction1 ] && exit 1
|
||||||
[ ! -e ${tmpa}/postaction2 ] && exit 1
|
[ ! -e "${tmpa}"/postaction2 ] && exit 1
|
||||||
[ ! -e ${tmpa}/naked1 ] && exit 1
|
[ ! -e "${tmpa}"/naked1 ] && exit 1
|
||||||
[ ! -e ${tmpa}/naked2 ] && exit 1
|
[ ! -e "${tmpa}"/naked2 ] && exit 1
|
||||||
|
|
||||||
grep 'var1 var2 var3' ${tmpa}/preaction1 >/dev/null
|
grep 'var1 var2 var3' "${tmpa}"/preaction1 >/dev/null
|
||||||
grep 'dvar1 dvar2 dvar3' ${tmpa}/preaction2 >/dev/null
|
grep 'dvar1 dvar2 dvar3' "${tmpa}"/preaction2 >/dev/null
|
||||||
grep 'var1 var2 var3' ${tmpa}/postaction1 >/dev/null
|
grep 'var1 var2 var3' "${tmpa}"/postaction1 >/dev/null
|
||||||
grep 'dvar1 dvar2 dvar3' ${tmpa}/postaction2 >/dev/null
|
grep 'dvar1 dvar2 dvar3' "${tmpa}"/postaction2 >/dev/null
|
||||||
grep 'var1 var2 var3' ${tmpa}/naked1 >/dev/null
|
grep 'var1 var2 var3' "${tmpa}"/naked1 >/dev/null
|
||||||
grep 'dvar1 dvar2 dvar3' ${tmpa}/naked2 >/dev/null
|
grep 'dvar1 dvar2 dvar3' "${tmpa}"/naked2 >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
29
tests-ng/dyndotfilepaths.sh
vendored
29
tests-ng/dyndotfilepaths.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
@@ -58,9 +61,9 @@ clear_on_exit "${tmpd}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
dst=`echo ${tmpd} | rev`
|
dst=$(echo "${tmpd}" | rev)
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -79,15 +82,15 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ dpath @@}}" > ${tmps}/dotfiles/abc
|
echo "{{@@ dpath @@}}" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
|
|
||||||
[ ! -e ${tmpd}/abc ] && echo "abc not installed dynamically" && exit 1
|
[ ! -e "${tmpd}"/abc ] && echo "abc not installed dynamically" && exit 1
|
||||||
grep "^${tmpd}" ${tmpd}/abc >/dev/null
|
grep "^${tmpd}" "${tmpd}"/abc >/dev/null
|
||||||
|
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
|
|
||||||
|
|||||||
69
tests-ng/dynextvariables.sh
vendored
69
tests-ng/dynextvariables.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -63,7 +66,7 @@ pvars="${tmps}/p1_vars.yaml"
|
|||||||
pvarin="${tmps}/inprofile_vars.yaml"
|
pvarin="${tmps}/inprofile_vars.yaml"
|
||||||
pvarout="${tmps}/outprofile_vars.yaml"
|
pvarout="${tmps}/outprofile_vars.yaml"
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -92,64 +95,64 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the external variables file
|
# create the external variables file
|
||||||
cat > ${extvars} << _EOF
|
cat > "${extvars}" << _EOF
|
||||||
variables:
|
variables:
|
||||||
vara: "extvar1"
|
vara: "extvar1"
|
||||||
dynvariables:
|
dynvariables:
|
||||||
dvara: "echo extdvar1"
|
dvara: "echo extdvar1"
|
||||||
_EOF
|
_EOF
|
||||||
cat > ${extdvars} << _EOF
|
cat > "${extdvars}" << _EOF
|
||||||
variables:
|
variables:
|
||||||
varb: "extvar2"
|
varb: "extvar2"
|
||||||
dynvariables:
|
dynvariables:
|
||||||
dvarb: "echo extdvar2"
|
dvarb: "echo extdvar2"
|
||||||
_EOF
|
_EOF
|
||||||
cat > ${pvars} << _EOF
|
cat > "${pvars}" << _EOF
|
||||||
variables:
|
variables:
|
||||||
pvar: "pvar1"
|
pvar: "pvar1"
|
||||||
dynvariables:
|
dynvariables:
|
||||||
pdvar: "echo pdvar1"
|
pdvar: "echo pdvar1"
|
||||||
_EOF
|
_EOF
|
||||||
cat > ${pvarin} << _EOF
|
cat > "${pvarin}" << _EOF
|
||||||
variables:
|
variables:
|
||||||
test: profileok
|
test: profileok
|
||||||
_EOF
|
_EOF
|
||||||
cat > ${pvarout} << _EOF
|
cat > "${pvarout}" << _EOF
|
||||||
variables:
|
variables:
|
||||||
test: profilenotok
|
test: profilenotok
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "var1: {{@@ var1 @@}}" > ${tmps}/dotfiles/abc
|
echo "var1: {{@@ var1 @@}}" > "${tmps}"/dotfiles/abc
|
||||||
echo "dvar1: {{@@ dvar1 @@}}" >> ${tmps}/dotfiles/abc
|
echo "dvar1: {{@@ dvar1 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
# from var file 1
|
# from var file 1
|
||||||
echo "vara: {{@@ vara @@}}" >> ${tmps}/dotfiles/abc
|
echo "vara: {{@@ vara @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "dvara: {{@@ dvara @@}}" >> ${tmps}/dotfiles/abc
|
echo "dvara: {{@@ dvara @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
# from var file 2
|
# from var file 2
|
||||||
echo "varb: {{@@ varb @@}}" >> ${tmps}/dotfiles/abc
|
echo "varb: {{@@ varb @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "dvarb: {{@@ dvarb @@}}" >> ${tmps}/dotfiles/abc
|
echo "dvarb: {{@@ dvarb @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
# from var file 3
|
# from var file 3
|
||||||
echo "pvar: {{@@ pvar @@}}" >> ${tmps}/dotfiles/abc
|
echo "pvar: {{@@ pvar @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "pdvar: {{@@ pdvar @@}}" >> ${tmps}/dotfiles/abc
|
echo "pdvar: {{@@ pdvar @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
# from profile variable
|
# from profile variable
|
||||||
echo "test: {{@@ test @@}}" >> ${tmps}/dotfiles/abc
|
echo "test: {{@@ test @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
#cat ${tmps}/dotfiles/abc
|
#cat ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
cat ${tmpd}/abc
|
cat "${tmpd}"/abc
|
||||||
|
|
||||||
grep '^var1: var' ${tmpd}/abc >/dev/null
|
grep '^var1: var' "${tmpd}"/abc >/dev/null
|
||||||
grep '^dvar1: dynvar' ${tmpd}/abc >/dev/null
|
grep '^dvar1: dynvar' "${tmpd}"/abc >/dev/null
|
||||||
grep '^vara: extvar1' ${tmpd}/abc >/dev/null
|
grep '^vara: extvar1' "${tmpd}"/abc >/dev/null
|
||||||
grep '^dvara: extdvar1' ${tmpd}/abc >/dev/null
|
grep '^dvara: extdvar1' "${tmpd}"/abc >/dev/null
|
||||||
grep '^varb: extvar2' ${tmpd}/abc >/dev/null
|
grep '^varb: extvar2' "${tmpd}"/abc >/dev/null
|
||||||
grep '^dvarb: extdvar2' ${tmpd}/abc >/dev/null
|
grep '^dvarb: extdvar2' "${tmpd}"/abc >/dev/null
|
||||||
grep '^pvar: pvar1' ${tmpd}/abc >/dev/null
|
grep '^pvar: pvar1' "${tmpd}"/abc >/dev/null
|
||||||
grep '^pdvar: pdvar1' ${tmpd}/abc >/dev/null
|
grep '^pdvar: pdvar1' "${tmpd}"/abc >/dev/null
|
||||||
grep '^test: profileok' ${tmpd}/abc >/dev/null
|
grep '^test: profileok' "${tmpd}"/abc >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
35
tests-ng/dyninclude.sh
vendored
35
tests-ng/dyninclude.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
@@ -58,7 +61,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
variables:
|
variables:
|
||||||
var1: "_1"
|
var1: "_1"
|
||||||
dynvariables:
|
dynvariables:
|
||||||
@@ -92,25 +95,25 @@ _EOF
|
|||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
c1="content:abc"
|
c1="content:abc"
|
||||||
echo "${c1}" > ${tmps}/dotfiles/abc
|
echo "${c1}" > "${tmps}"/dotfiles/abc
|
||||||
c2="content:def"
|
c2="content:def"
|
||||||
echo "${c2}" > ${tmps}/dotfiles/def
|
echo "${c2}" > "${tmps}"/dotfiles/def
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p profile_3 --verbose
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p profile_3 --verbose
|
||||||
|
|
||||||
# check dotfile exists
|
# check dotfile exists
|
||||||
[ ! -e ${tmpd}/abc ] && exit 1
|
[ ! -e "${tmpd}"/abc ] && exit 1
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
grep ${c1} ${tmpd}/abc >/dev/null || exit 1
|
grep ${c1} "${tmpd}"/abc >/dev/null || exit 1
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p profile_4 --verbose
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p profile_4 --verbose
|
||||||
|
|
||||||
# check dotfile exists
|
# check dotfile exists
|
||||||
[ ! -e ${tmpd}/def ] && exit 1
|
[ ! -e "${tmpd}"/def ] && exit 1
|
||||||
#cat ${tmpd}/def
|
#cat ${tmpd}/def
|
||||||
grep ${c2} ${tmpd}/def >/dev/null || exit 1
|
grep ${c2} "${tmpd}"/def >/dev/null || exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
51
tests-ng/dynvariables.sh
vendored
51
tests-ng/dynvariables.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -58,15 +61,15 @@ clear_on_exit "${tmpd}"
|
|||||||
|
|
||||||
# create a shell script
|
# create a shell script
|
||||||
export TESTENV="this is my testenv"
|
export TESTENV="this is my testenv"
|
||||||
scr=`mktemp --suffix='-dotdrop-tests' || mktemp -d`
|
scr=$(mktemp --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
chmod +x ${scr}
|
chmod +x "${scr}"
|
||||||
echo -e "#!/bin/bash\necho $TESTENV\n" >> ${scr}
|
echo -e "#!/bin/bash\necho $TESTENV\n" >> "${scr}"
|
||||||
clear_on_exit "${scr}"
|
clear_on_exit "${scr}"
|
||||||
|
|
||||||
# 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,25 +94,25 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ var1 @@}}" > ${tmps}/dotfiles/abc
|
echo "{{@@ var1 @@}}" > "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ dvar1 @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ dvar1 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ dvar2 @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ dvar2 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ dvar3 @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ dvar3 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ dvar4 @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ dvar4 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "test" >> ${tmps}/dotfiles/abc
|
echo "test" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
echo "-----"
|
echo "-----"
|
||||||
cat ${tmpd}/abc
|
cat "${tmpd}"/abc
|
||||||
echo "-----"
|
echo "-----"
|
||||||
|
|
||||||
grep '^this is some test' ${tmpd}/abc >/dev/null
|
grep '^this is some test' "${tmpd}"/abc >/dev/null
|
||||||
grep '^# author: deadc0de6' ${tmpd}/abc >/dev/null
|
grep '^# author: deadc0de6' "${tmpd}"/abc >/dev/null
|
||||||
grep '^tset,emos,si,siht' ${tmpd}/abc >/dev/null
|
grep '^tset,emos,si,siht' "${tmpd}"/abc >/dev/null
|
||||||
grep "^${TESTENV}" ${tmpd}/abc > /dev/null
|
grep "^${TESTENV}" "${tmpd}"/abc > /dev/null
|
||||||
grep '^4ravd_eht' ${tmpd}/abc >/dev/null
|
grep '^4ravd_eht' "${tmpd}"/abc >/dev/null
|
||||||
|
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
|
|
||||||
|
|||||||
65
tests-ng/env.sh
vendored
65
tests-ng/env.sh
vendored
@@ -27,32 +27,35 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
tmpx=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpx=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
tmpy=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpy=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
@@ -60,15 +63,15 @@ clear_on_exit "${tmpx}"
|
|||||||
clear_on_exit "${tmpy}"
|
clear_on_exit "${tmpy}"
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmpd}/adir
|
mkdir -p "${tmpd}"/adir
|
||||||
echo "adir/file1" > ${tmpd}/adir/file1
|
echo "adir/file1" > "${tmpd}"/adir/file1
|
||||||
echo "adir/fil2" > ${tmpd}/adir/file2
|
echo "adir/fil2" > "${tmpd}"/adir/file2
|
||||||
echo "file3" > ${tmpd}/file3
|
echo "file3" > "${tmpd}"/file3
|
||||||
|
|
||||||
# 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
|
||||||
@@ -88,40 +91,40 @@ export DOTDROP_WORKDIR="${tmpy}"
|
|||||||
export DOTDROP_WORKERS="1"
|
export DOTDROP_WORKERS="1"
|
||||||
|
|
||||||
# import
|
# import
|
||||||
cd ${ddpath} | ${bin} import -f ${tmpd}/adir
|
cd "${ddpath}" | ${bin} import -f "${tmpd}"/adir
|
||||||
cd ${ddpath} | ${bin} import -f ${tmpd}/file3
|
cd "${ddpath}" | ${bin} import -f "${tmpd}"/file3
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# ensure exists and is not link
|
# ensure exists and is not link
|
||||||
[ ! -d ${tmps}/dotfiles/${tmpd}/adir ] && echo "not a directory" && exit 1
|
[ ! -d "${tmps}"/dotfiles/"${tmpd}"/adir ] && echo "not a directory" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/adir/file1 ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/adir/file1 ] && echo "not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/adir/file2 ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/adir/file2 ] && echo "not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/file3 ] && echo "not a file" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/file3 ] && echo "not a file" && exit 1
|
||||||
|
|
||||||
cat ${cfg} | grep ${tmpd}/adir >/dev/null 2>&1
|
cat "${cfg}" | grep "${tmpd}"/adir >/dev/null 2>&1
|
||||||
cat ${cfg} | grep ${tmpd}/file3 >/dev/null 2>&1
|
cat "${cfg}" | grep "${tmpd}"/file3 >/dev/null 2>&1
|
||||||
|
|
||||||
nb=`cat ${cfg} | grep d_adir | wc -l`
|
nb=$(cat "${cfg}" | grep d_adir | wc -l)
|
||||||
[ "${nb}" != "2" ] && echo 'bad config1' && exit 1
|
[ "${nb}" != "2" ] && echo 'bad config1' && exit 1
|
||||||
nb=`cat ${cfg} | grep f_file3 | wc -l`
|
nb=$(cat "${cfg}" | grep f_file3 | wc -l)
|
||||||
[ "${nb}" != "2" ] && echo 'bad config2' && exit 1
|
[ "${nb}" != "2" ] && echo 'bad config2' && exit 1
|
||||||
|
|
||||||
cntpre=`find ${tmps}/dotfiles -type f | wc -l`
|
cntpre=$(find "${tmps}"/dotfiles -type f | wc -l)
|
||||||
|
|
||||||
export DOTDROP_FORCE_NODEBUG=
|
export DOTDROP_FORCE_NODEBUG=
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
cd ${ddpath} | ${bin} compare
|
cd "${ddpath}" | ${bin} compare
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f
|
cd "${ddpath}" | ${bin} install -f
|
||||||
|
|
||||||
# reimport
|
# reimport
|
||||||
cd ${ddpath} | ${bin} import -f ${tmpd}/adir
|
cd "${ddpath}" | ${bin} import -f "${tmpd}"/adir
|
||||||
cd ${ddpath} | ${bin} import -f ${tmpd}/file3
|
cd "${ddpath}" | ${bin} import -f "${tmpd}"/file3
|
||||||
|
|
||||||
cntpost=`find ${tmps}/dotfiles -type f | wc -l`
|
cntpost=$(find "${tmps}"/dotfiles -type f | wc -l)
|
||||||
|
|
||||||
[ "${cntpost}" != "${cntpre}" ] && echo "import failed" && exit 1
|
[ "${cntpost}" != "${cntpre}" ] && echo "import failed" && exit 1
|
||||||
|
|
||||||
|
|||||||
43
tests-ng/ext-actions.sh
vendored
43
tests-ng/ext-actions.sh
vendored
@@ -28,38 +28,41 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# the action temp
|
# the action temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
# 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}"
|
||||||
clear_on_exit "${tmpa}"
|
clear_on_exit "${tmpa}"
|
||||||
|
|
||||||
act="${tmps}/actions.yaml"
|
act="${tmps}/actions.yaml"
|
||||||
cat > ${act} << _EOF
|
cat > "${act}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
pre:
|
pre:
|
||||||
preaction: echo 'pre' > ${tmpa}/pre
|
preaction: echo 'pre' > ${tmpa}/pre
|
||||||
@@ -72,7 +75,7 @@ _EOF
|
|||||||
# 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
|
||||||
@@ -98,26 +101,26 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpa}/pre ] && exit 1
|
[ ! -e "${tmpa}"/pre ] && exit 1
|
||||||
grep pre ${tmpa}/pre >/dev/null
|
grep pre "${tmpa}"/pre >/dev/null
|
||||||
echo "pre is ok"
|
echo "pre is ok"
|
||||||
|
|
||||||
[ ! -e ${tmpa}/post ] && exit 1
|
[ ! -e "${tmpa}"/post ] && exit 1
|
||||||
grep post ${tmpa}/post >/dev/null
|
grep post "${tmpa}"/post >/dev/null
|
||||||
echo "post is ok"
|
echo "post is ok"
|
||||||
|
|
||||||
[ ! -e ${tmpa}/naked ] && exit 1
|
[ ! -e "${tmpa}"/naked ] && exit 1
|
||||||
grep naked ${tmpa}/naked >/dev/null
|
grep naked "${tmpa}"/naked >/dev/null
|
||||||
echo "naked is ok"
|
echo "naked is ok"
|
||||||
|
|
||||||
[ ! -e ${tmpa}/write ] && exit 1
|
[ ! -e "${tmpa}"/write ] && exit 1
|
||||||
grep over ${tmpa}/write >/dev/null
|
grep over "${tmpa}"/write >/dev/null
|
||||||
echo "write is ok"
|
echo "write is ok"
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
101
tests-ng/extvariables.sh
vendored
101
tests-ng/extvariables.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -59,13 +62,13 @@ clear_on_exit "${tmpd}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
extvars="${tmps}/variables.yaml"
|
extvars="${tmps}/variables.yaml"
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
dotpath: dotfiles
|
dotpath: dotfiles
|
||||||
import_variables:
|
import_variables:
|
||||||
- $(basename ${extvars})
|
- $(basename "${extvars}")
|
||||||
variables:
|
variables:
|
||||||
var1: "var1"
|
var1: "var1"
|
||||||
var2: "{{@@ var1 @@}} var2"
|
var2: "{{@@ var1 @@}} var2"
|
||||||
@@ -97,7 +100,7 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the external variables file
|
# create the external variables file
|
||||||
cat > ${extvars} << _EOF
|
cat > "${extvars}" << _EOF
|
||||||
variables:
|
variables:
|
||||||
varx: "exttest"
|
varx: "exttest"
|
||||||
dynvariables:
|
dynvariables:
|
||||||
@@ -106,47 +109,47 @@ dynvariables:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "var3: {{@@ var3 @@}}" > ${tmps}/dotfiles/abc
|
echo "var3: {{@@ var3 @@}}" > "${tmps}"/dotfiles/abc
|
||||||
echo "dvar3: {{@@ dvar3 @@}}" >> ${tmps}/dotfiles/abc
|
echo "dvar3: {{@@ dvar3 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "var4: {{@@ var4 @@}}" >> ${tmps}/dotfiles/abc
|
echo "var4: {{@@ var4 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "dvar4: {{@@ dvar4 @@}}" >> ${tmps}/dotfiles/abc
|
echo "dvar4: {{@@ dvar4 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "varx: {{@@ varx @@}}" >> ${tmps}/dotfiles/abc
|
echo "varx: {{@@ varx @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "evar1: {{@@ evar1 @@}}" >> ${tmps}/dotfiles/abc
|
echo "evar1: {{@@ evar1 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "provar: {{@@ provar @@}}" >> ${tmps}/dotfiles/abc
|
echo "provar: {{@@ provar @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "theprofile: {{@@ theprofile @@}}" >> ${tmps}/dotfiles/abc
|
echo "theprofile: {{@@ theprofile @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
echo "theprofile: {{@@ theprofile @@}}" > ${tmps}/dotfiles/def
|
echo "theprofile: {{@@ theprofile @@}}" > "${tmps}"/dotfiles/def
|
||||||
|
|
||||||
#cat ${tmps}/dotfiles/abc
|
#cat ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
echo "check1"
|
echo "check1"
|
||||||
cat ${tmpd}/abc
|
cat "${tmpd}"/abc
|
||||||
grep '^var3: var1 var2 var3' ${tmpd}/abc >/dev/null
|
grep '^var3: var1 var2 var3' "${tmpd}"/abc >/dev/null
|
||||||
grep '^dvar3: dvar1 dvar2 dvar3' ${tmpd}/abc >/dev/null
|
grep '^dvar3: dvar1 dvar2 dvar3' "${tmpd}"/abc >/dev/null
|
||||||
grep '^var4: echo var1 var2 var3' ${tmpd}/abc >/dev/null
|
grep '^var4: echo var1 var2 var3' "${tmpd}"/abc >/dev/null
|
||||||
grep '^dvar4: var1 var2 var3' ${tmpd}/abc >/dev/null
|
grep '^dvar4: var1 var2 var3' "${tmpd}"/abc >/dev/null
|
||||||
grep '^varx: profvarx' ${tmpd}/abc >/dev/null
|
grep '^varx: profvarx' "${tmpd}"/abc >/dev/null
|
||||||
grep '^evar1: extevar1' ${tmpd}/abc >/dev/null
|
grep '^evar1: extevar1' "${tmpd}"/abc >/dev/null
|
||||||
grep '^provar: provar' ${tmpd}/abc >/dev/null
|
grep '^provar: provar' "${tmpd}"/abc >/dev/null
|
||||||
grep '^theprofile: p1' ${tmpd}/abc >/dev/null
|
grep '^theprofile: p1' "${tmpd}"/abc >/dev/null
|
||||||
|
|
||||||
# check def
|
# check def
|
||||||
[ ! -e ${tmpd}/p1 ] && echo "def not created" && exit 1
|
[ ! -e "${tmpd}"/p1 ] && echo "def not created" && exit 1
|
||||||
grep '^theprofile: p1' ${tmpd}/p1 >/dev/null
|
grep '^theprofile: p1' "${tmpd}"/p1 >/dev/null
|
||||||
|
|
||||||
rm -f ${tmpd}/abc
|
rm -f "${tmpd}"/abc
|
||||||
|
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
dotpath: dotfiles
|
dotpath: dotfiles
|
||||||
import_variables:
|
import_variables:
|
||||||
- $(basename ${extvars})
|
- $(basename "${extvars}")
|
||||||
dotfiles:
|
dotfiles:
|
||||||
f_abc:
|
f_abc:
|
||||||
dst: ${tmpd}/abc
|
dst: ${tmpd}/abc
|
||||||
@@ -162,7 +165,7 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the external variables file
|
# create the external variables file
|
||||||
cat > ${extvars} << _EOF
|
cat > "${extvars}" << _EOF
|
||||||
variables:
|
variables:
|
||||||
var1: "extvar1"
|
var1: "extvar1"
|
||||||
varx: "exttest"
|
varx: "exttest"
|
||||||
@@ -177,26 +180,26 @@ dynvariables:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "var3: {{@@ var3 @@}}" > ${tmps}/dotfiles/abc
|
echo "var3: {{@@ var3 @@}}" > "${tmps}"/dotfiles/abc
|
||||||
echo "dvar3: {{@@ dvar3 @@}}" >> ${tmps}/dotfiles/abc
|
echo "dvar3: {{@@ dvar3 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "var4: {{@@ var4 @@}}" >> ${tmps}/dotfiles/abc
|
echo "var4: {{@@ var4 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "dvar4: {{@@ dvar4 @@}}" >> ${tmps}/dotfiles/abc
|
echo "dvar4: {{@@ dvar4 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "varx: {{@@ varx @@}}" >> ${tmps}/dotfiles/abc
|
echo "varx: {{@@ varx @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "vary: {{@@ vary @@}}" >> ${tmps}/dotfiles/abc
|
echo "vary: {{@@ vary @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
#cat ${tmps}/dotfiles/abc
|
#cat ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
echo "test2"
|
echo "test2"
|
||||||
cat ${tmpd}/abc
|
cat "${tmpd}"/abc
|
||||||
grep '^var3: extvar1 var2 var3' ${tmpd}/abc >/dev/null
|
grep '^var3: extvar1 var2 var3' "${tmpd}"/abc >/dev/null
|
||||||
grep '^dvar3: extdvar1 dvar2 dvar3' ${tmpd}/abc >/dev/null
|
grep '^dvar3: extdvar1 dvar2 dvar3' "${tmpd}"/abc >/dev/null
|
||||||
grep '^var4: echo extvar1 var2 var3' ${tmpd}/abc >/dev/null
|
grep '^var4: echo extvar1 var2 var3' "${tmpd}"/abc >/dev/null
|
||||||
grep '^dvar4: extvar1 var2 var3' ${tmpd}/abc >/dev/null
|
grep '^dvar4: extvar1 var2 var3' "${tmpd}"/abc >/dev/null
|
||||||
grep '^varx: profvarx' ${tmpd}/abc >/dev/null
|
grep '^varx: profvarx' "${tmpd}"/abc >/dev/null
|
||||||
grep '^vary: profvary' ${tmpd}/abc >/dev/null
|
grep '^vary: profvary' "${tmpd}"/abc >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
59
tests-ng/filter_file.sh
vendored
59
tests-ng/filter_file.sh
vendored
@@ -28,33 +28,36 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
filter_file=`mktemp`
|
filter_file=$(mktemp)
|
||||||
filter_file2=`mktemp`
|
filter_file2=$(mktemp)
|
||||||
filter_file3=`mktemp`
|
filter_file3=$(mktemp)
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
@@ -66,7 +69,7 @@ clear_on_exit "${filter_file3}"
|
|||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
cfgext="${tmps}/ext.yaml"
|
cfgext="${tmps}/ext.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -89,7 +92,7 @@ variables:
|
|||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
cat > ${cfgext} << _EOF
|
cat > "${cfgext}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -100,46 +103,46 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cat << _EOF > ${filter_file}
|
cat << _EOF > "${filter_file}"
|
||||||
def filter1(arg1):
|
def filter1(arg1):
|
||||||
return "filtered"
|
return "filtered"
|
||||||
def filter2(arg1, arg2=''):
|
def filter2(arg1, arg2=''):
|
||||||
return arg2
|
return arg2
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cat << _EOF > ${filter_file2}
|
cat << _EOF > "${filter_file2}"
|
||||||
def filter3(integer):
|
def filter3(integer):
|
||||||
return str(int(integer) - 10)
|
return str(int(integer) - 10)
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cat << _EOF > ${filter_file3}
|
cat << _EOF > "${filter_file3}"
|
||||||
def filter_ext(arg1):
|
def filter_ext(arg1):
|
||||||
return "external"
|
return "external"
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "this is the test dotfile" > ${tmps}/dotfiles/abc
|
echo "this is the test dotfile" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# test imported function
|
# test imported function
|
||||||
echo "{{@@ "abc" | filter1 @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ "abc" | filter1 @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ "arg1" | filter2('arg2') @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ "arg1" | filter2('arg2') @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ "13" | filter3() @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ "13" | filter3() @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ "something" | filter_ext() @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ "something" | filter_ext() @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ filt @@}}variable" >> ${tmps}/dotfiles/abc
|
echo "{{@@ filt @@}}variable" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
|
|
||||||
grep '^filtered$' ${tmpd}/abc >/dev/null
|
grep '^filtered$' "${tmpd}"/abc >/dev/null
|
||||||
grep '^arg2$' ${tmpd}/abc >/dev/null
|
grep '^arg2$' "${tmpd}"/abc >/dev/null
|
||||||
grep '^3$' ${tmpd}/abc >/dev/null
|
grep '^3$' "${tmpd}"/abc >/dev/null
|
||||||
grep '^external$' ${tmpd}/abc >/dev/null
|
grep '^external$' "${tmpd}"/abc >/dev/null
|
||||||
set +e
|
set +e
|
||||||
grep '^something$' ${tmpd}/abc >/dev/null && exit 1
|
grep '^something$' "${tmpd}"/abc >/dev/null && exit 1
|
||||||
set -e
|
set -e
|
||||||
grep '^filteredvariable$' ${tmpd}/abc > /dev/null
|
grep '^filteredvariable$' "${tmpd}"/abc > /dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
59
tests-ng/force-actions.sh
vendored
59
tests-ng/force-actions.sh
vendored
@@ -28,31 +28,34 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# the action temp
|
# the action temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
# 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}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpa}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
pre:
|
pre:
|
||||||
preaction: echo 'pre' > ${tmpa}/pre
|
preaction: echo 'pre' > ${tmpa}/pre
|
||||||
@@ -92,34 +95,34 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > "${tmps}"/dotfiles/abc
|
||||||
# deploy the dotfile
|
# deploy the dotfile
|
||||||
cp ${tmps}/dotfiles/abc ${tmpd}/abc
|
cp "${tmps}"/dotfiles/abc "${tmpd}"/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ -e ${tmpa}/pre ] && exit 1
|
[ -e "${tmpa}"/pre ] && exit 1
|
||||||
[ -e ${tmpa}/post ] && exit 1
|
[ -e "${tmpa}"/post ] && exit 1
|
||||||
[ -e ${tmpa}/naked ] && exit 1
|
[ -e "${tmpa}"/naked ] && exit 1
|
||||||
[ -e ${tmpa}/pre2 ] && exit 1
|
[ -e "${tmpa}"/pre2 ] && exit 1
|
||||||
[ -e ${tmpa}/post2 ] && exit 1
|
[ -e "${tmpa}"/post2 ] && exit 1
|
||||||
|
|
||||||
# install and force
|
# install and force
|
||||||
cd ${ddpath} | ${bin} install -f -a -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -a -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpa}/pre ] && exit 1
|
[ ! -e "${tmpa}"/pre ] && exit 1
|
||||||
grep pre ${tmpa}/pre >/dev/null
|
grep pre "${tmpa}"/pre >/dev/null
|
||||||
[ ! -e ${tmpa}/post ] && exit 1
|
[ ! -e "${tmpa}"/post ] && exit 1
|
||||||
grep post ${tmpa}/post >/dev/null
|
grep post "${tmpa}"/post >/dev/null
|
||||||
[ ! -e ${tmpa}/naked ] && exit 1
|
[ ! -e "${tmpa}"/naked ] && exit 1
|
||||||
grep naked ${tmpa}/naked >/dev/null
|
grep naked "${tmpa}"/naked >/dev/null
|
||||||
[ ! -e ${tmpa}/pre2 ] && exit 1
|
[ ! -e "${tmpa}"/pre2 ] && exit 1
|
||||||
grep pre2 ${tmpa}/pre2 >/dev/null
|
grep pre2 "${tmpa}"/pre2 >/dev/null
|
||||||
[ ! -e ${tmpa}/post2 ] && exit 1
|
[ ! -e "${tmpa}"/post2 ] && exit 1
|
||||||
grep post2 ${tmpa}/post2 >/dev/null
|
grep post2 "${tmpa}"/post2 >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
81
tests-ng/func_file.sh
vendored
81
tests-ng/func_file.sh
vendored
@@ -28,33 +28,36 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
func_file=`mktemp`
|
func_file=$(mktemp)
|
||||||
func_file2=`mktemp`
|
func_file2=$(mktemp)
|
||||||
func_file3=`mktemp`
|
func_file3=$(mktemp)
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
@@ -66,7 +69,7 @@ clear_on_exit "${func_file3}"
|
|||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
cfgext="${tmps}/ext.yaml"
|
cfgext="${tmps}/ext.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -89,7 +92,7 @@ variables:
|
|||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
cat > ${cfgext} << _EOF
|
cat > "${cfgext}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -100,62 +103,62 @@ dotfiles:
|
|||||||
profiles:
|
profiles:
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cat << _EOF > ${func_file}
|
cat << _EOF > "${func_file}"
|
||||||
def func1(something):
|
def func1(something):
|
||||||
if something:
|
if something:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cat << _EOF > ${func_file2}
|
cat << _EOF > "${func_file2}"
|
||||||
def func2(inp):
|
def func2(inp):
|
||||||
return not inp
|
return not inp
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cat << _EOF > ${func_file3}
|
cat << _EOF > "${func_file3}"
|
||||||
def func3(inp):
|
def func3(inp):
|
||||||
return 42
|
return 42
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "this is the test dotfile" > ${tmps}/dotfiles/abc
|
echo "this is the test dotfile" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# test imported function
|
# test imported function
|
||||||
echo "{%@@ if func1(True) @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ if func1(True) @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "this should exist" >> ${tmps}/dotfiles/abc
|
echo "this should exist" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{%@@ endif @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ endif @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
echo "{%@@ if not func1(False) @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ if not func1(False) @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "this should exist too" >> ${tmps}/dotfiles/abc
|
echo "this should exist too" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{%@@ endif @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ endif @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
echo "{%@@ if func2(True) @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ if func2(True) @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "nope" >> ${tmps}/dotfiles/abc
|
echo "nope" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{%@@ endif @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ endif @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
echo "{%@@ if func2(False) @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ if func2(False) @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "yes" >> ${tmps}/dotfiles/abc
|
echo "yes" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{%@@ endif @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ endif @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
echo "{%@@ if func3("whatever") == 42 @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ if func3(\"whatever\") == 42 @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "externalok" >> ${tmps}/dotfiles/abc
|
echo "externalok" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{%@@ endif @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ endif @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
echo "{{@@ func @@}}added" >> ${tmps}/dotfiles/abc
|
echo "{{@@ func @@}}added" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
|
|
||||||
grep '^this should exist$' ${tmpd}/abc >/dev/null
|
grep '^this should exist$' "${tmpd}"/abc >/dev/null
|
||||||
grep '^this should exist too$' ${tmpd}/abc >/dev/null
|
grep '^this should exist too$' "${tmpd}"/abc >/dev/null
|
||||||
grep '^yes$' ${tmpd}/abc >/dev/null
|
grep '^yes$' "${tmpd}"/abc >/dev/null
|
||||||
grep '^externalok$' ${tmpd}/abc >/dev/null
|
grep '^externalok$' "${tmpd}"/abc >/dev/null
|
||||||
set +e
|
set +e
|
||||||
grep '^nope$' ${tmpd}/abc >/dev/null && exit 1
|
grep '^nope$' "${tmpd}"/abc >/dev/null && exit 1
|
||||||
set -e
|
set -e
|
||||||
grep '^Falseadded$' ${tmpd}/abc >/dev/null
|
grep '^Falseadded$' "${tmpd}"/abc >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
43
tests-ng/global-compare-ignore.sh
vendored
43
tests-ng/global-compare-ignore.sh
vendored
@@ -28,43 +28,46 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# some files
|
# some files
|
||||||
mkdir -p ${tmpd}/{program,config}
|
mkdir -p "${tmpd}"/{program,config}
|
||||||
touch ${tmpd}/program/a
|
touch "${tmpd}"/program/a
|
||||||
touch ${tmpd}/config/a
|
touch "${tmpd}"/config/a
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -75,36 +78,36 @@ _EOF
|
|||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/program
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/program
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/config
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/config
|
||||||
|
|
||||||
# add files
|
# add files
|
||||||
echo "[+] add files"
|
echo "[+] add files"
|
||||||
touch ${tmpd}/program/b
|
touch "${tmpd}"/program/b
|
||||||
touch ${tmpd}/config/b
|
touch "${tmpd}"/config/b
|
||||||
|
|
||||||
# adding ignore in dotfile
|
# adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/dotpath: dotfiles/a \ \ cmpignore:\n\ \ \ \ - "*/config/b"' ${cfg} > ${cfg2}
|
sed '/dotpath: dotfiles/a \ \ cmpignore:\n\ \ \ \ - "*/config/b"' "${cfg}" > "${cfg2}"
|
||||||
cat ${cfg2}
|
cat "${cfg2}"
|
||||||
|
|
||||||
# expects one diff
|
# expects one diff
|
||||||
echo "[+] comparing with ignore in dotfile - 1 diff"
|
echo "[+] comparing with ignore in dotfile - 1 diff"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# adding ignore in dotfile
|
# adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/dotpath: dotfiles/a \ \ cmpignore:\n\ \ \ \ - "*b"' ${cfg} > ${cfg2}
|
sed '/dotpath: dotfiles/a \ \ cmpignore:\n\ \ \ \ - "*b"' "${cfg}" > "${cfg2}"
|
||||||
cat ${cfg2}
|
cat "${cfg2}"
|
||||||
|
|
||||||
# expects no diff
|
# expects no diff
|
||||||
patt="*b"
|
patt="*b"
|
||||||
echo "[+] comparing with ignore in dotfile - 0 diff"
|
echo "[+] comparing with ignore in dotfile - 0 diff"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|||||||
76
tests-ng/global-compare-negative-ignore.sh
vendored
76
tests-ng/global-compare-negative-ignore.sh
vendored
@@ -9,41 +9,12 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# all this crap to get current path
|
# all this crap to get current path
|
||||||
if [ $(uname) = Darwin ]; then
|
rl="readlink -f"
|
||||||
# Unfortunately, readlink works differently on macOS than it does on GNU/Linux
|
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
||||||
# (the -f option behaves differently) and the realpath command does not exist.
|
rl="realpath"
|
||||||
# Workarounds I find on the Internet suggest just using Homebrew to install coreutils
|
|
||||||
# so you can get the GNU coreutils on your Mac. But, I don't want this script to
|
|
||||||
# assume (a) users have Homebrew installed and (b) if they have Homebrew installed, that
|
|
||||||
# they then installed the GNU coreutils.
|
|
||||||
readlink() {
|
|
||||||
TARGET_FILE=$1
|
|
||||||
|
|
||||||
cd `dirname $TARGET_FILE`
|
if ! hash ${rl}; then
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
echo "\"${rl}\" not found !" && exit 1
|
||||||
|
|
||||||
# Iterate down a (possible) chain of symlinks
|
|
||||||
while [ -L "$TARGET_FILE" ]; do
|
|
||||||
TARGET_FILE=`readlink $TARGET_FILE`
|
|
||||||
cd `dirname $TARGET_FILE`
|
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
|
||||||
done
|
|
||||||
|
|
||||||
# Compute the canonicalized name by finding the physical path
|
|
||||||
# for the directory we're in and appending the target file.
|
|
||||||
PHYS_DIR=`pwd -P`
|
|
||||||
RESULT=$PHYS_DIR/$TARGET_FILE
|
|
||||||
echo $RESULT
|
|
||||||
}
|
|
||||||
rl="readlink"
|
|
||||||
else
|
|
||||||
rl="readlink -f"
|
|
||||||
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
|
||||||
rl="realpath"
|
|
||||||
|
|
||||||
if ! hash ${rl}; then
|
|
||||||
echo "\"${rl}\" not found !" && exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cur=$(dirname "$(${rl} "${0}")")
|
cur=$(dirname "$(${rl} "${0}")")
|
||||||
@@ -51,53 +22,56 @@ cur=$(dirname "$(${rl} "${0}")")
|
|||||||
# dotdrop path can be pass as argument
|
# dotdrop path can be pass as argument
|
||||||
ddpath="${cur}/../"
|
ddpath="${cur}/../"
|
||||||
[ -n "${1}" ] && ddpath="${1}"
|
[ -n "${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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# some files
|
# some files
|
||||||
mkdir -p ${tmpd}/{program,config}
|
mkdir -p "${tmpd}"/{program,config}
|
||||||
touch ${tmpd}/program/a
|
touch "${tmpd}"/program/a
|
||||||
touch ${tmpd}/config/a
|
touch "${tmpd}"/config/a
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/program
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/program
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/config
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/config
|
||||||
|
|
||||||
# add files
|
# add files
|
||||||
echo "[+] add files"
|
echo "[+] add files"
|
||||||
touch ${tmpd}/program/b
|
touch "${tmpd}"/program/b
|
||||||
touch ${tmpd}/config/b
|
touch "${tmpd}"/config/b
|
||||||
|
|
||||||
# adding ignore in dotfile
|
# adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
@@ -105,13 +79,13 @@ sed '/dotpath: dotfiles/a\
|
|||||||
\ \ cmpignore:\
|
\ \ cmpignore:\
|
||||||
\ \ \ \ - "*/config/*"\
|
\ \ \ \ - "*/config/*"\
|
||||||
\ \ \ \ - "!*/config/a"\
|
\ \ \ \ - "!*/config/a"\
|
||||||
' ${cfg} > ${cfg2}
|
' "${cfg}" > "${cfg2}"
|
||||||
cat ${cfg2}
|
cat "${cfg2}"
|
||||||
|
|
||||||
# expects one diff
|
# expects one diff
|
||||||
echo "[+] comparing with ignore in dotfile - 1 diff"
|
echo "[+] comparing with ignore in dotfile - 1 diff"
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose
|
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose
|
||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|||||||
43
tests-ng/global-update-ignore.sh
vendored
43
tests-ng/global-update-ignore.sh
vendored
@@ -28,42 +28,45 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
dt="${tmps}/dotfiles"
|
dt="${tmps}/dotfiles"
|
||||||
mkdir -p ${dt}
|
mkdir -p "${dt}"
|
||||||
mkdir -p ${dt}/a/{b,c}
|
mkdir -p "${dt}"/a/{b,c}
|
||||||
echo 'a' > ${dt}/a/b/abfile
|
echo 'a' > "${dt}"/a/b/abfile
|
||||||
echo 'a' > ${dt}/a/c/acfile
|
echo 'a' > "${dt}"/a/c/acfile
|
||||||
|
|
||||||
# fs dotfiles
|
# fs dotfiles
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
cp -r ${dt}/a ${tmpd}/
|
cp -r "${dt}"/a "${tmpd}"/
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# 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: false
|
backup: false
|
||||||
create: true
|
create: true
|
||||||
@@ -87,25 +90,25 @@ _EOF
|
|||||||
|
|
||||||
# edit/add files
|
# edit/add files
|
||||||
echo "[+] edit/add files"
|
echo "[+] edit/add files"
|
||||||
touch ${tmpd}/a/newfile
|
touch "${tmpd}"/a/newfile
|
||||||
echo 'b' > ${tmpd}/a/c/acfile
|
echo 'b' > "${tmpd}"/a/c/acfile
|
||||||
mkdir -p ${tmpd}/a/newdir/b
|
mkdir -p "${tmpd}"/a/newdir/b
|
||||||
touch ${tmpd}/a/newdir/b/c
|
touch "${tmpd}"/a/newdir/b/c
|
||||||
|
|
||||||
#tree ${tmpd}/a
|
#tree ${tmpd}/a
|
||||||
|
|
||||||
# update
|
# update
|
||||||
echo "[+] update"
|
echo "[+] update"
|
||||||
cd ${ddpath} | ${bin} update -f -c ${cfg} --verbose --profile=p1 --key f_abc
|
cd "${ddpath}" | ${bin} update -f -c "${cfg}" --verbose --profile=p1 --key f_abc
|
||||||
|
|
||||||
#tree ${dt}
|
#tree ${dt}
|
||||||
|
|
||||||
# check files haven't been updated
|
# check files haven't been updated
|
||||||
[ ! -e ${dt}/a/c/acfile ] && echo "acfile not found" && exit 1
|
[ ! -e "${dt}"/a/c/acfile ] && echo "acfile not found" && exit 1
|
||||||
set +e
|
set +e
|
||||||
grep 'b' ${dt}/a/c/acfile || (echo "acfile not updated" && exit 1)
|
grep 'b' "${dt}"/a/c/acfile || (echo "acfile not updated" && exit 1)
|
||||||
set -e
|
set -e
|
||||||
[ -e ${dt}/a/newfile ] && echo "newfile found" && exit 1
|
[ -e "${dt}"/a/newfile ] && echo "newfile found" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
94
tests-ng/global-update-negative-ignore.sh
vendored
94
tests-ng/global-update-negative-ignore.sh
vendored
@@ -9,41 +9,12 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# all this crap to get current path
|
# all this crap to get current path
|
||||||
if [ $(uname) = Darwin ]; then
|
rl="readlink -f"
|
||||||
# Unfortunately, readlink works differently on macOS than it does on GNU/Linux
|
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
||||||
# (the -f option behaves differently) and the realpath command does not exist.
|
rl="realpath"
|
||||||
# Workarounds I find on the Internet suggest just using Homebrew to install coreutils
|
|
||||||
# so you can get the GNU coreutils on your Mac. But, I don't want this script to
|
|
||||||
# assume (a) users have Homebrew installed and (b) if they have Homebrew installed, that
|
|
||||||
# they then installed the GNU coreutils.
|
|
||||||
readlink() {
|
|
||||||
TARGET_FILE=$1
|
|
||||||
|
|
||||||
cd `dirname $TARGET_FILE`
|
if ! hash ${rl}; then
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
echo "\"${rl}\" not found !" && exit 1
|
||||||
|
|
||||||
# Iterate down a (possible) chain of symlinks
|
|
||||||
while [ -L "$TARGET_FILE" ]; do
|
|
||||||
TARGET_FILE=`readlink $TARGET_FILE`
|
|
||||||
cd `dirname $TARGET_FILE`
|
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
|
||||||
done
|
|
||||||
|
|
||||||
# Compute the canonicalized name by finding the physical path
|
|
||||||
# for the directory we're in and appending the target file.
|
|
||||||
PHYS_DIR=`pwd -P`
|
|
||||||
RESULT=$PHYS_DIR/$TARGET_FILE
|
|
||||||
echo $RESULT
|
|
||||||
}
|
|
||||||
rl="readlink"
|
|
||||||
else
|
|
||||||
rl="readlink -f"
|
|
||||||
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
|
||||||
rl="realpath"
|
|
||||||
|
|
||||||
if ! hash ${rl}; then
|
|
||||||
echo "\"${rl}\" not found !" && exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cur=$(dirname "$(${rl} "${0}")")
|
cur=$(dirname "$(${rl} "${0}")")
|
||||||
@@ -51,44 +22,47 @@ cur=$(dirname "$(${rl} "${0}")")
|
|||||||
# dotdrop path can be pass as argument
|
# dotdrop path can be pass as argument
|
||||||
ddpath="${cur}/../"
|
ddpath="${cur}/../"
|
||||||
[ -n "${1}" ] && ddpath="${1}"
|
[ -n "${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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
mkdir -p ${basedir}/dotfiles/a/{b,c}
|
mkdir -p "${basedir}"/dotfiles/a/{b,c}
|
||||||
echo 'a' > ${basedir}/dotfiles/a/b/abfile1
|
echo 'a' > "${basedir}"/dotfiles/a/b/abfile1
|
||||||
echo 'a' > ${basedir}/dotfiles/a/b/abfile2
|
echo 'a' > "${basedir}"/dotfiles/a/b/abfile2
|
||||||
echo 'a' > ${basedir}/dotfiles/a/b/abfile3
|
echo 'a' > "${basedir}"/dotfiles/a/b/abfile3
|
||||||
echo 'a' > ${basedir}/dotfiles/a/c/acfile
|
echo 'a' > "${basedir}"/dotfiles/a/c/acfile
|
||||||
|
|
||||||
# the dotfile to be updated
|
# the dotfile to be updated
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
cp -r ${basedir}/dotfiles/a ${tmpd}/
|
cp -r "${basedir}"/dotfiles/a "${tmpd}"/
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: false
|
backup: false
|
||||||
create: true
|
create: true
|
||||||
@@ -110,26 +84,26 @@ _EOF
|
|||||||
|
|
||||||
# edit/add files
|
# edit/add files
|
||||||
echo "[+] edit/add files"
|
echo "[+] edit/add files"
|
||||||
mkdir -p ${tmpd}/a/newdir/b
|
mkdir -p "${tmpd}"/a/newdir/b
|
||||||
echo 'b' > ${tmpd}/a/b/abfile1
|
echo 'b' > "${tmpd}"/a/b/abfile1
|
||||||
echo 'b' > ${tmpd}/a/b/abfile2
|
echo 'b' > "${tmpd}"/a/b/abfile2
|
||||||
echo 'b' > ${tmpd}/a/b/abfile3
|
echo 'b' > "${tmpd}"/a/b/abfile3
|
||||||
echo 'b' > ${tmpd}/a/b/abfile4
|
echo 'b' > "${tmpd}"/a/b/abfile4
|
||||||
touch ${tmpd}/a/newdir/b/{c,d}
|
touch "${tmpd}"/a/newdir/b/{c,d}
|
||||||
|
|
||||||
# update
|
# update
|
||||||
echo "[+] update"
|
echo "[+] update"
|
||||||
cd ${ddpath} | ${bin} update -f -c ${cfg} --verbose --profile=p1 --key f_abc
|
cd "${ddpath}" | ${bin} update -f -c "${cfg}" --verbose --profile=p1 --key f_abc
|
||||||
|
|
||||||
# check files haven't been updated
|
# check files haven't been updated
|
||||||
set +e
|
set +e
|
||||||
grep 'a' ${basedir}/dotfiles/a/b/abfile1 >/dev/null 2>&1 || (echo "abfile1 should not have been updated" && exit 1)
|
grep 'a' "${basedir}"/dotfiles/a/b/abfile1 >/dev/null 2>&1 || (echo "abfile1 should not have been updated" && exit 1)
|
||||||
grep 'a' ${basedir}/dotfiles/a/b/abfile2 >/dev/null 2>&1 || (echo "abfile2 should not have been updated" && exit 1)
|
grep 'a' "${basedir}"/dotfiles/a/b/abfile2 >/dev/null 2>&1 || (echo "abfile2 should not have been updated" && exit 1)
|
||||||
grep 'b' ${basedir}/dotfiles/a/b/abfile3 >/dev/null 2>&1 || (echo "abfile3 was not updated" && exit 1)
|
grep 'b' "${basedir}"/dotfiles/a/b/abfile3 >/dev/null 2>&1 || (echo "abfile3 was not updated" && exit 1)
|
||||||
set -e
|
set -e
|
||||||
[ -e ${basedir}/dotfiles/a/b/abfile4 ] && echo "abfile4 should not have been updated" && exit 1
|
[ -e "${basedir}"/dotfiles/a/b/abfile4 ] && echo "abfile4 should not have been updated" && exit 1
|
||||||
[ -e ${basedir}/dotfiles/a/newdir/b/c ] && echo "newdir/b/c should not have been updated" && exit 1
|
[ -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
|
[ ! -e "${basedir}"/dotfiles/a/newdir/b/d ] && echo "newdir/b/d should have been updated" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
43
tests-ng/globs.sh
vendored
43
tests-ng/globs.sh
vendored
@@ -31,31 +31,34 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
# temporary
|
# temporary
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
@@ -66,18 +69,18 @@ clear_on_exit "${tmpa}"
|
|||||||
###########
|
###########
|
||||||
# create the action files
|
# create the action files
|
||||||
actionsd="${tmps}/actions"
|
actionsd="${tmps}/actions"
|
||||||
mkdir -p ${actionsd}
|
mkdir -p "${actionsd}"
|
||||||
cat > ${actionsd}/action1.yaml << _EOF
|
cat > "${actionsd}"/action1.yaml << _EOF
|
||||||
actions:
|
actions:
|
||||||
fromaction1: echo "fromaction1" > ${tmpa}/fromaction1
|
fromaction1: echo "fromaction1" > ${tmpa}/fromaction1
|
||||||
_EOF
|
_EOF
|
||||||
cat > ${actionsd}/action2.yaml << _EOF
|
cat > "${actionsd}"/action2.yaml << _EOF
|
||||||
actions:
|
actions:
|
||||||
fromaction2: echo "fromaction2" > ${tmpa}/fromaction2
|
fromaction2: echo "fromaction2" > ${tmpa}/fromaction2
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -98,18 +101,18 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
mkdir -p ${tmps}/dotfiles/
|
mkdir -p "${tmps}"/dotfiles/
|
||||||
echo "abc" > ${tmps}/dotfiles/abc
|
echo "abc" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 -V
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p1 -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpd}/abc ] && echo "dotfile not installed" && exit 1
|
[ ! -e "${tmpd}"/abc ] && echo "dotfile not installed" && exit 1
|
||||||
[ ! -e ${tmpa}/fromaction1 ] && echo "action1 not executed" && exit 1
|
[ ! -e "${tmpa}"/fromaction1 ] && echo "action1 not executed" && exit 1
|
||||||
grep fromaction1 ${tmpa}/fromaction1
|
grep fromaction1 "${tmpa}"/fromaction1
|
||||||
[ ! -e ${tmpa}/fromaction2 ] && echo "action2 not executed" && exit 1
|
[ ! -e "${tmpa}"/fromaction2 ] && echo "action2 not executed" && exit 1
|
||||||
grep fromaction2 ${tmpa}/fromaction2
|
grep fromaction2 "${tmpa}"/fromaction2
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
35
tests-ng/header.sh
vendored
35
tests-ng/header.sh
vendored
@@ -28,30 +28,33 @@ 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"
|
||||||
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 "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) <==$(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
|
||||||
#echo "dotfile source: ${tmps}"
|
#echo "dotfile source: ${tmps}"
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -60,7 +63,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -77,17 +80,17 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ header() @@}}" > ${tmps}/dotfiles/abc
|
echo "{{@@ header() @@}}" > "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ header('# ') @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ header('# ') @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ header('// ') @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ header('// ') @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "test" >> ${tmps}/dotfiles/abc
|
echo "test" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1
|
||||||
|
|
||||||
grep '^This dotfile is managed using dotdrop' ${tmpd}/abc >/dev/null
|
grep '^This dotfile is managed using dotdrop' "${tmpd}"/abc >/dev/null
|
||||||
grep '^# This dotfile is managed using dotdrop' ${tmpd}/abc >/dev/null
|
grep '^# This dotfile is managed using dotdrop' "${tmpd}"/abc >/dev/null
|
||||||
grep '^// This dotfile is managed using dotdrop' ${tmpd}/abc >/dev/null
|
grep '^// This dotfile is managed using dotdrop' "${tmpd}"/abc >/dev/null
|
||||||
|
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
|
|
||||||
|
|||||||
41
tests-ng/ignore-empty.sh
vendored
41
tests-ng/ignore-empty.sh
vendored
@@ -28,30 +28,33 @@ 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"
|
||||||
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 "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) <==$(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
|
||||||
#echo "dotfile source: ${tmps}"
|
#echo "dotfile source: ${tmps}"
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpd}"
|
|||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
# globally
|
# globally
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -79,19 +82,19 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmps}/dotfiles/d1
|
mkdir -p "${tmps}"/dotfiles/d1
|
||||||
echo "{#@@ should be stripped @@#}" > ${tmps}/dotfiles/d1/empty
|
echo "{#@@ should be stripped @@#}" > "${tmps}"/dotfiles/d1/empty
|
||||||
echo "not empty" > ${tmps}/dotfiles/d1/notempty
|
echo "not empty" > "${tmps}"/dotfiles/d1/notempty
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# test existence
|
# test existence
|
||||||
[ -e ${tmpd}/d1/empty ] && echo 'empty should not exist' && exit 1
|
[ -e "${tmpd}"/d1/empty ] && echo 'empty should not exist' && exit 1
|
||||||
[ ! -e ${tmpd}/d1/notempty ] && echo 'not empty should exist' && exit 1
|
[ ! -e "${tmpd}"/d1/notempty ] && echo 'not empty should exist' && exit 1
|
||||||
|
|
||||||
# through the dotfile
|
# through the dotfile
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -110,14 +113,14 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# clean destination
|
# clean destination
|
||||||
rm -rf ${tmpd}/*
|
rm -rf "${tmpd:?}"/*
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# test existence
|
# test existence
|
||||||
[ -e ${tmpd}/d1/empty ] && echo 'empty should not exist' && exit 1
|
[ -e "${tmpd}"/d1/empty ] && echo 'empty should not exist' && exit 1
|
||||||
[ ! -e ${tmpd}/d1/notempty ] && echo 'not empty should exist' && exit 1
|
[ ! -e "${tmpd}"/d1/notempty ] && echo 'not empty should exist' && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
83
tests-ng/import-as.sh
vendored
83
tests-ng/import-as.sh
vendored
@@ -27,46 +27,49 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
clear_on_exit "~/.dotdrop.test"
|
clear_on_exit "${HOME}/.dotdrop.test"
|
||||||
clear_on_exit "~/.dotdrop-dotfiles-test"
|
clear_on_exit "${HOME}/.dotdrop-dotfiles-test"
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmpd}/adir
|
mkdir -p "${tmpd}"/adir
|
||||||
echo "adir/file1" > ${tmpd}/adir/file1
|
echo "adir/file1" > "${tmpd}"/adir/file1
|
||||||
echo "adir/fil2" > ${tmpd}/adir/file2
|
echo "adir/fil2" > "${tmpd}"/adir/file2
|
||||||
echo "file3" > ${tmpd}/file3
|
echo "file3" > "${tmpd}"/file3
|
||||||
|
|
||||||
# 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
|
||||||
@@ -77,47 +80,47 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# import
|
# import
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/adir
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/file3
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/file3
|
||||||
|
|
||||||
echo "import --as dotfiles"
|
echo "import --as dotfiles"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p2 -V ${tmpd}/adir --as ~/config/adir
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p2 -V "${tmpd}"/adir --as ~/config/adir
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p2 -V ${tmpd}/file3 --as ~/config2/file3
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p2 -V "${tmpd}"/file3 --as ~/config2/file3
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p2 -V ${tmpd}/adir --as ~/config/should_not && echo "dual dst imported" && exit 1
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p2 -V "${tmpd}"/adir --as ~/config/should_not && echo "dual dst imported" && exit 1
|
||||||
set -e
|
set -e
|
||||||
cat ${cfg} | grep should_not && echo "dual dst imported" && exit 1
|
cat "${cfg}" | grep should_not && echo "dual dst imported" && exit 1
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
echo "ensure exists and is not link"
|
echo "ensure exists and is not link"
|
||||||
[ ! -d ${tmps}/dotfiles/${tmpd}/adir ] && echo "not a directory" && exit 1
|
[ ! -d "${tmps}"/dotfiles/"${tmpd}"/adir ] && echo "not a directory" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/adir/file1 ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/adir/file1 ] && echo "not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/adir/file2 ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/adir/file2 ] && echo "not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/file3 ] && echo "not a file" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/file3 ] && echo "not a file" && exit 1
|
||||||
|
|
||||||
echo "ensure --as are correctly imported"
|
echo "ensure --as are correctly imported"
|
||||||
[ ! -d ${tmps}/dotfiles/config/adir ] && echo "not a directory" && exit 1
|
[ ! -d "${tmps}"/dotfiles/config/adir ] && echo "not a directory" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/config/adir/file1 ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/config/adir/file1 ] && echo "not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/config/adir/file2 ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/config/adir/file2 ] && echo "not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/config2/file3 ] && echo "not a file" && exit 1
|
[ ! -e "${tmps}"/dotfiles/config2/file3 ] && echo "not a file" && exit 1
|
||||||
|
|
||||||
cat ${cfg} | grep ${tmpd}/adir >/dev/null 2>&1
|
cat "${cfg}" | grep "${tmpd}"/adir >/dev/null 2>&1
|
||||||
cat ${cfg} | grep ${tmpd}/file3 >/dev/null 2>&1
|
cat "${cfg}" | grep "${tmpd}"/file3 >/dev/null 2>&1
|
||||||
|
|
||||||
cat ${cfg} | grep config/adir >/dev/null 2>&1
|
cat "${cfg}" | grep config/adir >/dev/null 2>&1
|
||||||
cat ${cfg} | grep config2/file3 >/dev/null 2>&1
|
cat "${cfg}" | grep config2/file3 >/dev/null 2>&1
|
||||||
|
|
||||||
nb=`cat ${cfg} | grep d_adir | wc -l`
|
nb=$(cat "${cfg}" | grep d_adir | wc -l)
|
||||||
[ "${nb}" != "2" ] && echo 'bad config1' && exit 1
|
[ "${nb}" != "2" ] && echo 'bad config1' && exit 1
|
||||||
nb=`cat ${cfg} | grep f_file3 | wc -l`
|
nb=$(cat "${cfg}" | grep f_file3 | wc -l)
|
||||||
[ "${nb}" != "2" ] && echo 'bad config2' && exit 1
|
[ "${nb}" != "2" ] && echo 'bad config2' && exit 1
|
||||||
|
|
||||||
cat ${cfg} | grep "src: config/adir" || exit 1
|
cat "${cfg}" | grep "src: config/adir" || exit 1
|
||||||
cat ${cfg} | grep "src: config2/file3" || exit 1
|
cat "${cfg}" | grep "src: config2/file3" || exit 1
|
||||||
|
|
||||||
# test import from sub in home
|
# test import from sub in home
|
||||||
mkdir -p ~/.dotdrop-dotfiles-test/{dotfiles,config}
|
mkdir -p ~/.dotdrop-dotfiles-test/{dotfiles,config}
|
||||||
@@ -137,11 +140,11 @@ dotfiles:
|
|||||||
profiles:
|
profiles:
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cd ${ddpath} | ${bin} import -f -b -c ${cfg} -p test -V ~/.dotdrop.test --as=~/.whatever
|
cd "${ddpath}" | ${bin} import -f -b -c ${cfg} -p test -V ~/.dotdrop.test --as=~/.whatever
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
[ ! -e ~/.dotdrop-dotfiles-test/dotfiles/whatever ] && echo 'tild imported' && exit 1
|
[ ! -e ~/.dotdrop-dotfiles-test/dotfiles/whatever ] && echo 'tild imported' && exit 1
|
||||||
cat ${cfg} | grep '~/.whatever' && echo 'import with tild failed' && exit 1
|
cat ${cfg} | grep "${HOME}/.whatever" && echo 'import with tild failed' && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
117
tests-ng/import-configs.sh
vendored
117
tests-ng/import-configs.sh
vendored
@@ -27,30 +27,33 @@ 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"
|
||||||
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 "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) <==$(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
|
||||||
mkdir -p ${tmps}/dotfiles-other
|
mkdir -p "${tmps}"/dotfiles-other
|
||||||
# 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}"
|
||||||
@@ -59,7 +62,7 @@ clear_on_exit "${tmpd}"
|
|||||||
cfg1="${tmps}/config1.yaml"
|
cfg1="${tmps}/config1.yaml"
|
||||||
cfg2="${tmps}/config2.yaml"
|
cfg2="${tmps}/config2.yaml"
|
||||||
|
|
||||||
cat > ${cfg1} << _EOF
|
cat > "${cfg1}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -91,7 +94,7 @@ profiles:
|
|||||||
- psubsub
|
- psubsub
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cat > ${cfg2} << _EOF
|
cat > "${cfg2}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -117,47 +120,47 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
mkdir -p ${tmps}/dotfiles/
|
mkdir -p "${tmps}"/dotfiles/
|
||||||
echo "abc" > ${tmps}/dotfiles/abc
|
echo "abc" > "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ _dotfile_abs_dst @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ _dotfile_abs_dst @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
echo "def" > ${tmps}/dotfiles-other/def
|
echo "def" > "${tmps}"/dotfiles-other/def
|
||||||
echo "{{@@ _dotfile_abs_dst @@}}" >> ${tmps}/dotfiles-other/def
|
echo "{{@@ _dotfile_abs_dst @@}}" >> "${tmps}"/dotfiles-other/def
|
||||||
|
|
||||||
echo "ghi" > ${tmps}/dotfiles-other/ghi
|
echo "ghi" > "${tmps}"/dotfiles-other/ghi
|
||||||
echo "{{@@ _dotfile_abs_dst @@}}" >> ${tmps}/dotfiles-other/ghi
|
echo "{{@@ _dotfile_abs_dst @@}}" >> "${tmps}"/dotfiles-other/ghi
|
||||||
|
|
||||||
echo "zzz" > ${tmps}/dotfiles/zzz
|
echo "zzz" > "${tmps}"/dotfiles/zzz
|
||||||
echo "{{@@ _dotfile_abs_dst @@}}" >> ${tmps}/dotfiles/zzz
|
echo "{{@@ _dotfile_abs_dst @@}}" >> "${tmps}"/dotfiles/zzz
|
||||||
|
|
||||||
echo "sub" > ${tmps}/dotfiles/sub
|
echo "sub" > "${tmps}"/dotfiles/sub
|
||||||
echo "{{@@ _dotfile_abs_dst @@}}" >> ${tmps}/dotfiles/sub
|
echo "{{@@ _dotfile_abs_dst @@}}" >> "${tmps}"/dotfiles/sub
|
||||||
|
|
||||||
mkdir -p ${tmps}/dotfiles-other/subdir/sub
|
mkdir -p "${tmps}"/dotfiles-other/subdir/sub
|
||||||
echo "subsub" > ${tmps}/dotfiles-other/subdir/sub/asub
|
echo "subsub" > "${tmps}"/dotfiles-other/subdir/sub/asub
|
||||||
echo "{{@@ _dotfile_abs_dst @@}}" >> ${tmps}/dotfiles-other/subdir/sub/asub
|
echo "{{@@ _dotfile_abs_dst @@}}" >> "${tmps}"/dotfiles-other/subdir/sub/asub
|
||||||
|
|
||||||
# files comparison
|
# files comparison
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg1} -G -p p0 | grep '^f_def'
|
cd "${ddpath}" | ${bin} files -c "${cfg1}" -G -p p0 | grep '^f_def'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg1} -G -p p1 | grep '^f_abc'
|
cd "${ddpath}" | ${bin} files -c "${cfg1}" -G -p p1 | grep '^f_abc'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg1} -G -p p2 | grep '^f_def'
|
cd "${ddpath}" | ${bin} files -c "${cfg1}" -G -p p2 | grep '^f_def'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg1} -G -p p3 | grep '^f_zzz'
|
cd "${ddpath}" | ${bin} files -c "${cfg1}" -G -p p3 | grep '^f_zzz'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg1} -G -p pup | grep '^f_sub'
|
cd "${ddpath}" | ${bin} files -c "${cfg1}" -G -p pup | grep '^f_sub'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg1} -G -p psubsub | grep '^f_sub'
|
cd "${ddpath}" | ${bin} files -c "${cfg1}" -G -p psubsub | grep '^f_sub'
|
||||||
|
|
||||||
# test compare too
|
# test compare too
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg1} -p p2 -V -f
|
cd "${ddpath}" | ${bin} install -c "${cfg1}" -p p2 -V -f
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg1} -p p2 -V
|
cd "${ddpath}" | ${bin} compare -c "${cfg1}" -p p2 -V
|
||||||
|
|
||||||
[ ! -s ${tmpd}/def ] && echo "def not installed" && exit 1
|
[ ! -s "${tmpd}"/def ] && echo "def not installed" && exit 1
|
||||||
[ ! -s ${tmpd}/subdir/sub/asub ] && echo "asub not installed" && exit 1
|
[ ! -s "${tmpd}"/subdir/sub/asub ] && echo "asub not installed" && exit 1
|
||||||
|
|
||||||
# test with non-existing dotpath this time
|
# test with non-existing dotpath this time
|
||||||
|
|
||||||
rm -rf ${tmps}/dotfiles
|
rm -rf "${tmps}"/dotfiles
|
||||||
rm -rf ${tmpd}/*
|
rm -rf "${tmpd}"/*
|
||||||
|
|
||||||
cat > ${cfg1} << _EOF
|
cat > "${cfg1}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -167,7 +170,7 @@ config:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
profiles:
|
profiles:
|
||||||
_EOF
|
_EOF
|
||||||
cat > ${cfg2} << _EOF
|
cat > "${cfg2}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -182,14 +185,14 @@ profiles:
|
|||||||
- f_asub
|
- f_asub
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg1} -p p2 -V -f
|
cd "${ddpath}" | ${bin} install -c "${cfg1}" -p p2 -V -f
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg1} -p p2 -V
|
cd "${ddpath}" | ${bin} compare -c "${cfg1}" -p p2 -V
|
||||||
|
|
||||||
# test with same profile defined in both
|
# test with same profile defined in both
|
||||||
rm -rf ${tmps}/dotfiles
|
rm -rf "${tmps}"/dotfiles
|
||||||
rm -rf ${tmpd}/*
|
rm -rf "${tmpd}"/*
|
||||||
|
|
||||||
cat > ${cfg1} << _EOF
|
cat > "${cfg1}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -205,7 +208,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat > ${cfg2} << _EOF
|
cat > "${cfg2}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -221,30 +224,30 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
mkdir -p ${tmps}/dotfiles/
|
mkdir -p "${tmps}"/dotfiles/
|
||||||
|
|
||||||
echo "abc" > ${tmps}/dotfiles/abc
|
echo "abc" > "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ _dotfile_abs_dst @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ _dotfile_abs_dst @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
rm -f ${tmpd}/abc
|
rm -f "${tmpd}"/abc
|
||||||
|
|
||||||
echo "def" > ${tmps}/dotfiles/def
|
echo "def" > "${tmps}"/dotfiles/def
|
||||||
echo "{{@@ _dotfile_abs_dst @@}}" >> ${tmps}/dotfiles/def
|
echo "{{@@ _dotfile_abs_dst @@}}" >> "${tmps}"/dotfiles/def
|
||||||
rm -f ${tmpd}/def
|
rm -f "${tmpd}"/def
|
||||||
|
|
||||||
# files listing
|
# files listing
|
||||||
echo "file listing"
|
echo "file listing"
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg1} -p p1 -G | grep '^f_abc'
|
cd "${ddpath}" | ${bin} files -c "${cfg1}" -p p1 -G | grep '^f_abc'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg1} -p p1 -G | grep '^f_def'
|
cd "${ddpath}" | ${bin} files -c "${cfg1}" -p p1 -G | grep '^f_def'
|
||||||
|
|
||||||
# install and compare
|
# install and compare
|
||||||
echo "installing ..."
|
echo "installing ..."
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg1} -p p1 -V -f
|
cd "${ddpath}" | ${bin} install -c "${cfg1}" -p p1 -V -f
|
||||||
echo "comparing ..."
|
echo "comparing ..."
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg1} -p p1 -V
|
cd "${ddpath}" | ${bin} compare -c "${cfg1}" -p p1 -V
|
||||||
|
|
||||||
# check exists
|
# check exists
|
||||||
[ ! -s ${tmpd}/abc ] && echo "(same) abc not installed" && exit 1
|
[ ! -s "${tmpd}"/abc ] && echo "(same) abc not installed" && exit 1
|
||||||
[ ! -s ${tmpd}/def ] && echo "(same) def not installed" && exit 1
|
[ ! -s "${tmpd}"/def ] && echo "(same) def not installed" && exit 1
|
||||||
|
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
45
tests-ng/import-configs2.sh
vendored
45
tests-ng/import-configs2.sh
vendored
@@ -27,41 +27,44 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# the dotfile sources
|
# the dotfile sources
|
||||||
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
# 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}"
|
||||||
|
|
||||||
first="${tmps}/first"
|
first="${tmps}/first"
|
||||||
second="${tmps}/second"
|
second="${tmps}/second"
|
||||||
mkdir -p ${first} ${second}
|
mkdir -p "${first}" "${second}"
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg1="${first}/config.yaml"
|
cfg1="${first}/config.yaml"
|
||||||
cfg2="${second}/config.yaml"
|
cfg2="${second}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg1} << _EOF
|
cat > "${cfg1}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -80,7 +83,7 @@ profiles:
|
|||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cat > ${cfg2} << _EOF
|
cat > "${cfg2}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -96,24 +99,24 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
echo "abc" > ${first}/abc
|
echo "abc" > "${first}"/abc
|
||||||
echo "{{@@ _dotfile_abs_dst @@}}" >> ${first}/abc
|
echo "{{@@ _dotfile_abs_dst @@}}" >> "${first}"/abc
|
||||||
|
|
||||||
echo "def" > ${second}/def
|
echo "def" > "${second}"/def
|
||||||
echo "{{@@ _dotfile_abs_dst @@}}" >> ${second}/def
|
echo "{{@@ _dotfile_abs_dst @@}}" >> "${second}"/def
|
||||||
|
|
||||||
# files comparison
|
# files comparison
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg1} -G -p p0 | grep '^f_abc'
|
cd "${ddpath}" | ${bin} files -c "${cfg1}" -G -p p0 | grep '^f_abc'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg1} -G -p p0 | grep '^f_def'
|
cd "${ddpath}" | ${bin} files -c "${cfg1}" -G -p p0 | grep '^f_def'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg1} -G -p p1 | grep '^f_def'
|
cd "${ddpath}" | ${bin} files -c "${cfg1}" -G -p p1 | grep '^f_def'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg2} -G -p p1 | grep '^f_def'
|
cd "${ddpath}" | ${bin} files -c "${cfg2}" -G -p p1 | grep '^f_def'
|
||||||
|
|
||||||
# test compare too
|
# test compare too
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg1} -p p0 -V -f
|
cd "${ddpath}" | ${bin} install -c "${cfg1}" -p p0 -V -f
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg1} -p p0 -V
|
cd "${ddpath}" | ${bin} compare -c "${cfg1}" -p p0 -V
|
||||||
|
|
||||||
[ ! -s ${tmpd}/abc ] && echo "abc not installed" && exit 1
|
[ ! -s "${tmpd}"/abc ] && echo "abc not installed" && exit 1
|
||||||
[ ! -s ${tmpd}/def ] && echo "def not installed" && exit 1
|
[ ! -s "${tmpd}"/def ] && echo "def not installed" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
51
tests-ng/import-duplicate.sh
vendored
51
tests-ng/import-duplicate.sh
vendored
@@ -27,43 +27,46 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
touch ${tmpd}/.colors
|
touch "${tmpd}"/.colors
|
||||||
mkdir -p ${tmpd}/.mutt
|
mkdir -p "${tmpd}"/.mutt
|
||||||
touch ${tmpd}/.mutt/colors
|
touch "${tmpd}"/.mutt/colors
|
||||||
|
|
||||||
# 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
|
||||||
@@ -76,35 +79,35 @@ dotfiles:
|
|||||||
f_mutt_colors:
|
f_mutt_colors:
|
||||||
src: abc
|
src: abc
|
||||||
dst: abc
|
dst: abc
|
||||||
f_`echo ${tmpd} | sed -e 's#^/\(.*\)$#\1#g' | sed 's#/#_#g' | tr '[:upper:]' '[:lower:]'`_colors:
|
f_$(echo "${tmpd}" | sed -e 's#^/\(.*\)$#\1#g' | sed 's#/#_#g' | tr '[:upper:]' '[:lower:]')_colors:
|
||||||
src: abc
|
src: abc
|
||||||
dst: abc
|
dst: abc
|
||||||
f_`echo ${tmpd} | sed -e 's#^/tmp/\(.*\)$#\1#g' | sed 's#/#_#g' | tr '[:upper:]' '[:lower:]'`_colors:
|
f_$(echo "${tmpd}" | sed -e 's#^/tmp/\(.*\)$#\1#g' | sed 's#/#_#g' | tr '[:upper:]' '[:lower:]')_colors:
|
||||||
src: abc
|
src: abc
|
||||||
dst: abc
|
dst: abc
|
||||||
f_`echo ${tmpd} | sed -e 's#^/\(.*\)$#\1#g' | sed 's#/#_#g' | tr '[:upper:]' '[:lower:]'`_mutt_colors:
|
f_$(echo "${tmpd}" | sed -e 's#^/\(.*\)$#\1#g' | sed 's#/#_#g' | tr '[:upper:]' '[:lower:]')_mutt_colors:
|
||||||
src: abc
|
src: abc
|
||||||
dst: abc
|
dst: abc
|
||||||
f_`echo ${tmpd} | sed -e 's#^/tmp/\(.*\)$#\1#g' | sed 's#/#_#g' | tr '[:upper:]' '[:lower:]'`_mutt_colors:
|
f_$(echo "${tmpd}" | sed -e 's#^/tmp/\(.*\)$#\1#g' | sed 's#/#_#g' | tr '[:upper:]' '[:lower:]')_mutt_colors:
|
||||||
src: abc
|
src: abc
|
||||||
dst: abc
|
dst: abc
|
||||||
profiles:
|
profiles:
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# import
|
# import
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/.mutt/colors
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/.mutt/colors
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/.colors
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/.colors
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# ensure exists and is not link
|
# ensure exists and is not link
|
||||||
[ ! -d ${tmps}/dotfiles/${tmpd}/.mutt ] && echo "not a directory" && exit 1
|
[ ! -d "${tmps}"/dotfiles/"${tmpd}"/.mutt ] && echo "not a directory" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/.mutt/colors ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/.mutt/colors ] && echo "not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/.colors ] && echo "not exist (2)" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/.colors ] && echo "not exist (2)" && exit 1
|
||||||
|
|
||||||
cat ${cfg} | grep ${tmpd}/.mutt/colors >/dev/null 2>&1
|
cat "${cfg}" | grep "${tmpd}"/.mutt/colors >/dev/null 2>&1
|
||||||
cat ${cfg} | grep ${tmpd}/.colors >/dev/null 2>&1
|
cat "${cfg}" | grep "${tmpd}"/.colors >/dev/null 2>&1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
41
tests-ng/import-ignore.sh
vendored
41
tests-ng/import-ignore.sh
vendored
@@ -28,19 +28,22 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
@@ -54,27 +57,27 @@ grep_or_fail()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 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)
|
||||||
mkdir -p ${tmpd}
|
mkdir -p "${tmpd}"
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
mkdir -p ${tmpd}/a/{b,c}
|
mkdir -p "${tmpd}"/a/{b,c}
|
||||||
echo 'a' > ${tmpd}/a/b/abfile
|
echo 'a' > "${tmpd}"/a/b/abfile
|
||||||
echo 'a' > ${tmpd}/a/c/acfile
|
echo 'a' > "${tmpd}"/a/c/acfile
|
||||||
echo 'a' > ${tmpd}/a/b/newfile
|
echo 'a' > "${tmpd}"/a/b/newfile
|
||||||
mkdir -p ${tmpd}/a/newdir
|
mkdir -p "${tmpd}"/a/newdir
|
||||||
echo 'a' > ${tmpd}/a/newdir/newfile
|
echo 'a' > "${tmpd}"/a/newdir/newfile
|
||||||
|
|
||||||
# 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: false
|
backup: false
|
||||||
create: true
|
create: true
|
||||||
@@ -90,11 +93,11 @@ _EOF
|
|||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -c ${cfg} -f --verbose --profile=p1 ${tmpd}/a
|
cd "${ddpath}" | ${bin} import -c "${cfg}" -f --verbose --profile=p1 "${tmpd}"/a
|
||||||
|
|
||||||
[ -d ${tmps}/dotfiles/newdir ] && echo "newdir not ignored" && exit 1
|
[ -d "${tmps}"/dotfiles/newdir ] && echo "newdir not ignored" && exit 1
|
||||||
[ -e ${tmps}/dotfiles/newdir/newfile ] && echo "newfile not ignored" && exit 1
|
[ -e "${tmps}"/dotfiles/newdir/newfile ] && echo "newfile not ignored" && exit 1
|
||||||
[ -e ${tmps}/dotfiles/a/b/newfile ] && echo "newfile not ignored" && exit 1
|
[ -e "${tmps}"/dotfiles/a/b/newfile ] && echo "newfile not ignored" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
35
tests-ng/import-include.sh
vendored
35
tests-ng/import-include.sh
vendored
@@ -27,43 +27,46 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
|
|
||||||
# create the dotfile to import
|
# create the dotfile to import
|
||||||
echo "file" > ${tmpd}/file
|
echo "file" > "${tmpd}"/file
|
||||||
|
|
||||||
# create the dotfiles already imported
|
# create the dotfiles already imported
|
||||||
echo "already in" > ${tmps}/dotfiles/abc
|
echo "already in" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# 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
|
||||||
@@ -80,22 +83,22 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p0 | grep '^f_' | wc -l`
|
cnt=$(cd "${ddpath}" | ${bin} files -c "${cfg}" -p p0 | grep '^f_' | wc -l)
|
||||||
[ "${cnt}" != "1" ] && echo "this is bad" && exit 1
|
[ "${cnt}" != "1" ] && echo "this is bad" && exit 1
|
||||||
|
|
||||||
# import
|
# import
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p0 --verbose ${tmpd}/file
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p0 --verbose "${tmpd}"/file
|
||||||
|
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/file ] && echo "file not imported" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/file ] && echo "file not imported" && exit 1
|
||||||
|
|
||||||
# make sure file is in
|
# make sure file is in
|
||||||
cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p0 | grep '^f_file' | wc -l`
|
cnt=$(cd "${ddpath}" | ${bin} files -c "${cfg}" -p p0 | grep '^f_file' | wc -l)
|
||||||
[ "${cnt}" != "1" ] && echo "dotfiles not in config" && exit 1
|
[ "${cnt}" != "1" ] && echo "dotfiles not in config" && exit 1
|
||||||
|
|
||||||
# count
|
# count
|
||||||
cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p0 -b | grep '^f_' | wc -l`
|
cnt=$(cd "${ddpath}" | ${bin} files -c "${cfg}" -p p0 -b | grep '^f_' | wc -l)
|
||||||
[ "${cnt}" != "2" ] && echo "not enough dotfile" exit 1
|
[ "${cnt}" != "2" ] && echo "not enough dotfile" exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
56
tests-ng/import-link-children.sh
vendored
56
tests-ng/import-link-children.sh
vendored
@@ -32,7 +32,9 @@ ddpath="${cur}/../"
|
|||||||
|
|
||||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||||
bin="python3 -m dotdrop.dotdrop"
|
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 "dotdrop path: ${ddpath}"
|
||||||
echo "pythonpath: ${PYTHONPATH}"
|
echo "pythonpath: ${PYTHONPATH}"
|
||||||
@@ -40,7 +42,7 @@ echo "pythonpath: ${PYTHONPATH}"
|
|||||||
# get the helpers
|
# get the helpers
|
||||||
source ${cur}/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
|
# this is the test
|
||||||
@@ -92,39 +94,39 @@ _EOF
|
|||||||
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
|
||||||
[ ! -e ${dotpath}/${dtsub1} ] && echo "sub1 not found in dotpath" && exit 1
|
[ ! -e "${dotpath}"/"${dtsub1}" ] && echo "sub1 not found in dotpath" && exit 1
|
||||||
[ ! -e ${dotpath}/${dtsub2} ] && echo "sub2 not found in dotpath" && exit 1
|
[ ! -e "${dotpath}"/"${dtsub2}" ] && echo "sub2 not found in dotpath" && exit 1
|
||||||
[ ! -e ${dotpath}/${dtsub3} ] && echo "sub3 not found in dotpath" && exit 1
|
[ ! -e "${dotpath}"/"${dtsub3}" ] && echo "sub3 not found in dotpath" && exit 1
|
||||||
[ ! -e ${dotpath}/${f1} ] && echo "f1 not found in dotpath" && exit 1
|
[ ! -e "${dotpath}"/"${f1}" ] && echo "f1 not found in dotpath" && exit 1
|
||||||
[ ! -e ${dotpath}/${subf1} ] && echo "subf1 not found in dotpath" && exit 1
|
[ ! -e "${dotpath}"/"${subf1}" ] && echo "subf1 not found in dotpath" && exit 1
|
||||||
[ ! -e ${dotpath}/${subf2} ] && echo "subf2 not found in dotpath" && exit 1
|
[ ! -e "${dotpath}"/"${subf2}" ] && echo "subf2 not found in dotpath" && exit 1
|
||||||
[ ! -e ${dotpath}/${subf3} ] && echo "subf3 not found in dotpath" && exit 1
|
[ ! -e "${dotpath}"/"${subf3}" ] && echo "subf3 not found in dotpath" && exit 1
|
||||||
|
|
||||||
# checks file exists in fs
|
# checks file exists in fs
|
||||||
[ ! -e ${dt} ] && echo "dotfile not imported" && exit 1
|
[ ! -e "${dt}" ] && echo "dotfile not imported" && exit 1
|
||||||
[ ! -e ${dtsub1} ] && echo "sub1 not found in fs" && exit 1
|
[ ! -e "${dtsub1}" ] && echo "sub1 not found in fs" && exit 1
|
||||||
[ ! -e ${dtsub2} ] && echo "sub2 not found in fs" && exit 1
|
[ ! -e "${dtsub2}" ] && echo "sub2 not found in fs" && exit 1
|
||||||
[ ! -e ${dtsub3} ] && echo "sub3 not found in fs" && exit 1
|
[ ! -e "${dtsub3}" ] && echo "sub3 not found in fs" && exit 1
|
||||||
[ ! -e ${f1} ] && echo "f1 not found in fs" && exit 1
|
[ ! -e "${f1}" ] && echo "f1 not found in fs" && exit 1
|
||||||
[ ! -e ${subf1} ] && echo "subf1 not found in fs" && exit 1
|
[ ! -e "${subf1}" ] && echo "subf1 not found in fs" && exit 1
|
||||||
[ ! -e ${subf2} ] && echo "subf2 not found in fs" && exit 1
|
[ ! -e "${subf2}" ] && echo "subf2 not found in fs" && exit 1
|
||||||
[ ! -e ${subf3} ] && echo "subf3 not found in fs" && exit 1
|
[ ! -e "${subf3}" ] && echo "subf3 not found in fs" && exit 1
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks file have correct type in fs
|
# checks file have correct type in fs
|
||||||
[ ! -h ${f1} ] && echo "f1 is not a symlink" && exit 1
|
[ ! -h "${f1}" ] && echo "f1 is not a symlink" && exit 1
|
||||||
[ -h ${subf1} ] && echo "subf1 is not a regular file" && exit 1
|
[ -h "${subf1}" ] && echo "subf1 is not a regular file" && exit 1
|
||||||
[ -h ${subf2} ] && echo "subf2 is not a regular file" && exit 1
|
[ -h "${subf2}" ] && echo "subf2 is not a regular file" && exit 1
|
||||||
[ -h ${subf3} ] && echo "subf3 is not a regular file" && exit 1
|
[ -h "${subf3}" ] && echo "subf3 is not a regular file" && exit 1
|
||||||
[ ! -h ${dtsub1} ] && echo "dtsub1 is not a symlink" && exit 1
|
[ ! -h "${dtsub1}" ] && echo "dtsub1 is not a symlink" && exit 1
|
||||||
[ ! -h ${dtsub2} ] && echo "dtsub2 is not a symlink" && exit 1
|
[ ! -h "${dtsub2}" ] && echo "dtsub2 is not a symlink" && exit 1
|
||||||
[ -h ${dtsub3} ] && echo "dtsub3 is not a regular directory" && exit 1
|
[ -h "${dtsub3}" ] && echo "dtsub3 is not a regular directory" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
86
tests-ng/import-negative-ignore.sh
vendored
86
tests-ng/import-negative-ignore.sh
vendored
@@ -9,41 +9,12 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# all this crap to get current path
|
# all this crap to get current path
|
||||||
if [ $(uname) = Darwin ]; then
|
rl="readlink -f"
|
||||||
# Unfortunately, readlink works differently on macOS than it does on GNU/Linux
|
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
||||||
# (the -f option behaves differently) and the realpath command does not exist.
|
rl="realpath"
|
||||||
# Workarounds I find on the Internet suggest just using Homebrew to install coreutils
|
|
||||||
# so you can get the GNU coreutils on your Mac. But, I don't want this script to
|
|
||||||
# assume (a) users have Homebrew installed and (b) if they have Homebrew installed, that
|
|
||||||
# they then installed the GNU coreutils.
|
|
||||||
readlink() {
|
|
||||||
TARGET_FILE=$1
|
|
||||||
|
|
||||||
cd `dirname $TARGET_FILE`
|
if ! hash ${rl}; then
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
echo "\"${rl}\" not found !" && exit 1
|
||||||
|
|
||||||
# Iterate down a (possible) chain of symlinks
|
|
||||||
while [ -L "$TARGET_FILE" ]; do
|
|
||||||
TARGET_FILE=`readlink $TARGET_FILE`
|
|
||||||
cd `dirname $TARGET_FILE`
|
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
|
||||||
done
|
|
||||||
|
|
||||||
# Compute the canonicalized name by finding the physical path
|
|
||||||
# for the directory we're in and appending the target file.
|
|
||||||
PHYS_DIR=`pwd -P`
|
|
||||||
RESULT=$PHYS_DIR/$TARGET_FILE
|
|
||||||
echo $RESULT
|
|
||||||
}
|
|
||||||
rl="readlink"
|
|
||||||
else
|
|
||||||
rl="readlink -f"
|
|
||||||
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
|
||||||
rl="realpath"
|
|
||||||
|
|
||||||
if ! hash ${rl}; then
|
|
||||||
echo "\"${rl}\" not found !" && exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cur=$(dirname "$(${rl} "${0}")")
|
cur=$(dirname "$(${rl} "${0}")")
|
||||||
@@ -51,29 +22,32 @@ cur=$(dirname "$(${rl} "${0}")")
|
|||||||
# dotdrop path can be pass as argument
|
# dotdrop path can be pass as argument
|
||||||
ddpath="${cur}/../"
|
ddpath="${cur}/../"
|
||||||
[ -n "${1}" ] && ddpath="${1}"
|
[ -n "${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"
|
||||||
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 "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) <==$(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
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
mkdir -p ${basedir}/dotfiles
|
mkdir -p "${basedir}"/dotfiles
|
||||||
|
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mkdir -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
tmpd=$(mkdir -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
@@ -81,36 +55,36 @@ clear_on_exit "${tmpd}"
|
|||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
mkdir -p ${tmpd}/a/{b,c}
|
mkdir -p "${tmpd}"/a/{b,c}
|
||||||
echo 'a' > ${tmpd}/a/b/abfile1
|
echo 'a' > "${tmpd}"/a/b/abfile1
|
||||||
echo 'a' > ${tmpd}/a/b/abfile2
|
echo 'a' > "${tmpd}"/a/b/abfile2
|
||||||
echo 'a' > ${tmpd}/a/b/abfile3
|
echo 'a' > "${tmpd}"/a/b/abfile3
|
||||||
echo 'a' > ${tmpd}/a/c/acfile
|
echo 'a' > "${tmpd}"/a/c/acfile
|
||||||
mkdir -p ${tmpd}/a/newdir/b
|
mkdir -p "${tmpd}"/a/newdir/b
|
||||||
touch ${tmpd}/a/newdir/b/{c,d}
|
touch "${tmpd}"/a/newdir/b/{c,d}
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
sed '/dotpath: dotfiles/a\
|
sed '/dotpath: dotfiles/a\
|
||||||
\ \ impignore:\
|
\ \ impignore:\
|
||||||
\ \ \ \ - "*/newdir/b/*"\
|
\ \ \ \ - "*/newdir/b/*"\
|
||||||
\ \ \ \ - "!*/newdir/b/d"\
|
\ \ \ \ - "!*/newdir/b/d"\
|
||||||
\ \ \ \ - "*/abfile?"\
|
\ \ \ \ - "*/abfile?"\
|
||||||
\ \ \ \ - "!*/abfile3"
|
\ \ \ \ - "!*/abfile3"
|
||||||
' ${cfg} > ${cfg2}
|
' "${cfg}" > "${cfg2}"
|
||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg2} --verbose --profile=p1 ${tmpd}/a --as=~/a
|
cd "${ddpath}" | ${bin} import -f -c "${cfg2}" --verbose --profile=p1 "${tmpd}"/a --as=~/a
|
||||||
|
|
||||||
# check files haven't been imported
|
# check files haven't been imported
|
||||||
[ -e ${basedir}/dotfiles/a/newdir/b/c ] && echo "newdir/b/c should not have been imported" && exit 1
|
[ -e "${basedir}"/dotfiles/a/newdir/b/c ] && echo "newdir/b/c should not have been imported" && exit 1
|
||||||
[ ! -e ${basedir}/dotfiles/a/newdir/b/d ] && echo "newdir/b/d should have been imported" && exit 1
|
[ ! -e "${basedir}"/dotfiles/a/newdir/b/d ] && echo "newdir/b/d should have been imported" && exit 1
|
||||||
[ -e ${basedir}/dotfiles/a/b/abfile1 ] && echo "abfile1 should not have been imported" && exit 1
|
[ -e "${basedir}"/dotfiles/a/b/abfile1 ] && echo "abfile1 should not have been imported" && exit 1
|
||||||
[ -e ${basedir}/dotfiles/a/b/abfile2 ] && echo "abfile2 should not have been imported" && exit 1
|
[ -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
|
[ ! -e "${basedir}"/dotfiles/a/b/abfile3 ] && echo "abfile3 should have been imported" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
59
tests-ng/import-non-existing.sh
vendored
59
tests-ng/import-non-existing.sh
vendored
@@ -27,41 +27,44 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# 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
|
||||||
@@ -90,9 +93,9 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# dummy call
|
# dummy call
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -111,11 +114,11 @@ _EOF
|
|||||||
|
|
||||||
# dummy call
|
# dummy call
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||||
[ "$?" = "0" ] && echo "variables" && exit 1
|
[ "$?" = "0" ] && echo "variables" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -134,11 +137,11 @@ _EOF
|
|||||||
|
|
||||||
# dummy call
|
# dummy call
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||||
[ "$?" = "0" ] && echo "variables with separator" && exit 1
|
[ "$?" = "0" ] && echo "variables with separator" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -157,11 +160,11 @@ _EOF
|
|||||||
|
|
||||||
# dummy call
|
# dummy call
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||||
[ "$?" = "0" ] && echo "variables glob" && exit 1
|
[ "$?" = "0" ] && echo "variables glob" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -180,11 +183,11 @@ _EOF
|
|||||||
|
|
||||||
# dummy call
|
# dummy call
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||||
[ "$?" = "0" ] && echo "actions" && exit 1
|
[ "$?" = "0" ] && echo "actions" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -203,11 +206,11 @@ _EOF
|
|||||||
|
|
||||||
# dummy call
|
# dummy call
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||||
[ "$?" = "0" ] && echo "actions with separator" && exit 1
|
[ "$?" = "0" ] && echo "actions with separator" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -226,11 +229,11 @@ _EOF
|
|||||||
|
|
||||||
# dummy call
|
# dummy call
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||||
[ "$?" = "0" ] && echo "actions glob" && exit 1
|
[ "$?" = "0" ] && echo "actions glob" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -249,11 +252,11 @@ _EOF
|
|||||||
|
|
||||||
# dummy call
|
# dummy call
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||||
[ "$?" = "0" ] && echo "configs" && exit 1
|
[ "$?" = "0" ] && echo "configs" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -272,11 +275,11 @@ _EOF
|
|||||||
|
|
||||||
# dummy call
|
# dummy call
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||||
[ "$?" = "0" ] && echo "configs with separator" && exit 1
|
[ "$?" = "0" ] && echo "configs with separator" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -295,7 +298,7 @@ _EOF
|
|||||||
|
|
||||||
# dummy call
|
# dummy call
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||||
[ "$?" = "0" ] && echo "configs glob" && exit 1
|
[ "$?" = "0" ] && echo "configs glob" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|||||||
53
tests-ng/import-profile-dotfiles.sh
vendored
53
tests-ng/import-profile-dotfiles.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
extdotfiles="${tmps}/df_p1.yaml"
|
extdotfiles="${tmps}/df_p1.yaml"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -62,7 +65,7 @@ dynextdotfiles="${tmps}/ext_${dynextdotfiles_name}"
|
|||||||
# 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
|
||||||
@@ -87,42 +90,42 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
import:
|
import:
|
||||||
- $(basename ${extdotfiles})
|
- $(basename "${extdotfiles}")
|
||||||
- "ext_{{@@ d_uid @@}}"
|
- "ext_{{@@ d_uid @@}}"
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the external dotfile file
|
# create the external dotfile file
|
||||||
cat > ${extdotfiles} << _EOF
|
cat > "${extdotfiles}" << _EOF
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- f_def
|
- f_def
|
||||||
- f_xyz
|
- f_xyz
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cat > ${dynextdotfiles} << _EOF
|
cat > "${dynextdotfiles}" << _EOF
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- f_dyn
|
- f_dyn
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
mkdir -p ${tmps}/dotfiles/
|
mkdir -p "${tmps}"/dotfiles/
|
||||||
echo "abc" > ${tmps}/dotfiles/abc
|
echo "abc" > "${tmps}"/dotfiles/abc
|
||||||
echo "def" > ${tmps}/dotfiles/def
|
echo "def" > "${tmps}"/dotfiles/def
|
||||||
echo "xyz" > ${tmps}/dotfiles/xyz
|
echo "xyz" > "${tmps}"/dotfiles/xyz
|
||||||
echo "dyn" > ${tmps}/dotfiles/dyn
|
echo "dyn" > "${tmps}"/dotfiles/dyn
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpd}/abc ] && exit 1
|
[ ! -e "${tmpd}"/abc ] && exit 1
|
||||||
[ ! -e ${tmpd}/def ] && exit 1
|
[ ! -e "${tmpd}"/def ] && exit 1
|
||||||
[ ! -e ${tmpd}/xyz ] && exit 1
|
[ ! -e "${tmpd}"/xyz ] && exit 1
|
||||||
[ ! -e ${tmpd}/dyn ] && exit 1
|
[ ! -e "${tmpd}"/dyn ] && exit 1
|
||||||
echo 'file found'
|
echo 'file found'
|
||||||
grep 'abc' ${tmpd}/abc >/dev/null 2>&1
|
grep 'abc' "${tmpd}"/abc >/dev/null 2>&1
|
||||||
grep 'def' ${tmpd}/def >/dev/null 2>&1
|
grep 'def' "${tmpd}"/def >/dev/null 2>&1
|
||||||
grep 'xyz' ${tmpd}/xyz >/dev/null 2>&1
|
grep 'xyz' "${tmpd}"/xyz >/dev/null 2>&1
|
||||||
grep 'dyn' ${tmpd}/dyn >/dev/null 2>&1
|
grep 'dyn' "${tmpd}"/dyn >/dev/null 2>&1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
33
tests-ng/import-subfile.sh
vendored
33
tests-ng/import-subfile.sh
vendored
@@ -28,42 +28,45 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmpd}/adir
|
mkdir -p "${tmpd}"/adir
|
||||||
echo "first" > ${tmpd}/adir/file1
|
echo "first" > "${tmpd}"/adir/file1
|
||||||
|
|
||||||
# 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
|
||||||
@@ -74,18 +77,18 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# import dir
|
# import dir
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/adir
|
||||||
|
|
||||||
# change the file
|
# change the file
|
||||||
echo "second" >> ${tmpd}/adir/file1
|
echo "second" >> "${tmpd}"/adir/file1
|
||||||
|
|
||||||
# import file
|
# import file
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir/file1
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/adir/file1
|
||||||
|
|
||||||
# test
|
# test
|
||||||
#cat ${tmps}/dotfiles/${tmpd}/adir/file1
|
#cat ${tmps}/dotfiles/${tmpd}/adir/file1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/adir/file1 ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/adir/file1 ] && echo "not exist" && exit 1
|
||||||
grep 'second' ${tmps}/dotfiles/${tmpd}/adir/file1 >/dev/null
|
grep 'second' "${tmps}"/dotfiles/"${tmpd}"/adir/file1 >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
63
tests-ng/import-to-no-profile.sh
vendored
63
tests-ng/import-to-no-profile.sh
vendored
@@ -27,42 +27,45 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "file1" > ${tmpd}/file1
|
echo "file1" > "${tmpd}"/file1
|
||||||
echo "file2" > ${tmpd}/file2
|
echo "file2" > "${tmpd}"/file2
|
||||||
|
|
||||||
# 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
|
||||||
@@ -76,57 +79,57 @@ noprofile="ALL"
|
|||||||
|
|
||||||
##################################
|
##################################
|
||||||
# import with profile from arg
|
# import with profile from arg
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p "${noprofile}" -V ${tmpd}/file1
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p "${noprofile}" -V "${tmpd}"/file1
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# ensure exists and is not link
|
# ensure exists and is not link
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/file1 ] && echo "file not imported" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/file1 ] && echo "file not imported" && exit 1
|
||||||
# ensure present in config
|
# ensure present in config
|
||||||
cat ${cfg} | grep ${tmpd}/file1 >/dev/null 2>&1
|
cat "${cfg}" | grep "${tmpd}"/file1 >/dev/null 2>&1
|
||||||
|
|
||||||
nb=`cat ${cfg} | grep f_file1 | wc -l`
|
nb=$(cat "${cfg}" | grep f_file1 | wc -l)
|
||||||
[ "${nb}" != "1" ] && echo 'bad config' && exit 1
|
[ "${nb}" != "1" ] && echo 'bad config' && exit 1
|
||||||
|
|
||||||
cntpre=`find ${tmps}/dotfiles -type f | wc -l`
|
cntpre=$(find "${tmps}"/dotfiles -type f | wc -l)
|
||||||
|
|
||||||
# reimport
|
# reimport
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p "${noprofile}" -V ${tmpd}/file1
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p "${noprofile}" -V "${tmpd}"/file1
|
||||||
set -e
|
set -e
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
cntpost=`find ${tmps}/dotfiles -type f | wc -l`
|
cntpost=$(find "${tmps}"/dotfiles -type f | wc -l)
|
||||||
[ "${cntpost}" != "${cntpre}" ] && echo "imported twice" && exit 1
|
[ "${cntpost}" != "${cntpre}" ] && echo "imported twice" && exit 1
|
||||||
|
|
||||||
nb=`cat ${cfg} | grep "dst: ${tmpd}/file1" | wc -l`
|
nb=$(cat "${cfg}" | grep "dst: ${tmpd}/file1" | wc -l)
|
||||||
[ "${nb}" != "1" ] && echo 'imported twice in config' && exit 1
|
[ "${nb}" != "1" ] && echo 'imported twice in config' && exit 1
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
# import with profile from env
|
# import with profile from env
|
||||||
export DOTDROP_PROFILE="${noprofile}"
|
export DOTDROP_PROFILE="${noprofile}"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -V ${tmpd}/file2
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -V "${tmpd}"/file2
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# ensure exists and is not link
|
# ensure exists and is not link
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/file2 ] && echo "file not imported" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/file2 ] && echo "file not imported" && exit 1
|
||||||
# ensure present in config
|
# ensure present in config
|
||||||
cat ${cfg} | grep ${tmpd}/file2 >/dev/null 2>&1
|
cat "${cfg}" | grep "${tmpd}"/file2 >/dev/null 2>&1
|
||||||
|
|
||||||
nb=`cat ${cfg} | grep f_file2 | wc -l`
|
nb=$(cat "${cfg}" | grep f_file2 | wc -l)
|
||||||
[ "${nb}" != "1" ] && echo 'bad config' && exit 1
|
[ "${nb}" != "1" ] && echo 'bad config' && exit 1
|
||||||
|
|
||||||
cntpre=`find ${tmps}/dotfiles -type f | wc -l`
|
cntpre=$(find "${tmps}"/dotfiles -type f | wc -l)
|
||||||
|
|
||||||
# reimport
|
# reimport
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -V ${tmpd}/file2
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -V "${tmpd}"/file2
|
||||||
set -e
|
set -e
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
cntpost=`find ${tmps}/dotfiles -type f | wc -l`
|
cntpost=$(find "${tmps}"/dotfiles -type f | wc -l)
|
||||||
[ "${cntpost}" != "${cntpre}" ] && echo "imported twice" && exit 1
|
[ "${cntpost}" != "${cntpre}" ] && echo "imported twice" && exit 1
|
||||||
|
|
||||||
nb=`cat ${cfg} | grep "dst: ${tmpd}/file2" | wc -l`
|
nb=$(cat "${cfg}" | grep "dst: ${tmpd}/file2" | wc -l)
|
||||||
[ "${nb}" != "1" ] && echo 'imported twice in config' && exit 1
|
[ "${nb}" != "1" ] && echo 'imported twice in config' && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
29
tests-ng/import-with-empty.sh
vendored
29
tests-ng/import-with-empty.sh
vendored
@@ -28,41 +28,44 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
# the temp directory
|
# the temp directory
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# create a dotfile
|
# create a dotfile
|
||||||
dftoimport="${tmpd}/a_dotfile"
|
dftoimport="${tmpd}/a_dotfile"
|
||||||
echo 'some content' > ${dftoimport}
|
echo 'some content' > "${dftoimport}"
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -96,15 +99,15 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 --verbose ${dftoimport}
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 --verbose "${dftoimport}"
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
echo "[+] install"
|
echo "[+] install"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 --verbose | grep '^5 dotfile(s) installed.$'
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p1 --verbose | grep '^5 dotfile(s) installed.$'
|
||||||
rm -f ${dftoimport}
|
rm -f "${dftoimport}"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 --verbose | grep '^6 dotfile(s) installed.$'
|
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]' | grep -v '^Dotfile(s)' | wc -l`
|
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
|
[ "${nb}" != "6" ] && echo "error in dotfile list (${nb} VS 6)" && exit 1
|
||||||
|
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|||||||
105
tests-ng/import-with-trans.sh
vendored
105
tests-ng/import-with-trans.sh
vendored
@@ -29,30 +29,33 @@ 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"
|
||||||
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 "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) <==$(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
|
||||||
echo "dotfiles source (dotpath): ${tmps}"
|
echo "dotfiles source (dotpath): ${tmps}"
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "dotfiles destination: ${tmpd}"
|
echo "dotfiles destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -61,7 +64,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
trans_read:
|
trans_read:
|
||||||
base64: "cat {0} | base64 -d > {1}"
|
base64: "cat {0} | base64 -d > {1}"
|
||||||
decompress: "mkdir -p {1} && tar -xf {0} -C {1}"
|
decompress: "mkdir -p {1} && tar -xf {0} -C {1}"
|
||||||
@@ -85,10 +88,10 @@ tokend="compressed archive"
|
|||||||
tokenenc="encrypted"
|
tokenenc="encrypted"
|
||||||
|
|
||||||
# create the dotfiles
|
# create the dotfiles
|
||||||
echo ${token} > ${tmpd}/abc
|
echo ${token} > "${tmpd}"/abc
|
||||||
mkdir -p ${tmpd}/def/a
|
mkdir -p "${tmpd}"/def/a
|
||||||
echo ${tokend} > ${tmpd}/def/a/file
|
echo "${tokend}" > "${tmpd}"/def/a/file
|
||||||
echo ${tokenenc} > ${tmpd}/ghi
|
echo ${tokenenc} > "${tmpd}"/ghi
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# test import
|
# test import
|
||||||
@@ -96,73 +99,73 @@ echo ${tokenenc} > ${tmpd}/ghi
|
|||||||
|
|
||||||
echo "[+] run import"
|
echo "[+] run import"
|
||||||
# import file (to base64)
|
# import file (to base64)
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -b -V --transw=base64 --transr=base64 ${tmpd}/abc
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -b -V --transw=base64 --transr=base64 "${tmpd}"/abc
|
||||||
# import directory (to compress)
|
# import directory (to compress)
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -b -V --transw=compress --transr=decompress ${tmpd}/def
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -b -V --transw=compress --transr=decompress "${tmpd}"/def
|
||||||
# import file (to encrypt)
|
# import file (to encrypt)
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -b -V --transw=encrypt --transr=decrypt ${tmpd}/ghi
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -b -V --transw=encrypt --transr=decrypt "${tmpd}"/ghi
|
||||||
|
|
||||||
# check file imported in dotpath
|
# check file imported in dotpath
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/abc ] && echo "abc does not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/abc ] && echo "abc does not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/def ] && echo "def does not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/def ] && echo "def does not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/ghi ] && echo "ghi does not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/ghi ] && echo "ghi does not exist" && exit 1
|
||||||
|
|
||||||
# check content in dotpath
|
# check content in dotpath
|
||||||
echo "checking content"
|
echo "checking content"
|
||||||
file ${tmps}/dotfiles/${tmpd}/abc | grep -i 'text'
|
file "${tmps}"/dotfiles/"${tmpd}"/abc | grep -i 'text'
|
||||||
cat ${tmpd}/abc | base64 > ${tmps}/test-abc
|
cat "${tmpd}"/abc | base64 > "${tmps}"/test-abc
|
||||||
diff ${tmps}/dotfiles/${tmpd}/abc ${tmps}/test-abc
|
diff "${tmps}"/dotfiles/"${tmpd}"/abc "${tmps}"/test-abc
|
||||||
|
|
||||||
file ${tmps}/dotfiles/${tmpd}/def | grep -i 'tar'
|
file "${tmps}"/dotfiles/"${tmpd}"/def | grep -i 'tar'
|
||||||
tar -cf ${tmps}/test-def -C ${tmpd}/def .
|
tar -cf "${tmps}"/test-def -C "${tmpd}"/def .
|
||||||
diff ${tmps}/dotfiles/${tmpd}/def ${tmps}/test-def
|
diff "${tmps}"/dotfiles/"${tmpd}"/def "${tmps}"/test-def
|
||||||
|
|
||||||
file ${tmps}/dotfiles/${tmpd}/ghi | grep -i 'gpg symmetrically encrypted data'
|
file "${tmps}"/dotfiles/"${tmpd}"/ghi | grep -i 'gpg symmetrically encrypted data'
|
||||||
echo p1 | gpg -q --batch --yes --passphrase-fd 0 --no-tty -d ${tmps}/dotfiles/${tmpd}/ghi > ${tmps}/test-ghi
|
echo p1 | gpg -q --batch --yes --passphrase-fd 0 --no-tty -d "${tmps}"/dotfiles/"${tmpd}"/ghi > "${tmps}"/test-ghi
|
||||||
diff ${tmps}/test-ghi ${tmpd}/ghi
|
diff "${tmps}"/test-ghi "${tmpd}"/ghi
|
||||||
|
|
||||||
# check is imported in config
|
# check is imported in config
|
||||||
echo "checking imported in config"
|
echo "checking imported in config"
|
||||||
cd ${ddpath} | ${bin} -p p1 -c ${cfg} files
|
cd "${ddpath}" | ${bin} -p p1 -c "${cfg}" files
|
||||||
cd ${ddpath} | ${bin} -p p1 -c ${cfg} files | grep '^f_abc'
|
cd "${ddpath}" | ${bin} -p p1 -c "${cfg}" files | grep '^f_abc'
|
||||||
cd ${ddpath} | ${bin} -p p1 -c ${cfg} files | grep '^d_def'
|
cd "${ddpath}" | ${bin} -p p1 -c "${cfg}" files | grep '^d_def'
|
||||||
cd ${ddpath} | ${bin} -p p1 -c ${cfg} files | grep '^f_ghi'
|
cd "${ddpath}" | ${bin} -p p1 -c "${cfg}" files | grep '^f_ghi'
|
||||||
|
|
||||||
# check has trans_write and trans_read in config
|
# check has trans_write and trans_read in config
|
||||||
echo "checking trans_write is set in config"
|
echo "checking trans_write is set in config"
|
||||||
echo "--------------"
|
echo "--------------"
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
echo "--------------"
|
echo "--------------"
|
||||||
cat ${cfg} | grep -A 4 'f_abc:' | grep 'trans_write: base64'
|
cat "${cfg}" | grep -A 4 'f_abc:' | grep 'trans_write: base64'
|
||||||
cat ${cfg} | grep -A 4 'd_def:' | grep 'trans_write: compress'
|
cat "${cfg}" | grep -A 4 'd_def:' | grep 'trans_write: compress'
|
||||||
cat ${cfg} | grep -A 4 'f_ghi:' | grep 'trans_write: encrypt'
|
cat "${cfg}" | grep -A 4 'f_ghi:' | grep 'trans_write: encrypt'
|
||||||
|
|
||||||
cat ${cfg} | grep -A 4 'f_abc:' | grep 'trans_read: base64'
|
cat "${cfg}" | grep -A 4 'f_abc:' | grep 'trans_read: base64'
|
||||||
cat ${cfg} | grep -A 4 'd_def:' | grep 'trans_read: decompress'
|
cat "${cfg}" | grep -A 4 'd_def:' | grep 'trans_read: decompress'
|
||||||
cat ${cfg} | grep -A 4 'f_ghi:' | grep 'trans_read: decrypt'
|
cat "${cfg}" | grep -A 4 'f_ghi:' | grep 'trans_read: decrypt'
|
||||||
|
|
||||||
# install these
|
# install these
|
||||||
echo "install and check"
|
echo "install and check"
|
||||||
rm ${tmpd}/abc
|
rm "${tmpd}"/abc
|
||||||
rm -r ${tmpd}/def
|
rm -r "${tmpd}"/def
|
||||||
rm ${tmpd}/ghi
|
rm "${tmpd}"/ghi
|
||||||
|
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -b -V
|
||||||
|
|
||||||
# test exist
|
# test exist
|
||||||
echo "check exist"
|
echo "check exist"
|
||||||
[ ! -e ${tmpd}/abc ] && exit 1
|
[ ! -e "${tmpd}"/abc ] && exit 1
|
||||||
[ ! -d ${tmpd}/def/a ] && exit 1
|
[ ! -d "${tmpd}"/def/a ] && exit 1
|
||||||
[ ! -e ${tmpd}/def/a/file ] && exit 1
|
[ ! -e "${tmpd}"/def/a/file ] && exit 1
|
||||||
[ ! -e ${tmpd}/ghi ] && exit 1
|
[ ! -e "${tmpd}"/ghi ] && exit 1
|
||||||
|
|
||||||
# test content
|
# test content
|
||||||
echo "check content"
|
echo "check content"
|
||||||
cat ${tmpd}/abc
|
cat "${tmpd}"/abc
|
||||||
cat ${tmpd}/abc | grep "${token}"
|
cat "${tmpd}"/abc | grep "${token}"
|
||||||
cat ${tmpd}/def/a/file
|
cat "${tmpd}"/def/a/file
|
||||||
cat ${tmpd}/def/a/file | grep "${tokend}"
|
cat "${tmpd}"/def/a/file | grep "${tokend}"
|
||||||
cat ${tmpd}/ghi | grep "${tokenenc}"
|
cat "${tmpd}"/ghi | grep "${tokenenc}"
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
77
tests-ng/import.sh
vendored
77
tests-ng/import.sh
vendored
@@ -27,44 +27,47 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmpd}/adir
|
mkdir -p "${tmpd}"/adir
|
||||||
echo "adir/file1" > ${tmpd}/adir/file1
|
echo "adir/file1" > "${tmpd}"/adir/file1
|
||||||
echo "adir/fil2" > ${tmpd}/adir/file2
|
echo "adir/fil2" > "${tmpd}"/adir/file2
|
||||||
echo "file3" > ${tmpd}/file3
|
echo "file3" > "${tmpd}"/file3
|
||||||
|
|
||||||
# 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
|
||||||
@@ -75,39 +78,39 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# import
|
# import
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/adir
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/file3
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/file3
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# ensure exists and is not link
|
# ensure exists and is not link
|
||||||
[ ! -d ${tmps}/dotfiles/${tmpd}/adir ] && echo "not a directory" && exit 1
|
[ ! -d "${tmps}"/dotfiles/"${tmpd}"/adir ] && echo "not a directory" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/adir/file1 ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/adir/file1 ] && echo "not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/adir/file2 ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/adir/file2 ] && echo "not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/file3 ] && echo "not a file" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${tmpd}"/file3 ] && echo "not a file" && exit 1
|
||||||
|
|
||||||
cat ${cfg} | grep ${tmpd}/adir >/dev/null 2>&1
|
cat "${cfg}" | grep "${tmpd}"/adir >/dev/null 2>&1
|
||||||
cat ${cfg} | grep ${tmpd}/file3 >/dev/null 2>&1
|
cat "${cfg}" | grep "${tmpd}"/file3 >/dev/null 2>&1
|
||||||
|
|
||||||
nb=`cat ${cfg} | grep d_adir | wc -l`
|
nb=$(cat "${cfg}" | grep d_adir | wc -l)
|
||||||
[ "${nb}" != "2" ] && echo 'bad config1' && exit 1
|
[ "${nb}" != "2" ] && echo 'bad config1' && exit 1
|
||||||
nb=`cat ${cfg} | grep f_file3 | wc -l`
|
nb=$(cat "${cfg}" | grep f_file3 | wc -l)
|
||||||
[ "${nb}" != "2" ] && echo 'bad config2' && exit 1
|
[ "${nb}" != "2" ] && echo 'bad config2' && exit 1
|
||||||
|
|
||||||
cntpre=`find ${tmps}/dotfiles -type f | wc -l`
|
cntpre=$(find "${tmps}"/dotfiles -type f | wc -l)
|
||||||
|
|
||||||
# reimport
|
# reimport
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/adir
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/file3
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/file3
|
||||||
|
|
||||||
cntpost=`find ${tmps}/dotfiles -type f | wc -l`
|
cntpost=$(find "${tmps}"/dotfiles -type f | wc -l)
|
||||||
|
|
||||||
[ "${cntpost}" != "${cntpre}" ] && echo "import issue" && exit 1
|
[ "${cntpost}" != "${cntpre}" ] && echo "import issue" && exit 1
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# import directory with named pipe
|
# import directory with named pipe
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -118,20 +121,20 @@ _EOF
|
|||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
d="${tmpd}/with_named_pipe"
|
d="${tmpd}/with_named_pipe"
|
||||||
mkdir -p ${d}
|
mkdir -p "${d}"
|
||||||
echo "file1" > ${d}/file1
|
echo "file1" > "${d}"/file1
|
||||||
echo "fil2" > ${d}/file2
|
echo "fil2" > "${d}"/file2
|
||||||
mkfifo ${d}/fifo
|
mkfifo "${d}"/fifo
|
||||||
|
|
||||||
# import
|
# import
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p2 -V ${d}
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p2 -V "${d}"
|
||||||
|
|
||||||
# ensure exists and is not link
|
# ensure exists and is not link
|
||||||
[ ! -d ${tmps}/dotfiles/${d} ] && echo "not a directory" && exit 1
|
[ ! -d "${tmps}"/dotfiles/"${d}" ] && echo "not a directory" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${d}/file1 ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${d}"/file1 ] && echo "not exist" && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/${d}/file2 ] && echo "not exist" && exit 1
|
[ ! -e "${tmps}"/dotfiles/"${d}"/file2 ] && echo "not exist" && exit 1
|
||||||
|
|
||||||
cat ${cfg} | grep ${d} >/dev/null 2>&1
|
cat "${cfg}" | grep "${d}" >/dev/null 2>&1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
63
tests-ng/imported-configs-variables.sh
vendored
63
tests-ng/imported-configs-variables.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -59,13 +62,13 @@ clear_on_exit "${tmpd}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
extcfg="${tmps}/ext-config.yaml"
|
extcfg="${tmps}/ext-config.yaml"
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
dotpath: dotfiles
|
dotpath: dotfiles
|
||||||
import_configs:
|
import_configs:
|
||||||
- $(basename ${extcfg})
|
- $(basename "${extcfg}")
|
||||||
variables:
|
variables:
|
||||||
varx: "test"
|
varx: "test"
|
||||||
provar: "local"
|
provar: "local"
|
||||||
@@ -87,10 +90,10 @@ profiles:
|
|||||||
dvarx: echo dprofvarx
|
dvarx: echo dprofvarx
|
||||||
dprovar: echo dprovar
|
dprovar: echo dprovar
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# create the external variables file
|
# create the external variables file
|
||||||
cat > ${extcfg} << _EOF
|
cat > "${extcfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
profiles:
|
profiles:
|
||||||
p2:
|
p2:
|
||||||
@@ -104,36 +107,36 @@ profiles:
|
|||||||
dprovar: echo extdprovar
|
dprovar: echo extdprovar
|
||||||
dotfiles:
|
dotfiles:
|
||||||
_EOF
|
_EOF
|
||||||
ls -l ${extcfg}
|
ls -l "${extcfg}"
|
||||||
cat ${extcfg}
|
cat "${extcfg}"
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "varx: {{@@ varx @@}}" > ${tmps}/dotfiles/abc
|
echo "varx: {{@@ varx @@}}" > "${tmps}"/dotfiles/abc
|
||||||
echo "provar: {{@@ provar @@}}" >> ${tmps}/dotfiles/abc
|
echo "provar: {{@@ provar @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "dvarx: {{@@ dvarx @@}}" >> ${tmps}/dotfiles/abc
|
echo "dvarx: {{@@ dvarx @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "dprovar: {{@@ dprovar@@}}" >> ${tmps}/dotfiles/abc
|
echo "dprovar: {{@@ dprovar@@}}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
#cat ${tmps}/dotfiles/abc
|
#cat ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p2 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p2 -V
|
||||||
|
|
||||||
echo "test1"
|
echo "test1"
|
||||||
cat ${tmpd}/abc
|
cat "${tmpd}"/abc
|
||||||
grep '^varx: extprofvarx' ${tmpd}/abc >/dev/null
|
grep '^varx: extprofvarx' "${tmpd}"/abc >/dev/null
|
||||||
grep '^provar: extprovar' ${tmpd}/abc >/dev/null
|
grep '^provar: extprovar' "${tmpd}"/abc >/dev/null
|
||||||
grep '^dvarx: extdprofvarx' ${tmpd}/abc >/dev/null
|
grep '^dvarx: extdprofvarx' "${tmpd}"/abc >/dev/null
|
||||||
grep '^dprovar: extdprovar' ${tmpd}/abc >/dev/null
|
grep '^dprovar: extdprovar' "${tmpd}"/abc >/dev/null
|
||||||
|
|
||||||
rm -f ${tmpd}/abc
|
rm -f "${tmpd}"/abc
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
echo "test2"
|
echo "test2"
|
||||||
cat ${tmpd}/abc
|
cat "${tmpd}"/abc
|
||||||
grep '^varx: profvarx' ${tmpd}/abc >/dev/null
|
grep '^varx: profvarx' "${tmpd}"/abc >/dev/null
|
||||||
grep '^provar: provar' ${tmpd}/abc >/dev/null
|
grep '^provar: provar' "${tmpd}"/abc >/dev/null
|
||||||
grep '^dvarx: dprofvarx' ${tmpd}/abc >/dev/null
|
grep '^dvarx: dprofvarx' "${tmpd}"/abc >/dev/null
|
||||||
grep '^dprovar: dprovar' ${tmpd}/abc >/dev/null
|
grep '^dprovar: dprovar' "${tmpd}"/abc >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
29
tests-ng/imported-variables-from-config.sh
vendored
29
tests-ng/imported-variables-from-config.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
@@ -59,7 +62,7 @@ clear_on_exit "${tmpd}"
|
|||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
subcfg="${tmps}/subconfig.yaml"
|
subcfg="${tmps}/subconfig.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -75,10 +78,10 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# create the subconfig file
|
# create the subconfig file
|
||||||
cat > ${subcfg} << _EOF
|
cat > "${subcfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -92,13 +95,13 @@ profiles: []
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
dirname ${tmps}/dotfiles/abc | xargs mkdir -p
|
dirname "${tmps}"/dotfiles/abc | xargs mkdir -p
|
||||||
cat > ${tmps}/dotfiles/abc << _EOF
|
cat > "${tmps}"/dotfiles/abc << _EOF
|
||||||
Hell yeah
|
Hell yeah
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# test file existence and content
|
# test file existence and content
|
||||||
[ -f "${tmpd}/abc" ] || {
|
[ -f "${tmpd}/abc" ] || {
|
||||||
|
|||||||
121
tests-ng/include-actions.sh
vendored
121
tests-ng/include-actions.sh
vendored
@@ -29,31 +29,34 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
# the action temp
|
# the action temp
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
@@ -62,7 +65,7 @@ clear_on_exit "${tmpa}"
|
|||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
actions:
|
actions:
|
||||||
pre:
|
pre:
|
||||||
preaction: echo 'pre' >> ${tmpa}/pre
|
preaction: echo 'pre' >> ${tmpa}/pre
|
||||||
@@ -103,109 +106,109 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
mkdir -p ${tmps}/dotfiles/
|
mkdir -p "${tmps}"/dotfiles/
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
echo "PROFILE p2"
|
echo "PROFILE p2"
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p2 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p2 -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpa}/pre ] && echo "pre not found" && exit 1
|
[ ! -e "${tmpa}"/pre ] && echo "pre not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/pre | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/pre | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "pre executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "pre executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/pre2 ] && echo "pre2 not found" && exit 1
|
[ ! -e "${tmpa}"/pre2 ] && echo "pre2 not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/pre2 | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/pre2 | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "pre2 executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "pre2 executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/post ] && echo "post not found" && exit 1
|
[ ! -e "${tmpa}"/post ] && echo "post not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/post | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/post | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "post executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "post executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/post2 ] && echo "post2 not found" && exit 1
|
[ ! -e "${tmpa}"/post2 ] && echo "post2 not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/post2 | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/post2 | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "post2 executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "post2 executed multiple times" && exit 1
|
||||||
|
|
||||||
# install
|
# install
|
||||||
rm -f ${tmpa}/pre ${tmpa}/pre2 ${tmpa}/post ${tmpa}/post2 ${tmpa}/naked
|
rm -f "${tmpa}"/pre "${tmpa}"/pre2 "${tmpa}"/post "${tmpa}"/post2 "${tmpa}"/naked
|
||||||
rm -f ${tmpd}/abc
|
rm -f "${tmpd}"/abc
|
||||||
echo "PROFILE p3"
|
echo "PROFILE p3"
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p3 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p3 -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpa}/pre ] && echo "pre not found" && exit 1
|
[ ! -e "${tmpa}"/pre ] && echo "pre not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/pre | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/pre | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "pre executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "pre executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/pre2 ] && echo "pre2 not found" && exit 1
|
[ ! -e "${tmpa}"/pre2 ] && echo "pre2 not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/pre2 | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/pre2 | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "pre2 executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "pre2 executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/post ] && echo "post not found" && exit 1
|
[ ! -e "${tmpa}"/post ] && echo "post not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/post | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/post | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "post executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "post executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/post2 ] && echo "post2 not found" && exit 1
|
[ ! -e "${tmpa}"/post2 ] && echo "post2 not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/post2 | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/post2 | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "post2 executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "post2 executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/naked ] && echo "naked not found" && exit 1
|
[ ! -e "${tmpa}"/naked ] && echo "naked not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/naked | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/naked | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "naked executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "naked executed multiple times" && exit 1
|
||||||
|
|
||||||
# install
|
# install
|
||||||
rm -f ${tmpa}/pre ${tmpa}/pre2 ${tmpa}/post ${tmpa}/post2 ${tmpa}/naked
|
rm -f "${tmpa}"/pre "${tmpa}"/pre2 "${tmpa}"/post "${tmpa}"/post2 "${tmpa}"/naked
|
||||||
rm -f ${tmpd}/abc
|
rm -f "${tmpd}"/abc
|
||||||
echo "PROFILE p0"
|
echo "PROFILE p0"
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p0 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p0 -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpa}/pre ] && echo "pre not found" && exit 1
|
[ ! -e "${tmpa}"/pre ] && echo "pre not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/pre | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/pre | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "pre executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "pre executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/pre2 ] && echo "pre2 not found" && exit 1
|
[ ! -e "${tmpa}"/pre2 ] && echo "pre2 not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/pre2 | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/pre2 | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "pre2 executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "pre2 executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/post ] && echo "post not found" && exit 1
|
[ ! -e "${tmpa}"/post ] && echo "post not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/post | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/post | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "post executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "post executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/post2 ] && echo "post2 not found" && exit 1
|
[ ! -e "${tmpa}"/post2 ] && echo "post2 not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/post2 | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/post2 | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "post2 executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "post2 executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/naked ] && echo "naked not found" && exit 1
|
[ ! -e "${tmpa}"/naked ] && echo "naked not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/naked | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/naked | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "naked executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "naked executed multiple times" && exit 1
|
||||||
|
|
||||||
# install without verbose
|
# install without verbose
|
||||||
rm -f ${tmpa}/pre ${tmpa}/pre2 ${tmpa}/post ${tmpa}/post2 ${tmpa}/naked
|
rm -f "${tmpa}"/pre "${tmpa}"/pre2 "${tmpa}"/post "${tmpa}"/post2 "${tmpa}"/naked
|
||||||
rm -f ${tmpd}/abc
|
rm -f "${tmpd}"/abc
|
||||||
echo "PROFILE p0 without verbose"
|
echo "PROFILE p0 without verbose"
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p0
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p0
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpa}/pre ] && echo "pre not found" && exit 1
|
[ ! -e "${tmpa}"/pre ] && echo "pre not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/pre | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/pre | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "pre executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "pre executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/pre2 ] && echo "pre2 not found" && exit 1
|
[ ! -e "${tmpa}"/pre2 ] && echo "pre2 not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/pre2 | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/pre2 | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "pre2 executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "pre2 executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/post ] && echo "post not found" && exit 1
|
[ ! -e "${tmpa}"/post ] && echo "post not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/post | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/post | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "post executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "post executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/post2 ] && echo "post2 not found" && exit 1
|
[ ! -e "${tmpa}"/post2 ] && echo "post2 not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/post2 | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/post2 | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "post2 executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "post2 executed multiple times" && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpa}/naked ] && echo "naked not found" && exit 1
|
[ ! -e "${tmpa}"/naked ] && echo "naked not found" && exit 1
|
||||||
nb=`wc -l ${tmpa}/naked | awk '{print $1}'`
|
nb=$(wc -l "${tmpa}"/naked | awk '{print $1}')
|
||||||
[ "${nb}" != "1" ] && echo "naked executed multiple times" && exit 1
|
[ "${nb}" != "1" ] && echo "naked executed multiple times" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
51
tests-ng/include-order.sh
vendored
51
tests-ng/include-order.sh
vendored
@@ -29,31 +29,34 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
# temporary
|
# temporary
|
||||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpa=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
@@ -63,7 +66,7 @@ export DOTDROP_WORKERS=1
|
|||||||
# 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
|
||||||
@@ -105,24 +108,24 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
mkdir -p ${tmps}/dotfiles/
|
mkdir -p "${tmps}"/dotfiles/
|
||||||
echo "first" > ${tmps}/dotfiles/first
|
echo "first" > "${tmps}"/dotfiles/first
|
||||||
echo "second" > ${tmps}/dotfiles/second
|
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
|
||||||
|
|
||||||
# checks timestamp
|
# checks timestamp
|
||||||
echo "first timestamp: `stat -c %y ${tmpd}/first`"
|
echo "first timestamp: $(stat -c %y "${tmpd}"/first)"
|
||||||
echo "second timestamp: `stat -c %y ${tmpd}/second`"
|
echo "second timestamp: $(stat -c %y "${tmpd}"/second)"
|
||||||
echo "third timestamp: `stat -c %y ${tmpd}/third`"
|
echo "third timestamp: $(stat -c %y "${tmpd}"/third)"
|
||||||
|
|
||||||
ts_first=`date "+%s" -d "$(stat -c %y ${tmpd}/first)"`
|
ts_first=$(date "+%s" -d "$(stat -c %y "${tmpd}"/first)")
|
||||||
ts_second=`date "+%s" -d "$(stat -c %y ${tmpd}/second)"`
|
ts_second=$(date "+%s" -d "$(stat -c %y "${tmpd}"/second)")
|
||||||
ts_third=`date "+%s" -d "$(stat -c %y ${tmpd}/third)"`
|
ts_third=$(date "+%s" -d "$(stat -c %y "${tmpd}"/third)")
|
||||||
|
|
||||||
#echo "first ts: ${ts_first}"
|
#echo "first ts: ${ts_first}"
|
||||||
#echo "second ts: ${ts_second}"
|
#echo "second ts: ${ts_second}"
|
||||||
@@ -132,13 +135,13 @@ for ((i=0;i<${attempts};i++)); do
|
|||||||
[ "${ts_second}" -ge "${ts_third}" ] && echo "third created before second" && exit 1
|
[ "${ts_second}" -ge "${ts_third}" ] && echo "third created before second" && exit 1
|
||||||
|
|
||||||
# check cookie
|
# check cookie
|
||||||
cat ${tmpa}/cookie
|
cat "${tmpa}"/cookie
|
||||||
content=`cat ${tmpa}/cookie | xargs`
|
content=$(cat "${tmpa}"/cookie | xargs)
|
||||||
[ "${content}" != "first second third" ] && echo "bad cookie" && exit 1
|
[ "${content}" != "first second third" ] && echo "bad cookie" && exit 1
|
||||||
|
|
||||||
# clean
|
# clean
|
||||||
rm ${tmpa}/cookie
|
rm "${tmpa}"/cookie
|
||||||
rm ${tmpd}/first ${tmpd}/second ${tmpd}/third
|
rm "${tmpd}"/first "${tmpd}"/second "${tmpd}"/third
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
35
tests-ng/include-variables.sh
vendored
35
tests-ng/include-variables.sh
vendored
@@ -29,29 +29,32 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
@@ -59,7 +62,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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,18 +94,18 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
mkdir -p ${tmps}/dotfiles/
|
mkdir -p "${tmps}"/dotfiles/
|
||||||
echo "head" > ${tmps}/dotfiles/abc
|
echo "head" > "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ var @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ var @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ dvar @@}}" >> ${tmps}/dotfiles/abc
|
echo "{{@@ dvar @@}}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "tail" >> ${tmps}/dotfiles/abc
|
echo "tail" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p0 --verbose
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p0 --verbose
|
||||||
|
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
grep 'p0v' ${tmpd}/abc
|
grep 'p0v' "${tmpd}"/abc
|
||||||
grep 'p0dv' ${tmpd}/abc
|
grep 'p0dv' "${tmpd}"/abc
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
51
tests-ng/include.sh
vendored
51
tests-ng/include.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
@@ -58,7 +61,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -89,35 +92,35 @@ profiles:
|
|||||||
include:
|
include:
|
||||||
- p2
|
- p2
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
mkdir -p ${tmps}/dotfiles/
|
mkdir -p "${tmps}"/dotfiles/
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p0 --verbose
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p0 --verbose
|
||||||
|
|
||||||
[ ! -e ${tmpd}/action.pre ] && exit 1
|
[ ! -e "${tmpd}"/action.pre ] && exit 1
|
||||||
[ ! -e ${tmpd}/action.post ] && exit 1
|
[ ! -e "${tmpd}"/action.post ] && exit 1
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p1
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p2
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p2
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p3
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p3
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p0
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p0
|
||||||
|
|
||||||
# list
|
# list
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 | grep f_abc
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 | grep f_abc
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p2 | grep f_abc
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p2 | grep f_abc
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p3 | grep f_abc
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p3 | grep f_abc
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p0 | grep f_abc
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p0 | grep f_abc
|
||||||
|
|
||||||
cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p0 | grep f_abc | wc -l`
|
cnt=$(cd "${ddpath}" | ${bin} files -c "${cfg}" -p p0 | grep f_abc | wc -l)
|
||||||
[ "${cnt}" != "1" ] && echo "dotfiles displayed more than once" && exit 1
|
[ "${cnt}" != "1" ] && echo "dotfiles displayed more than once" && exit 1
|
||||||
|
|
||||||
# count
|
# count
|
||||||
cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -b | grep '^f_' | wc -l`
|
cnt=$(cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -b | grep '^f_' | wc -l)
|
||||||
[ "${cnt}" != "1" ] && exit 1
|
[ "${cnt}" != "1" ] && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
85
tests-ng/inst-link-default.sh
vendored
85
tests-ng/inst-link-default.sh
vendored
@@ -28,45 +28,48 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmps}/dotfiles/abc
|
mkdir -p "${tmps}"/dotfiles/abc
|
||||||
echo "test link_dotfile_default 1" > ${tmps}/dotfiles/abc/file1
|
echo "test link_dotfile_default 1" > "${tmps}"/dotfiles/abc/file1
|
||||||
echo "test link_dotfile_default 2" > ${tmps}/dotfiles/abc/file2
|
echo "test link_dotfile_default 2" > "${tmps}"/dotfiles/abc/file2
|
||||||
echo "should be linked" > ${tmps}/dotfiles/def
|
echo "should be linked" > "${tmps}"/dotfiles/def
|
||||||
|
|
||||||
# create a shell script
|
# create a shell script
|
||||||
# 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
|
||||||
@@ -84,19 +87,19 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# ensure exists and is not link
|
# ensure exists and is not link
|
||||||
[ ! -d ${tmpd}/abc ] && echo "not a directory" && exit 1
|
[ ! -d "${tmpd}"/abc ] && echo "not a directory" && exit 1
|
||||||
[ -h ${tmpd}/abc ] && echo "not a regular file" && exit 1
|
[ -h "${tmpd}"/abc ] && echo "not a regular file" && exit 1
|
||||||
[ ! -e ${tmpd}/abc/file1 ] && echo "not exist" && exit 1
|
[ ! -e "${tmpd}"/abc/file1 ] && echo "not exist" && exit 1
|
||||||
[ -h ${tmpd}/abc/file1 ] && echo "not a regular file" && exit 1
|
[ -h "${tmpd}"/abc/file1 ] && echo "not a regular file" && exit 1
|
||||||
[ ! -e ${tmpd}/abc/file2 ] && echo "not exist" && exit 1
|
[ ! -e "${tmpd}"/abc/file2 ] && echo "not exist" && exit 1
|
||||||
[ -h ${tmpd}/abc/file2 ] && echo "not a regular file" && exit 1
|
[ -h "${tmpd}"/abc/file2 ] && echo "not a regular file" && exit 1
|
||||||
rm -rf ${tmpd}/abc
|
rm -rf "${tmpd}"/abc
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -117,23 +120,23 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# ensure exists and parent is a link
|
# ensure exists and parent is a link
|
||||||
[ ! -e ${tmpd}/abc ] && echo "not exist" && exit 1
|
[ ! -e "${tmpd}"/abc ] && echo "not exist" && exit 1
|
||||||
[ ! -h ${tmpd}/abc ] && echo "not a symlink" && exit 1
|
[ ! -h "${tmpd}"/abc ] && echo "not a symlink" && exit 1
|
||||||
[ ! -e ${tmpd}/abc/file1 ] && echo "not exist" && exit 1
|
[ ! -e "${tmpd}"/abc/file1 ] && echo "not exist" && exit 1
|
||||||
[ -h ${tmpd}/abc/file1 ] && echo "not a regular file" && exit 1
|
[ -h "${tmpd}"/abc/file1 ] && echo "not a regular file" && exit 1
|
||||||
[ ! -e ${tmpd}/abc/file2 ] && echo "not exist" && exit 1
|
[ ! -e "${tmpd}"/abc/file2 ] && echo "not exist" && exit 1
|
||||||
[ -h ${tmpd}/abc/file2 ] && echo "not a regular file" && exit 1
|
[ -h "${tmpd}"/abc/file2 ] && echo "not a regular file" && exit 1
|
||||||
rm -rf ${tmpd}/abc
|
rm -rf "${tmpd}"/abc
|
||||||
|
|
||||||
[ ! -e ${tmpd}/def ] && echo "not exist" && exit 1
|
[ ! -e "${tmpd}"/def ] && echo "not exist" && exit 1
|
||||||
[ ! -h ${tmpd}/def ] && echo "not a symlink" && exit 1
|
[ ! -h "${tmpd}"/def ] && echo "not a symlink" && exit 1
|
||||||
rm -f ${tmpd}/def
|
rm -f "${tmpd}"/def
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -150,17 +153,17 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# ensure exists and children are links
|
# ensure exists and children are links
|
||||||
[ ! -e ${tmpd}/abc ] && echo "not exist" && exit 1
|
[ ! -e "${tmpd}"/abc ] && echo "not exist" && exit 1
|
||||||
[ -h ${tmpd}/abc ] && echo "not a regular file" && exit 1
|
[ -h "${tmpd}"/abc ] && echo "not a regular file" && exit 1
|
||||||
[ ! -e ${tmpd}/abc/file1 ] && echo "not exist" && exit 1
|
[ ! -e "${tmpd}"/abc/file1 ] && echo "not exist" && exit 1
|
||||||
[ ! -h ${tmpd}/abc/file1 ] && echo "not a symlink" && exit 1
|
[ ! -h "${tmpd}"/abc/file1 ] && echo "not a symlink" && exit 1
|
||||||
[ ! -e ${tmpd}/abc/file2 ] && echo "not exist" && exit 1
|
[ ! -e "${tmpd}"/abc/file2 ] && echo "not exist" && exit 1
|
||||||
[ ! -h ${tmpd}/abc/file2 ] && echo "not a symlink" && exit 1
|
[ ! -h "${tmpd}"/abc/file2 ] && echo "not a symlink" && exit 1
|
||||||
rm -rf ${tmpd}/abc
|
rm -rf "${tmpd}"/abc
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
17
tests-ng/install-empty.sh
vendored
17
tests-ng/install-empty.sh
vendored
@@ -28,26 +28,29 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
@@ -55,7 +58,7 @@ clear_on_exit "${basedir}"
|
|||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -89,7 +92,7 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
echo "[+] install"
|
echo "[+] install"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 --verbose | grep '^5 dotfile(s) installed.$'
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p1 --verbose | grep '^5 dotfile(s) installed.$'
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
131
tests-ng/install-ignore.sh
vendored
131
tests-ng/install-ignore.sh
vendored
@@ -28,105 +28,108 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
tmps="${basedir}"
|
tmps="${basedir}"
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# some files
|
# some files
|
||||||
mkdir -p ${tmpd}/{program,config,vscode}
|
mkdir -p "${tmpd}"/{program,config,vscode}
|
||||||
echo "some data" > ${tmpd}/program/a
|
echo "some data" > "${tmpd}"/program/a
|
||||||
echo "some data" > ${tmpd}/config/a
|
echo "some data" > "${tmpd}"/config/a
|
||||||
echo "some data" > ${tmpd}/vscode/extensions.txt
|
echo "some data" > "${tmpd}"/vscode/extensions.txt
|
||||||
echo "some data" > ${tmpd}/vscode/keybindings.json
|
echo "some data" > "${tmpd}"/vscode/keybindings.json
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/program
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/program
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/config
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/config
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/vscode
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/vscode
|
||||||
|
|
||||||
# add files on filesystem
|
# add files on filesystem
|
||||||
echo "[+] add files"
|
echo "[+] add files"
|
||||||
echo "new data" > ${basedir}/dotfiles/${tmpd}/README.md
|
echo "new data" > "${basedir}"/dotfiles/"${tmpd}"/README.md
|
||||||
echo "new data" > ${basedir}/dotfiles/${tmpd}/vscode/README.md
|
echo "new data" > "${basedir}"/dotfiles/"${tmpd}"/vscode/README.md
|
||||||
echo "new data" > ${basedir}/dotfiles/${tmpd}/program/README.md
|
echo "new data" > "${basedir}"/dotfiles/"${tmpd}"/program/README.md
|
||||||
mkdir -p ${basedir}/dotfiles/${tmpd}/readmes
|
mkdir -p "${basedir}"/dotfiles/"${tmpd}"/readmes
|
||||||
echo "new data" > ${basedir}/dotfiles/${tmpd}/readmes/README.md
|
echo "new data" > "${basedir}"/dotfiles/"${tmpd}"/readmes/README.md
|
||||||
|
|
||||||
# install
|
# install
|
||||||
rm -rf ${tmpd}
|
rm -rf "${tmpd}"
|
||||||
echo "[+] install normal"
|
echo "[+] install normal"
|
||||||
cd ${ddpath} | ${bin} install --showdiff -c ${cfg} --verbose -f
|
cd "${ddpath}" | ${bin} install --showdiff -c "${cfg}" --verbose -f
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
nb=`find ${tmpd} -iname 'README.md' | wc -l`
|
nb=$(find "${tmpd}" -iname 'README.md' | wc -l)
|
||||||
echo "(1) found ${nb} README.md file(s)"
|
echo "(1) found ${nb} README.md file(s)"
|
||||||
[ "${nb}" != "2" ] && exit 1
|
[ "${nb}" != "2" ] && exit 1
|
||||||
|
|
||||||
# adding ignore in dotfile
|
# adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/d_program:/a \ \ \ \ instignore:\n\ \ \ \ - "README.md"' ${cfg} > ${cfg2}
|
sed '/d_program:/a \ \ \ \ instignore:\n\ \ \ \ - "README.md"' "${cfg}" > "${cfg2}"
|
||||||
cat ${cfg2}
|
cat "${cfg2}"
|
||||||
|
|
||||||
# install
|
# install
|
||||||
rm -rf ${tmpd}
|
rm -rf "${tmpd}"
|
||||||
echo "[+] install with ignore in dotfile"
|
echo "[+] install with ignore in dotfile"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg2} --verbose -f
|
cd "${ddpath}" | ${bin} install -c "${cfg2}" --verbose -f
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
nb=`find ${tmpd} -iname 'README.md' | wc -l`
|
nb=$(find "${tmpd}" -iname 'README.md' | wc -l)
|
||||||
echo "(2) found ${nb} README.md file(s)"
|
echo "(2) found ${nb} README.md file(s)"
|
||||||
[ "${nb}" != "1" ] && exit 1
|
[ "${nb}" != "1" ] && exit 1
|
||||||
|
|
||||||
# adding ignore in config
|
# adding ignore in config
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/^config:/a \ \ instignore:\n\ \ - "README.md"' ${cfg} > ${cfg2}
|
sed '/^config:/a \ \ instignore:\n\ \ - "README.md"' "${cfg}" > "${cfg2}"
|
||||||
cat ${cfg2}
|
cat "${cfg2}"
|
||||||
|
|
||||||
# install
|
# install
|
||||||
rm -rf ${tmpd}
|
rm -rf "${tmpd}"
|
||||||
echo "[+] install with ignore in config"
|
echo "[+] install with ignore in config"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg2} --verbose -f
|
cd "${ddpath}" | ${bin} install -c "${cfg2}" --verbose -f
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
nb=`find ${tmpd} -iname 'README.md' | wc -l`
|
nb=$(find "${tmpd}" -iname 'README.md' | wc -l)
|
||||||
echo "(3) found ${nb} README.md file(s)"
|
echo "(3) found ${nb} README.md file(s)"
|
||||||
[ "${nb}" != "0" ] && exit 1
|
[ "${nb}" != "0" ] && exit 1
|
||||||
|
|
||||||
## reinstall to trigger showdiff
|
## reinstall to trigger showdiff
|
||||||
echo "showdiff" > ${tmpd}/program/a
|
echo "showdiff" > "${tmpd}"/program/a
|
||||||
cd ${ddpath} | echo "y" | ${bin} install --showdiff -c ${cfg} --verbose -f
|
cd "${ddpath}" | echo "y" | ${bin} install --showdiff -c "${cfg}" --verbose -f
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
# test templated subdir
|
# test templated subdir
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -135,52 +138,52 @@ dotfiles:
|
|||||||
profiles:
|
profiles:
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
mkdir -p ${tmpd}/nvim
|
mkdir -p "${tmpd}"/nvim
|
||||||
mkdir -p ${tmpd}/nvim/dir1
|
mkdir -p "${tmpd}"/nvim/dir1
|
||||||
echo "f1" > ${tmpd}/nvim/dir1/file1
|
echo "f1" > "${tmpd}"/nvim/dir1/file1
|
||||||
mkdir -p ${tmpd}/nvim/dir2
|
mkdir -p "${tmpd}"/nvim/dir2
|
||||||
echo "f1" > ${tmpd}/nvim/dir2/file2
|
echo "f1" > "${tmpd}"/nvim/dir2/file2
|
||||||
echo "ftop" > ${tmpd}/nvim/ftop
|
echo "ftop" > "${tmpd}"/nvim/ftop
|
||||||
|
|
||||||
echo "[+] import top"
|
echo "[+] import top"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -l link_children -p p1 ${tmpd}/nvim
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -l link_children -p p1 "${tmpd}"/nvim
|
||||||
|
|
||||||
# add sub dir
|
# add sub dir
|
||||||
mkdir -p ${tmpd}/nvim/templated
|
mkdir -p "${tmpd}"/nvim/templated
|
||||||
echo "noprofile" > ${tmpd}/nvim/templated/ftemplated
|
echo "noprofile" > "${tmpd}"/nvim/templated/ftemplated
|
||||||
echo "noprofile" > ${tmpd}/nvim/template
|
echo "noprofile" > "${tmpd}"/nvim/template
|
||||||
|
|
||||||
echo "[+] import sub"
|
echo "[+] import sub"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${tmpd}/nvim/templated
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 "${tmpd}"/nvim/templated
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${tmpd}/nvim/template
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 "${tmpd}"/nvim/template
|
||||||
|
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/d_nvim:/a \ \ \ \ instignore:\n\ \ \ \ - "*template*"' ${cfg} > ${cfg2}
|
sed '/d_nvim:/a \ \ \ \ instignore:\n\ \ \ \ - "*template*"' "${cfg}" > "${cfg2}"
|
||||||
cat ${cfg2}
|
cat "${cfg2}"
|
||||||
|
|
||||||
## clean destination files
|
## clean destination files
|
||||||
rm -rf ${tmpd}/nvim
|
rm -rf "${tmpd}"/nvim
|
||||||
## patch template file
|
## patch template file
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/${tmpd}/nvim/templated/ftemplated
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/"${tmpd}"/nvim/templated/ftemplated
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/${tmpd}/nvim/template
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/"${tmpd}"/nvim/template
|
||||||
|
|
||||||
echo "[+] install link_children"
|
echo "[+] install link_children"
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg2} -p p1 -V d_nvim
|
cd "${ddpath}" | ${bin} install -f -c "${cfg2}" -p p1 -V d_nvim
|
||||||
|
|
||||||
[ -d ${tmpd}/nvim/templated ] && echo "templated should not be installed" && exit 1
|
[ -d "${tmpd}"/nvim/templated ] && echo "templated should not be installed" && exit 1
|
||||||
[ -e ${tmpd}/nvim/templated/ftemplated ] && echo "templated file should not be installed" && exit 1
|
[ -e "${tmpd}"/nvim/templated/ftemplated ] && echo "templated file should not be installed" && exit 1
|
||||||
[ -e ${tmpd}/nvim/template ] && echo "template file should not be installed" && exit 1
|
[ -e "${tmpd}"/nvim/template ] && echo "template file should not be installed" && exit 1
|
||||||
|
|
||||||
echo "[+] install sub"
|
echo "[+] install sub"
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg2} -p p1 -V d_templated
|
cd "${ddpath}" | ${bin} install -f -c "${cfg2}" -p p1 -V d_templated
|
||||||
echo "[+] install template"
|
echo "[+] install template"
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg2} -p p1 -V f_template
|
cd "${ddpath}" | ${bin} install -f -c "${cfg2}" -p p1 -V f_template
|
||||||
|
|
||||||
[ ! -d ${tmpd}/nvim/templated ] && echo "templated not installed" && exit 1
|
[ ! -d "${tmpd}"/nvim/templated ] && echo "templated not installed" && exit 1
|
||||||
[ ! -e ${tmpd}/nvim/templated/ftemplated ] && echo "templated file not installed" && exit 1
|
[ ! -e "${tmpd}"/nvim/templated/ftemplated ] && echo "templated file not installed" && exit 1
|
||||||
[ ! -e ${tmpd}/nvim/template ] && echo "template file not installed" && exit 1
|
[ ! -e "${tmpd}"/nvim/template ] && echo "template file not installed" && exit 1
|
||||||
grep 'p1' ${tmpd}/nvim/templated/ftemplated
|
grep 'p1' "${tmpd}"/nvim/templated/ftemplated
|
||||||
grep 'p1' ${tmpd}/nvim/template
|
grep 'p1' "${tmpd}"/nvim/template
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
57
tests-ng/install-link-children.sh
vendored
57
tests-ng/install-link-children.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -59,7 +62,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -80,34 +83,34 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir ${tmps}/dotfiles/dir1
|
mkdir "${tmps}"/dotfiles/dir1
|
||||||
mkdir ${tmps}/dotfiles/dir1/empty
|
mkdir "${tmps}"/dotfiles/dir1/empty
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dir1/empty/this.ignore
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dir1/empty/this.ignore
|
||||||
mkdir ${tmps}/dotfiles/dir1/not-empty
|
mkdir "${tmps}"/dotfiles/dir1/not-empty
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dir1/not-empty/file
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dir1/not-empty/file
|
||||||
mkdir ${tmps}/dotfiles/dir1/sub
|
mkdir "${tmps}"/dotfiles/dir1/sub
|
||||||
mkdir ${tmps}/dotfiles/dir1/sub/empty
|
mkdir "${tmps}"/dotfiles/dir1/sub/empty
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/dir1/sub/empty/that.ignore
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/dir1/sub/empty/that.ignore
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# check normal
|
# check normal
|
||||||
[ ! -d ${tmpd}/dir1 ] && exit 1
|
[ ! -d "${tmpd}"/dir1 ] && exit 1
|
||||||
[ -d ${tmpd}/dir1/empty ] && exit 1
|
[ -d "${tmpd}"/dir1/empty ] && exit 1
|
||||||
[ -d ${tmpd}/dir1/sub ] && exit 1
|
[ -d "${tmpd}"/dir1/sub ] && exit 1
|
||||||
[ -d ${tmpd}/dir1/sub/empty ] && exit 1
|
[ -d "${tmpd}"/dir1/sub/empty ] && exit 1
|
||||||
[ ! -d ${tmpd}/dir1/not-empty ] && exit 1
|
[ ! -d "${tmpd}"/dir1/not-empty ] && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpd}/dir1/not-empty/file ] && exit 1
|
[ ! -e "${tmpd}"/dir1/not-empty/file ] && exit 1
|
||||||
|
|
||||||
# ignored files
|
# ignored files
|
||||||
[ -e ${tmpd}/dir1/empty/this.ignore ] && exit 1
|
[ -e "${tmpd}"/dir1/empty/this.ignore ] && exit 1
|
||||||
[ -e ${tmpd}/dir1/sub/empty/that.ignore ] && exit 1
|
[ -e "${tmpd}"/dir1/sub/empty/that.ignore ] && exit 1
|
||||||
|
|
||||||
cat ${tmpd}/dir1/not-empty/file
|
cat "${tmpd}"/dir1/not-empty/file
|
||||||
grep "p1" ${tmpd}/dir1/not-empty/file
|
grep "p1" "${tmpd}"/dir1/not-empty/file
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
78
tests-ng/install-negative-ignore.sh
vendored
78
tests-ng/install-negative-ignore.sh
vendored
@@ -9,41 +9,12 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# all this crap to get current path
|
# all this crap to get current path
|
||||||
if [ $(uname) = Darwin ]; then
|
rl="readlink -f"
|
||||||
# Unfortunately, readlink works differently on macOS than it does on GNU/Linux
|
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
||||||
# (the -f option behaves differently) and the realpath command does not exist.
|
rl="realpath"
|
||||||
# Workarounds I find on the Internet suggest just using Homebrew to install coreutils
|
|
||||||
# so you can get the GNU coreutils on your Mac. But, I don't want this script to
|
|
||||||
# assume (a) users have Homebrew installed and (b) if they have Homebrew installed, that
|
|
||||||
# they then installed the GNU coreutils.
|
|
||||||
readlink() {
|
|
||||||
TARGET_FILE=$1
|
|
||||||
|
|
||||||
cd `dirname $TARGET_FILE`
|
if ! hash ${rl}; then
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
echo "\"${rl}\" not found !" && exit 1
|
||||||
|
|
||||||
# Iterate down a (possible) chain of symlinks
|
|
||||||
while [ -L "$TARGET_FILE" ]; do
|
|
||||||
TARGET_FILE=`readlink $TARGET_FILE`
|
|
||||||
cd `dirname $TARGET_FILE`
|
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
|
||||||
done
|
|
||||||
|
|
||||||
# Compute the canonicalized name by finding the physical path
|
|
||||||
# for the directory we're in and appending the target file.
|
|
||||||
PHYS_DIR=`pwd -P`
|
|
||||||
RESULT=$PHYS_DIR/$TARGET_FILE
|
|
||||||
echo $RESULT
|
|
||||||
}
|
|
||||||
rl="readlink"
|
|
||||||
else
|
|
||||||
rl="readlink -f"
|
|
||||||
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
|
||||||
rl="realpath"
|
|
||||||
|
|
||||||
if ! hash ${rl}; then
|
|
||||||
echo "\"${rl}\" not found !" && exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cur=$(dirname "$(${rl} "${0}")")
|
cur=$(dirname "$(${rl} "${0}")")
|
||||||
@@ -51,48 +22,51 @@ cur=$(dirname "$(${rl} "${0}")")
|
|||||||
# dotdrop path can be pass as argument
|
# dotdrop path can be pass as argument
|
||||||
ddpath="${cur}/../"
|
ddpath="${cur}/../"
|
||||||
[ -n "${1}" ] && ddpath="${1}"
|
[ -n "${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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# some files
|
# some files
|
||||||
mkdir -p ${tmpd}/program/ignore_me
|
mkdir -p "${tmpd}"/program/ignore_me
|
||||||
echo "some data" > ${tmpd}/program/a
|
echo "some data" > "${tmpd}"/program/a
|
||||||
echo "some data" > ${tmpd}/program/ignore_me/b
|
echo "some data" > "${tmpd}"/program/ignore_me/b
|
||||||
echo "some data" > ${tmpd}/program/ignore_me/c
|
echo "some data" > "${tmpd}"/program/ignore_me/c
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/program
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/program
|
||||||
|
|
||||||
# adding ignore in dotfile
|
# adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
@@ -100,12 +74,12 @@ sed '/d_program:/a\
|
|||||||
\ \ \ \ instignore:\
|
\ \ \ \ instignore:\
|
||||||
\ \ \ \ - "*/ignore_me/*"\
|
\ \ \ \ - "*/ignore_me/*"\
|
||||||
\ \ \ \ - "!*/ignore_me/c"
|
\ \ \ \ - "!*/ignore_me/c"
|
||||||
' ${cfg} > ${cfg2}
|
' "${cfg}" > "${cfg2}"
|
||||||
|
|
||||||
# install
|
# install
|
||||||
rm -rf ${tmpd}
|
rm -rf "${tmpd}"
|
||||||
echo "[+] install with negative ignore in dotfile"
|
echo "[+] install with negative ignore in dotfile"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg2} --verbose
|
cd "${ddpath}" | ${bin} install -c "${cfg2}" --verbose
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
echo '(1) expect structure to be
|
echo '(1) expect structure to be
|
||||||
.
|
.
|
||||||
@@ -114,11 +88,11 @@ echo '(1) expect structure to be
|
|||||||
└── ignore_me
|
└── ignore_me
|
||||||
└── c'
|
└── c'
|
||||||
|
|
||||||
[[ -n "$(find ${tmpd}/program -name a)" ]] || exit 1
|
[[ -n "$(find "${tmpd}"/program -name a)" ]] || exit 1
|
||||||
echo "(1) found program/a ... good"
|
echo "(1) found program/a ... good"
|
||||||
[[ -n "$(find ${tmpd}/program/ignore_me -name b)" ]] && exit 1
|
[[ -n "$(find "${tmpd}"/program/ignore_me -name b)" ]] && exit 1
|
||||||
echo "(1) didn't find program/b ... good"
|
echo "(1) didn't find program/b ... good"
|
||||||
[[ -n "$(find ${tmpd}/program/ignore_me -name c)" ]] || exit 1
|
[[ -n "$(find "${tmpd}"/program/ignore_me -name c)" ]] || exit 1
|
||||||
echo "(1) found program/c ... good"
|
echo "(1) found program/c ... good"
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
31
tests-ng/install-to-temp.sh
vendored
31
tests-ng/install-to-temp.sh
vendored
@@ -28,28 +28,31 @@ 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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
mkdir -p ${basedir}/dotfiles
|
mkdir -p "${basedir}"/dotfiles
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
@@ -58,7 +61,7 @@ clear_on_exit "${tmpd}"
|
|||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -82,19 +85,19 @@ profiles:
|
|||||||
- f_z
|
- f_z
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
echo 'test_x' > ${basedir}/dotfiles/x
|
echo 'test_x' > "${basedir}"/dotfiles/x
|
||||||
echo 'test_y' > ${basedir}/dotfiles/y
|
echo 'test_y' > "${basedir}"/dotfiles/y
|
||||||
echo "00000000 01 02 03 04 05" | xxd -r - ${basedir}/dotfiles/z
|
echo "00000000 01 02 03 04 05" | xxd -r - "${basedir}"/dotfiles/z
|
||||||
|
|
||||||
echo "[+] install"
|
echo "[+] install"
|
||||||
log="${basedir}/log"
|
log="${basedir}/log"
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 --showdiff --verbose --temp > ${log}
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --showdiff --verbose --temp > "${log}"
|
||||||
|
|
||||||
tmpfile=`cat ${basedir}/log | grep 'installed to tmp ' | sed 's/^.*to tmp "\(.*\)"./\1/'`
|
tmpfile=$(cat "${basedir}"/log | grep 'installed to tmp ' | sed 's/^.*to tmp "\(.*\)"./\1/')
|
||||||
echo "tmpfile: ${tmpfile}"
|
echo "tmpfile: ${tmpfile}"
|
||||||
clear_on_exit "${tmpfile}"
|
clear_on_exit "${tmpfile}"
|
||||||
|
|
||||||
cat ${log} | grep '^3 dotfile(s) installed.$'
|
cat "${log}" | grep '^3 dotfile(s) installed.$'
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
36
tests-ng/install.sh
vendored
36
tests-ng/install.sh
vendored
@@ -32,7 +32,9 @@ ddpath="${cur}/../"
|
|||||||
|
|
||||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||||
bin="python3 -m dotdrop.dotdrop"
|
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 "dotdrop path: ${ddpath}"
|
||||||
echo "pythonpath: ${PYTHONPATH}"
|
echo "pythonpath: ${PYTHONPATH}"
|
||||||
@@ -40,7 +42,7 @@ echo "pythonpath: ${PYTHONPATH}"
|
|||||||
# get the helpers
|
# get the helpers
|
||||||
source ${cur}/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
|
# this is the test
|
||||||
@@ -61,25 +63,25 @@ has_rights()
|
|||||||
echo "testing ${1} is ${2}"
|
echo "testing ${1} is ${2}"
|
||||||
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
|
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
|
||||||
local mode=`stat -L -c '%a' "$1"`
|
local mode=`stat -L -c '%a' "$1"`
|
||||||
[ "${mode}" != "$2" ] && echo "bad mode for `basename $1` (${mode} VS expected ${2})" && exit 1
|
[ "${mode}" != "$2" ] && echo "bad mode for `basename "$1"` (${mode} VS expected ${2})" && exit 1
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
mkdir -p ${basedir}/dotfiles
|
mkdir -p "${basedir}"/dotfiles
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
echo "content" > ${basedir}/dotfiles/x
|
echo "content" > "${basedir}"/dotfiles/x
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -95,30 +97,30 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
echo "[+] install"
|
echo "[+] install"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 --verbose | grep '^1 dotfile(s) installed.$'
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p1 --verbose | grep '^1 dotfile(s) installed.$'
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
[ ! -e ${tmpd}/x ] && echo "f_x not installed" && exit 1
|
[ ! -e "${tmpd}"/x ] && echo "f_x not installed" && exit 1
|
||||||
|
|
||||||
# update chmod
|
# update chmod
|
||||||
chmod 666 ${tmpd}/x
|
chmod 666 "${tmpd}"/x
|
||||||
cd ${ddpath} | ${bin} update -c ${cfg} -f -p p1 --verbose ${tmpd}/x
|
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 --verbose "${tmpd}"/x
|
||||||
|
|
||||||
# chmod updated
|
# chmod updated
|
||||||
cat ${cfg} | grep "chmod: '666'"
|
cat "${cfg}" | grep "chmod: '666'"
|
||||||
|
|
||||||
chmod 644 ${tmpd}/x
|
chmod 644 "${tmpd}"/x
|
||||||
|
|
||||||
mode=`get_file_mode ${tmpd}/x`
|
mode=$(get_file_mode "${tmpd}"/x)
|
||||||
echo "[+] re-install with no"
|
echo "[+] re-install with no"
|
||||||
cd ${ddpath} | printf "N\n" | ${bin} install -c ${cfg} -p p1 --verbose
|
cd "${ddpath}" | printf "N\n" | ${bin} install -c "${cfg}" -p p1 --verbose
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
# if user answers N, chmod should not be done
|
# if user answers N, chmod should not be done
|
||||||
has_rights "${tmpd}/x" "${mode}"
|
has_rights "${tmpd}/x" "${mode}"
|
||||||
|
|
||||||
echo "[+] re-install with yes"
|
echo "[+] re-install with yes"
|
||||||
cd ${ddpath} | printf "y\n" | ${bin} install -c ${cfg} -p p1 --verbose
|
cd "${ddpath}" | printf "y\n" | ${bin} install -c "${cfg}" -p p1 --verbose
|
||||||
[ "$?" != "0" ] && exit 1
|
[ "$?" != "0" ] && exit 1
|
||||||
|
|
||||||
has_rights "${tmpd}/x" "666"
|
has_rights "${tmpd}/x" "666"
|
||||||
|
|||||||
57
tests-ng/jhelpers.sh
vendored
57
tests-ng/jhelpers.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -59,7 +62,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -80,25 +83,25 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "this is the test dotfile" > ${tmps}/dotfiles/abc
|
echo "this is the test dotfile" > "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# test exists
|
# test exists
|
||||||
echo "{%@@ if exists('/dev/null') @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ if exists('/dev/null') @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "this should exist" >> ${tmps}/dotfiles/abc
|
echo "this should exist" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{%@@ endif @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ endif @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
echo "{%@@ if exists('/dev/abcdef') @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ if exists('/dev/abcdef') @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
echo "this should not exist" >> ${tmps}/dotfiles/abc
|
echo "this should not exist" >> "${tmps}"/dotfiles/abc
|
||||||
echo "{%@@ endif @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ endif @@%}" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# test exists_in_path
|
# test exists_in_path
|
||||||
cat >> ${tmps}/dotfiles/abc << _EOF
|
cat >> "${tmps}"/dotfiles/abc << _EOF
|
||||||
{%@@ if exists_in_path('cat') @@%}
|
{%@@ if exists_in_path('cat') @@%}
|
||||||
this should exist too
|
this should exist too
|
||||||
{%@@ endif @@%}
|
{%@@ endif @@%}
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cat >> ${tmps}/dotfiles/abc << _EOF
|
cat >> "${tmps}"/dotfiles/abc << _EOF
|
||||||
{%@@ if exists_in_path('a_name_that_is_unlikely_to_be_chosen_for_an_executable') @@%}
|
{%@@ if exists_in_path('a_name_that_is_unlikely_to_be_chosen_for_an_executable') @@%}
|
||||||
this should not exist either
|
this should not exist either
|
||||||
{%@@ endif @@%}
|
{%@@ endif @@%}
|
||||||
@@ -106,16 +109,16 @@ _EOF
|
|||||||
|
|
||||||
#cat ${tmps}/dotfiles/abc
|
#cat ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
echo "this is def" > ${tmps}/dotfiles/def
|
echo "this is def" > "${tmps}"/dotfiles/def
|
||||||
|
|
||||||
# test basename
|
# test basename
|
||||||
cat >> ${tmps}/dotfiles/def << _EOF
|
cat >> "${tmps}"/dotfiles/def << _EOF
|
||||||
{%@@ set dotfile_filename = basename( _dotfile_abs_dst ) @@%}
|
{%@@ set dotfile_filename = basename( _dotfile_abs_dst ) @@%}
|
||||||
dotfile dst filename: {{@@ dotfile_filename @@}}
|
dotfile dst filename: {{@@ dotfile_filename @@}}
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# test dirname
|
# test dirname
|
||||||
cat >> ${tmps}/dotfiles/def << _EOF
|
cat >> "${tmps}"/dotfiles/def << _EOF
|
||||||
{%@@ set dotfile_dirname= dirname( _dotfile_abs_dst ) @@%}
|
{%@@ set dotfile_dirname= dirname( _dotfile_abs_dst ) @@%}
|
||||||
dotfile dst dirname: {{@@ dotfile_dirname @@}}
|
dotfile dst dirname: {{@@ dotfile_dirname @@}}
|
||||||
_EOF
|
_EOF
|
||||||
@@ -123,22 +126,22 @@ _EOF
|
|||||||
#cat ${tmps}/dotfiles/def
|
#cat ${tmps}/dotfiles/def
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
|
|
||||||
grep '^this should exist' ${tmpd}/abc >/dev/null
|
grep '^this should exist' "${tmpd}"/abc >/dev/null
|
||||||
grep '^this should exist too' ${tmpd}/abc >/dev/null
|
grep '^this should exist too' "${tmpd}"/abc >/dev/null
|
||||||
set +e
|
set +e
|
||||||
grep '^this should not exist' ${tmpd}/abc >/dev/null && exit 1
|
grep '^this should not exist' "${tmpd}"/abc >/dev/null && exit 1
|
||||||
grep '^this should not exist either' ${tmpd}/abc >/dev/null && exit 1
|
grep '^this should not exist either' "${tmpd}"/abc >/dev/null && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
|
|
||||||
# test def
|
# test def
|
||||||
grep "dotfile dst filename: `basename ${tmpd}/def`" ${tmpd}/def
|
grep "dotfile dst filename: $(basename "${tmpd}"/def)" "${tmpd}"/def
|
||||||
grep "dotfile dst dirname: `dirname ${tmpd}/def`" ${tmpd}/def
|
grep "dotfile dst dirname: $(dirname "${tmpd}"/def)" "${tmpd}"/def
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
59
tests-ng/key-prefix-sep.sh
vendored
59
tests-ng/key-prefix-sep.sh
vendored
@@ -27,45 +27,48 @@ 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"
|
||||||
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 "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) <==$(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)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmpd}/top
|
mkdir -p "${tmpd}"/top
|
||||||
touch ${tmpd}/top/.colors
|
touch "${tmpd}"/top/.colors
|
||||||
mkdir -p ${tmpd}/.mutt/sub
|
mkdir -p "${tmpd}"/.mutt/sub
|
||||||
touch ${tmpd}/.mutt/sub/colors
|
touch "${tmpd}"/.mutt/sub/colors
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
# normal behavior
|
# normal behavior
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -78,19 +81,19 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# import
|
# import
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/top/.colors
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/top/.colors
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/.mutt/sub
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/.mutt/sub
|
||||||
|
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | cut -f1 -d',' | grep -q '_top_colors'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | cut -f1 -d',' | grep -q '_top_colors'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | cut -f1 -d',' | grep -q '_mutt_sub'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | cut -f1 -d',' | grep -q '_mutt_sub'
|
||||||
|
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | cut -f1 -d',' | grep '_top_colors' | grep -q 'f_'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | cut -f1 -d',' | grep '_top_colors' | grep -q 'f_'
|
||||||
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:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -103,17 +106,17 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# import
|
# import
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/top/.colors
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/top/.colors
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/.mutt/sub
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/.mutt/sub
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G
|
||||||
|
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | cut -f1 -d',' | grep -q '+top+colors'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | cut -f1 -d',' | grep -q '+top+colors'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | cut -f1 -d',' | grep -q '+mutt+sub'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | cut -f1 -d',' | grep -q '+mutt+sub'
|
||||||
|
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | cut -f1 -d',' | grep '+top+colors' | grep -qv 'f_'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | cut -f1 -d',' | grep '+top+colors' | grep -qv 'f_'
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | cut -f1 -d',' | grep '+mutt+sub' | grep -qv 'd_'
|
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -G | cut -f1 -d',' | grep '+mutt+sub' | grep -qv 'd_'
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
37
tests-ng/link-import-default.sh
vendored
37
tests-ng/link-import-default.sh
vendored
@@ -28,29 +28,32 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
@@ -59,10 +62,10 @@ clear_on_exit "${tmpd}"
|
|||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
echo "abc" > ${tmpd}/abc
|
echo "abc" > "${tmpd}"/abc
|
||||||
|
|
||||||
# import with nolink by default
|
# import with nolink by default
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -73,18 +76,18 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# import
|
# import
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/abc
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/abc
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
inside="${tmps}/dotfiles/${tmpd}/abc"
|
inside="${tmps}/dotfiles/${tmpd}/abc"
|
||||||
[ ! -e ${inside} ] && exit 1
|
[ ! -e "${inside}" ] && exit 1
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
cat ${cfg} | grep 'link:' && exit 1
|
cat "${cfg}" | grep 'link:' && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# import with parent by default
|
# import with parent by default
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -95,14 +98,14 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# import
|
# import
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/abc
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 -V "${tmpd}"/abc
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
inside="${tmps}/dotfiles/${tmpd}/abc"
|
inside="${tmps}/dotfiles/${tmpd}/abc"
|
||||||
[ ! -e ${inside} ] && exit 1
|
[ ! -e "${inside}" ] && exit 1
|
||||||
|
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
cat ${cfg} | grep 'link: absolute' >/dev/null
|
cat "${cfg}" | grep 'link: absolute' >/dev/null
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
37
tests-ng/link-templates-dir-home.sh
vendored
37
tests-ng/link-templates-dir-home.sh
vendored
@@ -28,33 +28,36 @@ 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"
|
||||||
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 "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) <==$(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
|
||||||
echo "dotfiles source (dotpath): ${tmps}"
|
echo "dotfiles source (dotpath): ${tmps}"
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mktemp -d -p ${HOME} --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d -p "${HOME}" --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "dotfiles destination: ${tmpd}"
|
echo "dotfiles destination: ${tmpd}"
|
||||||
# the workdir
|
# the workdir
|
||||||
tmpw=`mktemp -d -p ${HOME} --suffix='-dotdrop-tests' || mktemp -d`
|
tmpw=$(mktemp -d -p "${HOME}" --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
export DOTDROP_WORKDIR="${tmpw}"
|
export DOTDROP_WORKDIR="${tmpw}"
|
||||||
echo "workdir: ${tmpw}"
|
echo "workdir: ${tmpw}"
|
||||||
|
|
||||||
@@ -65,7 +68,7 @@ clear_on_exit "${tmpw}"
|
|||||||
# 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
|
||||||
@@ -84,21 +87,21 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmps}/dotfiles/abc
|
mkdir -p "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/abc/template
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/abc/template
|
||||||
echo "blabla" >> ${tmps}/dotfiles/abc/template
|
echo "blabla" >> "${tmps}"/dotfiles/abc/template
|
||||||
echo "blabla" > ${tmps}/dotfiles/abc/nottemplate
|
echo "blabla" > "${tmps}"/dotfiles/abc/nottemplate
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -b -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -d ${tmpd}/abc ] && echo "[ERROR] dotfile not installed" && exit 1
|
[ ! -d "${tmpd}"/abc ] && echo "[ERROR] dotfile not installed" && exit 1
|
||||||
[ ! -h ${tmpd}/abc ] && echo "[ERROR] dotfile is not a symlink" && exit 1
|
[ ! -h "${tmpd}"/abc ] && echo "[ERROR] dotfile is not a symlink" && exit 1
|
||||||
#cat ${tmpd}/abc/template
|
#cat ${tmpd}/abc/template
|
||||||
#tree -a ${tmpd}/abc/
|
#tree -a ${tmpd}/abc/
|
||||||
set +e
|
set +e
|
||||||
grep '{{@@' ${tmpd}/abc/template >/dev/null 2>&1 && echo "[ERROR] template in dir not replace" && exit 1
|
grep '{{@@' "${tmpd}"/abc/template >/dev/null 2>&1 && echo "[ERROR] template in dir not replace" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
37
tests-ng/link-templates-dir.sh
vendored
37
tests-ng/link-templates-dir.sh
vendored
@@ -28,33 +28,36 @@ 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"
|
||||||
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 "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) <==$(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
|
||||||
echo "dotfiles source (dotpath): ${tmps}"
|
echo "dotfiles source (dotpath): ${tmps}"
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "dotfiles destination: ${tmpd}"
|
echo "dotfiles destination: ${tmpd}"
|
||||||
# the workdir
|
# the workdir
|
||||||
tmpw=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpw=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
export DOTDROP_WORKDIR="${tmpw}"
|
export DOTDROP_WORKDIR="${tmpw}"
|
||||||
echo "workdir: ${tmpw}"
|
echo "workdir: ${tmpw}"
|
||||||
|
|
||||||
@@ -65,7 +68,7 @@ clear_on_exit "${tmpw}"
|
|||||||
# 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
|
||||||
@@ -84,21 +87,21 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmps}/dotfiles/abc
|
mkdir -p "${tmps}"/dotfiles/abc
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/abc/template
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/abc/template
|
||||||
echo "blabla" >> ${tmps}/dotfiles/abc/template
|
echo "blabla" >> "${tmps}"/dotfiles/abc/template
|
||||||
echo "blabla" > ${tmps}/dotfiles/abc/nottemplate
|
echo "blabla" > "${tmps}"/dotfiles/abc/nottemplate
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -b -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -d ${tmpd}/abc ] && echo "[ERROR] dotfile not installed" && exit 1
|
[ ! -d "${tmpd}"/abc ] && echo "[ERROR] dotfile not installed" && exit 1
|
||||||
[ ! -h ${tmpd}/abc ] && echo "[ERROR] dotfile is not a symlink" && exit 1
|
[ ! -h "${tmpd}"/abc ] && echo "[ERROR] dotfile is not a symlink" && exit 1
|
||||||
#cat ${tmpd}/abc/template
|
#cat ${tmpd}/abc/template
|
||||||
#tree -a ${tmpd}/abc/
|
#tree -a ${tmpd}/abc/
|
||||||
set +e
|
set +e
|
||||||
grep '{{@@' ${tmpd}/abc/template >/dev/null 2>&1 && echo "[ERROR] template in dir not replace" && exit 1
|
grep '{{@@' "${tmpd}"/abc/template >/dev/null 2>&1 && echo "[ERROR] template in dir not replace" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
31
tests-ng/link-templates.sh
vendored
31
tests-ng/link-templates.sh
vendored
@@ -28,33 +28,36 @@ 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"
|
||||||
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 "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) <==$(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
|
||||||
echo "dotfiles source (dotpath): ${tmps}"
|
echo "dotfiles source (dotpath): ${tmps}"
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
echo "dotfiles destination: ${tmpd}"
|
echo "dotfiles destination: ${tmpd}"
|
||||||
# the workdir
|
# the workdir
|
||||||
tmpw=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpw=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
export DOTDROP_WORKDIR="${tmpw}"
|
export DOTDROP_WORKDIR="${tmpw}"
|
||||||
echo "workdir: ${tmpw}"
|
echo "workdir: ${tmpw}"
|
||||||
|
|
||||||
@@ -65,7 +68,7 @@ clear_on_exit "${tmpw}"
|
|||||||
# 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
|
||||||
@@ -84,15 +87,15 @@ _EOF
|
|||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/abc
|
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/abc
|
||||||
echo "blabla" >> ${tmps}/dotfiles/abc
|
echo "blabla" >> "${tmps}"/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -b -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
[ ! -e ${tmpd}/abc ] && echo "[ERROR] dotfile not installed" && exit 1
|
[ ! -e "${tmpd}"/abc ] && echo "[ERROR] dotfile not installed" && exit 1
|
||||||
[ ! -h ${tmpd}/abc ] && echo "[ERROR] dotfile is not a symlink" && exit 1
|
[ ! -h "${tmpd}"/abc ] && echo "[ERROR] dotfile is not a symlink" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
22
tests-ng/link-value-tests.sh
vendored
22
tests-ng/link-value-tests.sh
vendored
@@ -33,7 +33,9 @@ ddpath="${cur}/../"
|
|||||||
|
|
||||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||||
bin="python3 -m dotdrop.dotdrop"
|
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 "dotdrop path: ${ddpath}"
|
||||||
echo "pythonpath: ${PYTHONPATH}"
|
echo "pythonpath: ${PYTHONPATH}"
|
||||||
@@ -41,7 +43,7 @@ echo "pythonpath: ${PYTHONPATH}"
|
|||||||
# get the helpers
|
# get the helpers
|
||||||
source ${cur}/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
|
# this is the test
|
||||||
@@ -454,16 +456,16 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V
|
|||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "d_`basename ${df}`" | head -1 | grep ',link:link_children,'
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "d_`basename "${df}"`" | head -1 | grep ',link:link_children,'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
rm -rf ${tmpd}/qwert
|
rm -rf "${tmpd}"/qwert
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
[ ! -e ${df} ] && echo "does not exist" && exit 1
|
[ ! -e "${df}" ] && echo "does not exist" && exit 1
|
||||||
[ -h ${df} ] && echo "is a symlink" && exit 1
|
[ -h "${df}" ] && echo "is a symlink" && exit 1
|
||||||
[ ! -h ${df}/file ] && echo "file is not a symlink" && exit 1
|
[ ! -h "${df}"/file ] && echo "file is not a symlink" && exit 1
|
||||||
[ ! -h ${df}/directory ] && echo "directory is not a symlink" && exit 1
|
[ ! -h "${df}"/directory ] && echo "directory is not a symlink" && exit 1
|
||||||
[ -h ${df}/directory/file ] && echo "directory/file is a symlink" && exit 1
|
[ -h "${df}"/directory/file ] && echo "directory/file is a symlink" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
33
tests-ng/macro-with-globals.sh
vendored
33
tests-ng/macro-with-globals.sh
vendored
@@ -27,29 +27,32 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
@@ -57,7 +60,7 @@ clear_on_exit "${tmpd}"
|
|||||||
# 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
|
||||||
@@ -76,27 +79,27 @@ variables:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
mkdir -p ${tmps}/dotfiles/
|
mkdir -p "${tmps}"/dotfiles/
|
||||||
|
|
||||||
cat > ${tmps}/dotfiles/macro_file << _EOF
|
cat > "${tmps}"/dotfiles/macro_file << _EOF
|
||||||
{%@@ macro macro(var) @@%}
|
{%@@ macro macro(var) @@%}
|
||||||
{{@@ global @@}}
|
{{@@ global @@}}
|
||||||
{{@@ var @@}}
|
{{@@ var @@}}
|
||||||
{%@@ endmacro @@%}
|
{%@@ endmacro @@%}
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
cat > ${tmps}/dotfiles/abc << _EOF
|
cat > "${tmps}"/dotfiles/abc << _EOF
|
||||||
{%@@ from 'macro_file' import macro with context @@%}
|
{%@@ from 'macro_file' import macro with context @@%}
|
||||||
{{@@ macro(local) @@}}
|
{{@@ macro(local) @@}}
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -p p0 -V -f
|
cd "${ddpath}" | ${bin} install -c "${cfg}" -p p0 -V -f
|
||||||
|
|
||||||
# test file content
|
# test file content
|
||||||
cat ${tmpd}/abc
|
cat "${tmpd}"/abc
|
||||||
grep 'global_var' ${tmpd}/abc >/dev/null 2>&1
|
grep 'global_var' "${tmpd}"/abc >/dev/null 2>&1
|
||||||
grep 'local_var' ${tmpd}/abc >/dev/null 2>&1
|
grep 'local_var' "${tmpd}"/abc >/dev/null 2>&1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
45
tests-ng/minversion.sh
vendored
45
tests-ng/minversion.sh
vendored
@@ -26,35 +26,38 @@ 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"
|
||||||
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 "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) <==$(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}"
|
||||||
|
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -71,20 +74,20 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
mkdir -p ${tmps}/dotfiles/
|
mkdir -p "${tmps}"/dotfiles/
|
||||||
echo "abc" > ${tmps}/dotfiles/abc
|
echo "abc" > "${tmps}"/dotfiles/abc
|
||||||
ln -s ${tmps}/dotfiles/abc ${tmpd}/abc
|
ln -s "${tmps}"/dotfiles/abc "${tmpd}"/abc
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# ensure minversion is present
|
# ensure minversion is present
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
grep 'link: absolute' ${cfg}
|
grep 'link: absolute' "${cfg}"
|
||||||
grep 'minversion' ${cfg}
|
grep 'minversion' "${cfg}"
|
||||||
|
|
||||||
# fake a higher version
|
# fake a higher version
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -103,12 +106,12 @@ _EOF
|
|||||||
|
|
||||||
# compare
|
# compare
|
||||||
set +e
|
set +e
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p1 -V
|
||||||
[ "$?" != "1" ] && echo "minversion not working" && exit 1
|
[ "$?" != "1" ] && echo "minversion not working" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# all clean
|
# all clean
|
||||||
cat > ${cfg} << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -124,11 +127,11 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# compare
|
# compare
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 -V
|
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
# test
|
# test
|
||||||
cat ${cfg}
|
cat "${cfg}"
|
||||||
grep 'minversion' ${cfg} && echo "minversion added, not needed" && exit 1
|
grep 'minversion' "${cfg}" && echo "minversion added, not needed" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
73
tests-ng/negative-ignore-no-match.sh
vendored
73
tests-ng/negative-ignore-no-match.sh
vendored
@@ -10,106 +10,79 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# all this crap to get current path
|
# all this crap to get current path
|
||||||
if [ $(uname) = Darwin ]; then
|
rl="readlink -f"
|
||||||
# Unfortunately, readlink works differently on macOS than it does on GNU/Linux
|
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
||||||
# (the -f option behaves differently) and the realpath command does not exist.
|
rl="realpath"
|
||||||
# Workarounds I find on the Internet suggest just using Homebrew to install coreutils
|
|
||||||
# so you can get the GNU coreutils on your Mac. But, I don't want this script to
|
|
||||||
# assume (a) users have Homebrew installed and (b) if they have Homebrew installed, that
|
|
||||||
# they then installed the GNU coreutils.
|
|
||||||
readlink() {
|
|
||||||
TARGET_FILE=$1
|
|
||||||
|
|
||||||
cd `dirname $TARGET_FILE`
|
if ! hash ${rl}; then
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
echo "\"${rl}\" not found !" && exit 1
|
||||||
|
|
||||||
# Iterate down a (possible) chain of symlinks
|
|
||||||
while [ -L "$TARGET_FILE" ]; do
|
|
||||||
TARGET_FILE=`readlink $TARGET_FILE`
|
|
||||||
cd `dirname $TARGET_FILE`
|
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
|
||||||
done
|
|
||||||
|
|
||||||
# Compute the canonicalized name by finding the physical path
|
|
||||||
# for the directory we're in and appending the target file.
|
|
||||||
PHYS_DIR=`pwd -P`
|
|
||||||
RESULT=$PHYS_DIR/$TARGET_FILE
|
|
||||||
echo $RESULT
|
|
||||||
}
|
|
||||||
rl="readlink"
|
|
||||||
else
|
|
||||||
rl="readlink -f"
|
|
||||||
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
|
||||||
rl="realpath"
|
|
||||||
|
|
||||||
if ! hash ${rl}; then
|
|
||||||
echo "\"${rl}\" not found !" && exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cur=$(dirname "$(${rl} "${0}")")
|
cur=$(dirname "$(${rl} "${0}")")
|
||||||
|
|
||||||
# dotdrop path can be pass as argument
|
# dotdrop path can be pass as argument
|
||||||
ddpath="${cur}/../"
|
ddpath="${cur}/../"
|
||||||
[ -n "${1}" ] && ddpath="${1}"
|
[ -n "${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"
|
||||||
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 "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) <==$(tput sgr0)"
|
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
basedir=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d`
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' 2>/dev/null || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
# some files
|
# some files
|
||||||
mkdir -p ${tmpd}/program/ignore_me
|
mkdir -p "${tmpd}"/program/ignore_me
|
||||||
echo "some data" > ${tmpd}/program/a
|
echo "some data" > "${tmpd}"/program/a
|
||||||
echo "some data" > ${tmpd}/program/ignore_me/b
|
echo "some data" > "${tmpd}"/program/ignore_me/b
|
||||||
echo "some data" > ${tmpd}/program/ignore_me/c
|
echo "some data" > "${tmpd}"/program/ignore_me/c
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${basedir}/config.yaml"
|
cfg="${basedir}/config.yaml"
|
||||||
create_conf ${cfg} # sets token
|
create_conf "${cfg}" # sets token
|
||||||
|
|
||||||
# import
|
# import
|
||||||
echo "[+] import"
|
echo "[+] import"
|
||||||
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/program
|
cd "${ddpath}" | ${bin} import -f -c "${cfg}" "${tmpd}"/program
|
||||||
|
|
||||||
# adding ignore in dotfile
|
# adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/d_program:/a\
|
sed '/d_program:/a\
|
||||||
\ \ \ \ instignore:\
|
\ \ \ \ instignore:\
|
||||||
\ \ \ \ - "!*/ignore_me/c"
|
\ \ \ \ - "!*/ignore_me/c"
|
||||||
' ${cfg} > ${cfg2}
|
' "${cfg}" > "${cfg2}"
|
||||||
|
|
||||||
# install
|
# install
|
||||||
rm -rf ${tmpd}
|
rm -rf "${tmpd}"
|
||||||
echo "[+] install with negative ignore in dotfile"
|
echo "[+] install with negative ignore in dotfile"
|
||||||
echo '(1) expect dotdrop install to warn when negative ignore pattern does not match an already-ignored file'
|
echo '(1) expect dotdrop install to warn when negative ignore pattern does not match an already-ignored file'
|
||||||
|
|
||||||
patt="[WARN] no files that are currently being ignored match \"*/ignore_me/c\". In order for a negative ignore
|
patt="[WARN] no files that are currently being ignored match \"*/ignore_me/c\". In order for a negative ignore
|
||||||
pattern to work, it must match a file that is being ignored by a previous ignore pattern."
|
pattern to work, it must match a file that is being ignored by a previous ignore pattern."
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg2} --verbose 2>&1 >/dev/null | grep -F "${patt}" ||
|
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)
|
(echo "dotdrop did not warn when negative ignore pattern did not match an already-ignored file" && exit 1)
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user