mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 18:34:48 +00:00
shell linting
This commit is contained in:
1
tests-ng/chmod-import.sh
vendored
1
tests-ng/chmod-import.sh
vendored
@@ -54,6 +54,7 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sg
|
||||
chmod_to_umask()
|
||||
{
|
||||
u=$(umask)
|
||||
# shellcheck disable=SC2001
|
||||
u=$(echo "${u}" | sed 's/^0*//')
|
||||
if [ -d "${1}" ]; then
|
||||
v=$((777 - u))
|
||||
|
||||
29
tests-ng/chmod-install.sh
vendored
29
tests-ng/chmod-install.sh
vendored
@@ -29,7 +29,7 @@ cur=$(dirname "$(${rl} "${0}")")
|
||||
# dotdrop path can be pass as argument
|
||||
ddpath="${cur}/../"
|
||||
[ "${1}" != "" ] && ddpath="${1}"
|
||||
[ ! -d ${ddpath} ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
|
||||
[ ! -d "${ddpath}" ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
|
||||
|
||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||
bin="python3 -m dotdrop.dotdrop"
|
||||
@@ -41,9 +41,10 @@ echo "dotdrop path: ${ddpath}"
|
||||
echo "pythonpath: ${PYTHONPATH}"
|
||||
|
||||
# get the helpers
|
||||
source ${cur}/helpers
|
||||
# shellcheck source=tests-ng/helpers
|
||||
source "${cur}"/helpers
|
||||
|
||||
echo -e "$(tput setaf 6)==> RUNNING $(basename ${BASH_SOURCE[0]}) <==$(tput sgr0)"
|
||||
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||
|
||||
################################################################
|
||||
# this is the test
|
||||
@@ -54,28 +55,22 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename ${BASH_SOURCE[0]}) <==$(tput sgr0
|
||||
has_rights()
|
||||
{
|
||||
echo "testing ${1} is ${2}"
|
||||
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
|
||||
local mode=`stat -L -c '%a' "$1"`
|
||||
[ "${mode}" != "$2" ] && echo "bad mode for `basename "$1"` (${mode} VS expected ${2})" && exit 1
|
||||
[ ! -e "$1" ] && echo "$(basename "$1") does not exist" && exit 1
|
||||
local mode
|
||||
mode=$(stat -L -c '%a' "$1")
|
||||
[ "${mode}" != "$2" ] && echo "bad mode for $(basename "$1") (${mode} VS expected ${2})" && exit 1
|
||||
true
|
||||
}
|
||||
|
||||
get_file_mode()
|
||||
{
|
||||
u=$(umask)
|
||||
# shellcheck disable=2001
|
||||
u=$(echo "${u}" | sed 's/^0*//')
|
||||
v=$((666 - u))
|
||||
echo "${v}"
|
||||
}
|
||||
|
||||
get_dir_mode()
|
||||
{
|
||||
u=$(umask)
|
||||
u=$(echo "${u}" | sed 's/^0*//')
|
||||
v=$((777 - u))
|
||||
echo "${v}"
|
||||
}
|
||||
|
||||
# the dotfile source
|
||||
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
@@ -271,7 +266,11 @@ echo "nomode" > "${tmps}"/dotfiles/nomode
|
||||
chmod 600 "${tmps}"/dotfiles/nomode
|
||||
echo "nomode" > "${tmpd}"/nomode
|
||||
chmod 700 "${tmpd}"/nomode
|
||||
cd "${ddpath}" | printf 'y\ny\n' | ${bin} install -f -c "${cfg}" -p p2 -V f_nomode
|
||||
(
|
||||
d "${ddpath}"
|
||||
printf 'y\ny\n' | ${bin} install -f -c "${cfg}" -p p2 -V f_nomode
|
||||
exit $?
|
||||
)
|
||||
echo "different mode (2)"
|
||||
has_rights "${tmpd}/nomode" "600"
|
||||
|
||||
|
||||
27
tests-ng/chmod-more.sh
vendored
27
tests-ng/chmod-more.sh
vendored
@@ -29,7 +29,7 @@ cur=$(dirname "$(${rl} "${0}")")
|
||||
# dotdrop path can be pass as argument
|
||||
ddpath="${cur}/../"
|
||||
[ "${1}" != "" ] && ddpath="${1}"
|
||||
[ ! -d ${ddpath} ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
|
||||
[ ! -d "${ddpath}" ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
|
||||
|
||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||
bin="python3 -m dotdrop.dotdrop"
|
||||
@@ -41,9 +41,10 @@ echo "dotdrop path: ${ddpath}"
|
||||
echo "pythonpath: ${PYTHONPATH}"
|
||||
|
||||
# get the helpers
|
||||
source ${cur}/helpers
|
||||
# shellcheck source=tests-ng/helpers
|
||||
source "${cur}"/helpers
|
||||
|
||||
echo -e "$(tput setaf 6)==> RUNNING $(basename ${BASH_SOURCE[0]}) <==$(tput sgr0)"
|
||||
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||
|
||||
################################################################
|
||||
# this is the test
|
||||
@@ -54,25 +55,13 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename ${BASH_SOURCE[0]}) <==$(tput sgr0
|
||||
has_rights()
|
||||
{
|
||||
echo "testing ${1} is ${2}"
|
||||
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
|
||||
local mode=`stat -L -c '%a' "$1"`
|
||||
[ "${mode}" != "$2" ] && echo "bad mode for `basename "$1"` (${mode} instead of ${2})" && exit 1
|
||||
[ ! -e "$1" ] && echo "$(basename "$1") does not exist" && exit 1
|
||||
local mode
|
||||
mode=$(stat -L -c '%a' "$1")
|
||||
[ "${mode}" != "$2" ] && echo "bad mode for $(basename "$1") (${mode} instead of ${2})" && exit 1
|
||||
true
|
||||
}
|
||||
|
||||
# $1 file
|
||||
chmod_to_umask()
|
||||
{
|
||||
u=$(umask)
|
||||
u=$(echo "${u}" | sed 's/^0*//')
|
||||
if [ -d "${1}" ]; then
|
||||
v=$((777 - u))
|
||||
else
|
||||
v=$((666 - u))
|
||||
fi
|
||||
chmod ${v} "${1}"
|
||||
}
|
||||
|
||||
# the dotfile source
|
||||
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
|
||||
28
tests-ng/chmod-preserve-install.sh
vendored
28
tests-ng/chmod-preserve-install.sh
vendored
@@ -27,7 +27,7 @@ cur=$(dirname "$(${rl} "${0}")")
|
||||
# dotdrop path can be pass as argument
|
||||
ddpath="${cur}/../"
|
||||
[ "${1}" != "" ] && ddpath="${1}"
|
||||
[ ! -d ${ddpath} ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
|
||||
[ ! -d "${ddpath}" ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
|
||||
|
||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||
bin="python3 -m dotdrop.dotdrop"
|
||||
@@ -39,9 +39,10 @@ echo "dotdrop path: ${ddpath}"
|
||||
echo "pythonpath: ${PYTHONPATH}"
|
||||
|
||||
# get the helpers
|
||||
source ${cur}/helpers
|
||||
# shellcheck source=tests-ng/helpers
|
||||
source "${cur}"/helpers
|
||||
|
||||
echo -e "$(tput setaf 6)==> RUNNING $(basename ${BASH_SOURCE[0]}) <==$(tput sgr0)"
|
||||
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||
|
||||
################################################################
|
||||
# this is the test
|
||||
@@ -52,9 +53,10 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename ${BASH_SOURCE[0]}) <==$(tput sgr0
|
||||
has_rights()
|
||||
{
|
||||
echo "testing ${1} is ${2}"
|
||||
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
|
||||
local mode=`stat -L -c '%a' "$1"`
|
||||
[ "${mode}" != "$2" ] && echo "bad mode for `basename $1` (${mode} VS expected ${2})" && exit 1
|
||||
[ ! -e "$1" ] && echo "$(basename "$1") does not exist" && exit 1
|
||||
local mode
|
||||
mode=$(stat -L -c '%a' "$1")
|
||||
[ "${mode}" != "$2" ] && echo "bad mode for $(basename "$1") (${mode} VS expected ${2})" && exit 1
|
||||
true
|
||||
}
|
||||
|
||||
@@ -62,21 +64,24 @@ has_rights()
|
||||
is_same_as()
|
||||
{
|
||||
echo "testing ${1} has same rights than ${2}"
|
||||
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
|
||||
[ ! -e "$2" ] && echo "`basename $2` does not exist" && exit 1
|
||||
[ ! -e "$1" ] && echo "$(basename "$1") does not exist" && exit 1
|
||||
[ ! -e "$2" ] && echo "$(basename "$2") does not exist" && exit 1
|
||||
|
||||
local mode1=`stat -L -c '%a' "$1"`
|
||||
local mode1
|
||||
mode1=$(stat -L -c '%a' "$1")
|
||||
echo "$1: ${mode1}"
|
||||
local mode2=`stat -L -c '%a' "$2"`
|
||||
local mode2
|
||||
mode2=$(stat -L -c '%a' "$2")
|
||||
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
|
||||
}
|
||||
|
||||
get_default_file_mode()
|
||||
{
|
||||
u=$(umask)
|
||||
# shellcheck disable=SC2001
|
||||
u=$(echo "${u}" | sed 's/^0*//')
|
||||
v=$((666 - u))
|
||||
echo "${v}"
|
||||
@@ -85,6 +90,7 @@ get_default_file_mode()
|
||||
get_default_dir_mode()
|
||||
{
|
||||
u=$(umask)
|
||||
# shellcheck disable=SC2001
|
||||
u=$(echo "${u}" | sed 's/^0*//')
|
||||
v=$((777 - u))
|
||||
echo "${v}"
|
||||
|
||||
15
tests-ng/chmod-update.sh
vendored
15
tests-ng/chmod-update.sh
vendored
@@ -111,7 +111,8 @@ chmod 777 "${dnormal}"
|
||||
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 -V "${dnormal}"
|
||||
|
||||
# check rights updated
|
||||
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/$(basename "${dnormal}"))" != "777" ] && echo "rights not updated (1)" && exit 1
|
||||
bname=$(basename "${dnormal}")
|
||||
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/"${bname}")" != "777" ] && echo "rights not updated (1)" && exit 1
|
||||
|
||||
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||
[ "${cnt}" != "1" ] && echo "chmod not updated (1)" && exit 1
|
||||
@@ -122,7 +123,8 @@ chmod 777 "${dlink}"
|
||||
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 -V "${dlink}"
|
||||
|
||||
# check rights updated
|
||||
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/$(basename "${dlink}"))" != "777" ] && echo "rights not updated (2)" && exit 1
|
||||
bname=$(basename "${dlink}")
|
||||
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/"${bname}")" != "777" ] && echo "rights not updated (2)" && exit 1
|
||||
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||
[ "${cnt}" != "2" ] && echo "chmod not updated (2)" && exit 1
|
||||
|
||||
@@ -132,7 +134,8 @@ chmod 777 "${dlinkchildren}"
|
||||
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 -V "${dlinkchildren}"
|
||||
|
||||
# check rights updated
|
||||
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/$(basename "${dlinkchildren}"))" != "777" ] && echo "rights not updated (3)" && exit 1
|
||||
bname=$(basename "${dlinkchildren}")
|
||||
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/"${bname}")" != "777" ] && echo "rights not updated (3)" && exit 1
|
||||
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||
[ "${cnt}" != "3" ] && echo "chmod not updated (3)" && exit 1
|
||||
|
||||
@@ -142,7 +145,8 @@ chmod 777 "${fnormal}"
|
||||
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 -V "${fnormal}"
|
||||
|
||||
# check rights updated
|
||||
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/$(basename "${fnormal}"))" != "777" ] && echo "rights not updated (4)" && exit 1
|
||||
bname=$(basename "${fnormal}")
|
||||
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/"${bname}")" != "777" ] && echo "rights not updated (4)" && exit 1
|
||||
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||
[ "${cnt}" != "4" ] && echo "chmod not updated (4)" && exit 1
|
||||
|
||||
@@ -152,7 +156,8 @@ chmod 777 "${flink}"
|
||||
cd "${ddpath}" | ${bin} update -c "${cfg}" -f -p p1 -V "${flink}"
|
||||
|
||||
# check rights updated
|
||||
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/$(basename "${flink}"))" != "777" ] && echo "rights not updated (5)" && exit 1
|
||||
bname=$(basename "${flink}")
|
||||
[ "$(stat -c '%a' "${tmps}"/dotfiles/"${tmpd}"/"${bname}")" != "777" ] && echo "rights not updated (5)" && exit 1
|
||||
cnt=$(cat "${cfg}" | grep "chmod: '777'" | wc -l)
|
||||
[ "${cnt}" != "5" ] && echo "chmod not updated (5)" && exit 1
|
||||
|
||||
|
||||
14
tests-ng/clear-workdir.sh
vendored
14
tests-ng/clear-workdir.sh
vendored
@@ -96,8 +96,11 @@ cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p1 --verbose | grep '^1 dotfil
|
||||
touch "${DOTDROP_WORKDIR}"/new
|
||||
|
||||
echo "[+] re-install with clear-workdir in cli"
|
||||
cd "${ddpath}" | printf "y\n" | ${bin} install -W -c "${cfg}" -p p1 --verbose
|
||||
[ "$?" != "0" ] && exit 1
|
||||
(
|
||||
cd "${ddpath}"
|
||||
printf "y\n" | ${bin} install -W -c "${cfg}" -p p1 --verbose
|
||||
exit $?
|
||||
)
|
||||
|
||||
[ ! -e "${tmpd}"/x ] && echo "f_x not installed" && exit 1
|
||||
[ ! -h "${tmpd}"/x ] && echo "f_x not symlink" && exit 1
|
||||
@@ -124,8 +127,11 @@ profiles:
|
||||
dotfiles:
|
||||
- f_x
|
||||
_EOF
|
||||
cd "${ddpath}" | printf "y\n" | ${bin} install -W -c "${cfg}" -p p1 --verbose
|
||||
[ "$?" != "0" ] && exit 1
|
||||
(
|
||||
cd "${ddpath}"
|
||||
printf "y\n" | ${bin} install -W -c "${cfg}" -p p1 --verbose
|
||||
exit $?
|
||||
)
|
||||
|
||||
[ ! -e "${tmpd}"/x ] && echo "f_x not installed" && exit 1
|
||||
[ ! -h "${tmpd}"/x ] && echo "f_x not symlink" && exit 1
|
||||
|
||||
2
tests-ng/compare-profile-check.sh
vendored
2
tests-ng/compare-profile-check.sh
vendored
@@ -51,7 +51,7 @@ dt="${tmps}/dotfiles"
|
||||
mkdir -p "${dt}"
|
||||
|
||||
xori="profile x"
|
||||
xori="profile y"
|
||||
yori="profile y"
|
||||
echo "${xori}" > "${dt}"/file_x
|
||||
echo "${yori}" > "${dt}"/file_y
|
||||
|
||||
|
||||
8
tests-ng/filter_file.sh
vendored
8
tests-ng/filter_file.sh
vendored
@@ -124,10 +124,10 @@ _EOF
|
||||
echo "this is the test dotfile" > "${tmps}"/dotfiles/abc
|
||||
|
||||
# test imported function
|
||||
echo "{{@@ "abc" | filter1 @@}}" >> "${tmps}"/dotfiles/abc
|
||||
echo "{{@@ "arg1" | filter2('arg2') @@}}" >> "${tmps}"/dotfiles/abc
|
||||
echo "{{@@ "13" | filter3() @@}}" >> "${tmps}"/dotfiles/abc
|
||||
echo "{{@@ "something" | filter_ext() @@}}" >> "${tmps}"/dotfiles/abc
|
||||
echo "{{@@ \"abc\" | filter1 @@}}" >> "${tmps}"/dotfiles/abc
|
||||
echo "{{@@ \"arg1\" | filter2('arg2') @@}}" >> "${tmps}"/dotfiles/abc
|
||||
echo "{{@@ \"13\" | filter3() @@}}" >> "${tmps}"/dotfiles/abc
|
||||
echo "{{@@ \"something\" | filter_ext() @@}}" >> "${tmps}"/dotfiles/abc
|
||||
echo "{{@@ filt @@}}variable" >> "${tmps}"/dotfiles/abc
|
||||
|
||||
# install
|
||||
|
||||
1
tests-ng/global-compare-ignore.sh
vendored
1
tests-ng/global-compare-ignore.sh
vendored
@@ -104,7 +104,6 @@ sed '/dotpath: dotfiles/a \ \ cmpignore:\n\ \ \ \ - "*b"' "${cfg}" > "${cfg2}"
|
||||
cat "${cfg2}"
|
||||
|
||||
# expects no diff
|
||||
patt="*b"
|
||||
echo "[+] comparing with ignore in dotfile - 0 diff"
|
||||
set +e
|
||||
cd "${ddpath}" | ${bin} compare -c "${cfg2}" --verbose
|
||||
|
||||
4
tests-ng/import-configs.sh
vendored
4
tests-ng/import-configs.sh
vendored
@@ -158,7 +158,7 @@ cd "${ddpath}" | ${bin} compare -c "${cfg1}" -p p2 -V
|
||||
# test with non-existing dotpath this time
|
||||
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
rm -rf "${tmpd}"/*
|
||||
rm -rf "${tmpd:?}"/*
|
||||
|
||||
cat > "${cfg1}" << _EOF
|
||||
config:
|
||||
@@ -190,7 +190,7 @@ cd "${ddpath}" | ${bin} compare -c "${cfg1}" -p p2 -V
|
||||
|
||||
# test with same profile defined in both
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
rm -rf "${tmpd}"/*
|
||||
rm -rf "${tmpd:?}"/*
|
||||
|
||||
cat > "${cfg1}" << _EOF
|
||||
config:
|
||||
|
||||
7
tests-ng/import-ignore.sh
vendored
7
tests-ng/import-ignore.sh
vendored
@@ -49,13 +49,6 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sg
|
||||
# this is the test
|
||||
################################################################
|
||||
|
||||
# $1 pattern
|
||||
# $2 path
|
||||
grep_or_fail()
|
||||
{
|
||||
grep "${1}" "${2}" >/dev/null 2>&1 || (echo "pattern not found in ${2}" && exit 1)
|
||||
}
|
||||
|
||||
# the dotfile source
|
||||
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
|
||||
7
tests-ng/install-ignore.sh
vendored
7
tests-ng/install-ignore.sh
vendored
@@ -125,8 +125,11 @@ echo "(3) found ${nb} README.md file(s)"
|
||||
|
||||
## reinstall to trigger showdiff
|
||||
echo "showdiff" > "${tmpd}"/program/a
|
||||
cd "${ddpath}" | echo "y" | ${bin} install --showdiff -c "${cfg}" --verbose -f
|
||||
[ "$?" != "0" ] && exit 1
|
||||
(
|
||||
cd "${ddpath}"
|
||||
printf "y\n" | ${bin} install --showdiff -c "${cfg}" --verbose -f
|
||||
exit $?
|
||||
)
|
||||
|
||||
# test templated subdir
|
||||
cat > "${cfg}" << _EOF
|
||||
|
||||
33
tests-ng/install.sh
vendored
33
tests-ng/install.sh
vendored
@@ -28,7 +28,7 @@ cur=$(dirname "$(${rl} "${0}")")
|
||||
# dotdrop path can be pass as argument
|
||||
ddpath="${cur}/../"
|
||||
[ "${1}" != "" ] && ddpath="${1}"
|
||||
[ ! -d ${ddpath} ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
|
||||
[ ! -d "${ddpath}" ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
|
||||
|
||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||
bin="python3 -m dotdrop.dotdrop"
|
||||
@@ -40,9 +40,10 @@ echo "dotdrop path: ${ddpath}"
|
||||
echo "pythonpath: ${PYTHONPATH}"
|
||||
|
||||
# get the helpers
|
||||
source ${cur}/helpers
|
||||
# shellcheck source=tests-ng/helpers
|
||||
source "${cur}"/helpers
|
||||
|
||||
echo -e "$(tput setaf 6)==> RUNNING $(basename ${BASH_SOURCE[0]}) <==$(tput sgr0)"
|
||||
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||
|
||||
################################################################
|
||||
# this is the test
|
||||
@@ -50,8 +51,9 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename ${BASH_SOURCE[0]}) <==$(tput sgr0
|
||||
|
||||
get_file_mode()
|
||||
{
|
||||
u=`umask`
|
||||
u=`echo ${u} | sed 's/^0*//'`
|
||||
u=$(umask)
|
||||
# shellcheck disable=SC2001
|
||||
u=$(echo "${u}" | sed 's/^0*//')
|
||||
v=$((666 - u))
|
||||
echo "${v}"
|
||||
}
|
||||
@@ -61,9 +63,10 @@ get_file_mode()
|
||||
has_rights()
|
||||
{
|
||||
echo "testing ${1} is ${2}"
|
||||
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
|
||||
local mode=`stat -L -c '%a' "$1"`
|
||||
[ "${mode}" != "$2" ] && echo "bad mode for `basename "$1"` (${mode} VS expected ${2})" && exit 1
|
||||
[ ! -e "$1" ] && echo "$(basename "$1") does not exist" && exit 1
|
||||
local mode
|
||||
mode=$(stat -L -c '%a' "$1")
|
||||
[ "${mode}" != "$2" ] && echo "bad mode for $(basename "$1") (${mode} VS expected ${2})" && exit 1
|
||||
true
|
||||
}
|
||||
|
||||
@@ -113,15 +116,21 @@ chmod 644 "${tmpd}"/x
|
||||
|
||||
mode=$(get_file_mode "${tmpd}"/x)
|
||||
echo "[+] re-install with no"
|
||||
cd "${ddpath}" | printf "N\n" | ${bin} install -c "${cfg}" -p p1 --verbose
|
||||
[ "$?" != "0" ] && exit 1
|
||||
(
|
||||
cd "${ddpath}"
|
||||
printf "N\n" | ${bin} install -c "${cfg}" -p p1 --verbose
|
||||
exit ${?}
|
||||
)
|
||||
|
||||
# if user answers N, chmod should not be done
|
||||
has_rights "${tmpd}/x" "${mode}"
|
||||
|
||||
echo "[+] re-install with yes"
|
||||
cd "${ddpath}" | printf "y\n" | ${bin} install -c "${cfg}" -p p1 --verbose
|
||||
[ "$?" != "0" ] && exit 1
|
||||
(
|
||||
cd "${ddpath}"
|
||||
printf "y\n" | ${bin} install -c "${cfg}" -p p1 --verbose
|
||||
exit ${?}
|
||||
)
|
||||
|
||||
has_rights "${tmpd}/x" "666"
|
||||
|
||||
|
||||
299
tests-ng/link-value-tests.sh
vendored
299
tests-ng/link-value-tests.sh
vendored
@@ -29,7 +29,7 @@ cur=$(dirname "$(${rl} "${0}")")
|
||||
# dotdrop path can be pass as argument
|
||||
ddpath="${cur}/../"
|
||||
[ "${1}" != "" ] && ddpath="${1}"
|
||||
[ ! -d ${ddpath} ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
|
||||
[ ! -d "${ddpath}" ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
|
||||
|
||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||
bin="python3 -m dotdrop.dotdrop"
|
||||
@@ -41,19 +41,20 @@ echo "dotdrop path: ${ddpath}"
|
||||
echo "pythonpath: ${PYTHONPATH}"
|
||||
|
||||
# get the helpers
|
||||
source ${cur}/helpers
|
||||
# shellcheck source=tests-ng/helpers
|
||||
source "${cur}"/helpers
|
||||
|
||||
echo -e "$(tput setaf 6)==> RUNNING $(basename ${BASH_SOURCE[0]}) <==$(tput sgr0)"
|
||||
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
|
||||
|
||||
################################################################
|
||||
# this is the test
|
||||
################################################################
|
||||
|
||||
# the dotfile source
|
||||
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# 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 "${tmpd}"
|
||||
@@ -64,13 +65,13 @@ cfg="${tmps}/config.yaml"
|
||||
# ----------------------------------------------------------
|
||||
echo -e "\n======> import with all default"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert
|
||||
rm -rf "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -81,28 +82,28 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 "${df}" -V
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:nolink,'
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "f_$(basename "${df}")" | head -1 | grep ',link:nolink,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
[ ! -e ${df} ] && echo "does not exist" && exit 1
|
||||
[ -h ${df} ] && echo "is symlink" && exit 1
|
||||
rm -rf "${tmpd}"/qwert
|
||||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
[ ! -e "${df}" ] && echo "does not exist" && exit 1
|
||||
[ -h "${df}" ] && echo "is symlink" && exit 1
|
||||
|
||||
# ----------------------------------------------------------
|
||||
echo -e "\n======> import with link_on_import=nolink and link_dotfile_default=nolink"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert
|
||||
rm -rf "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -115,28 +116,28 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 "${df}" -V
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:nolink,'
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "f_$(basename "${df}")" | head -1 | grep ',link:nolink,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
[ ! -e ${df} ] && echo "does not exist" && exit 1
|
||||
[ -h ${df} ] && echo "is symlink" && exit 1
|
||||
rm -rf "${tmpd}"/qwert
|
||||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
[ ! -e "${df}" ] && echo "does not exist" && exit 1
|
||||
[ -h "${df}" ] && echo "is symlink" && exit 1
|
||||
|
||||
# ----------------------------------------------------------
|
||||
echo -e "\n======> import with link_on_import=nolink and link_dotfile_default=nolink and --link=nolink"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert
|
||||
rm -rf "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -149,28 +150,28 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V --link=nolink
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 "${df}" -V --link=nolink
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:nolink,'
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "f_$(basename "${df}")" | head -1 | grep ',link:nolink,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
[ ! -e ${df} ] && echo "does not exist" && exit 1
|
||||
[ -h ${df} ] && echo "is symlink" && exit 1
|
||||
rm -rf "${tmpd}"/qwert
|
||||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
[ ! -e "${df}" ] && echo "does not exist" && exit 1
|
||||
[ -h "${df}" ] && echo "is symlink" && exit 1
|
||||
|
||||
# ----------------------------------------------------------
|
||||
echo -e "\n======> import with link_on_import=nolink and link_dotfile_default=nolink and --link=link"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert
|
||||
rm -rf "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -183,28 +184,28 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V --link=absolute
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 "${df}" -V --link=absolute
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:absolute,'
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "f_$(basename "${df}")" | head -1 | grep ',link:absolute,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
[ ! -e ${df} ] && echo "does not exist" && exit 1
|
||||
[ ! -h ${df} ] && echo "not symlink" && exit 1
|
||||
rm -rf "${tmpd}"/qwert
|
||||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
[ ! -e "${df}" ] && echo "does not exist" && exit 1
|
||||
[ ! -h "${df}" ] && echo "not symlink" && exit 1
|
||||
|
||||
# ----------------------------------------------------------
|
||||
echo -e "\n======> import with link_on_import=link and link_dotfile_default=nolink"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert
|
||||
rm -rf "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -217,28 +218,28 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 "${df}" -V
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:absolute,'
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "f_$(basename "${df}")" | head -1 | grep ',link:absolute,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
[ ! -e ${df} ] && echo "does not exist" && exit 1
|
||||
[ ! -h ${df} ] && echo "not symlink" && exit 1
|
||||
rm -rf "${tmpd}"/qwert
|
||||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
[ ! -e "${df}" ] && echo "does not exist" && exit 1
|
||||
[ ! -h "${df}" ] && echo "not symlink" && exit 1
|
||||
|
||||
# ----------------------------------------------------------
|
||||
echo -e "\n======> import with link_on_import=link and link_dotfile_default=nolink and --link=nolink"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert
|
||||
rm -rf "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -251,28 +252,28 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V --link=nolink
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 "${df}" -V --link=nolink
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:nolink,'
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "f_$(basename "${df}")" | head -1 | grep ',link:nolink,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
[ ! -e ${df} ] && echo "does not exist" && exit 1
|
||||
[ -h ${df} ] && echo "is symlink" && exit 1
|
||||
rm -rf "${tmpd}"/qwert
|
||||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
[ ! -e "${df}" ] && echo "does not exist" && exit 1
|
||||
[ -h "${df}" ] && echo "is symlink" && exit 1
|
||||
|
||||
# ----------------------------------------------------------
|
||||
echo -e "\n======> import with link_on_import=nolink and link_dotfile_default=link"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert
|
||||
rm -rf "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -285,28 +286,28 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V --link=nolink
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 "${df}" -V --link=nolink
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:nolink,'
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "f_$(basename "${df}")" | head -1 | grep ',link:nolink,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
[ ! -e ${df} ] && echo "does not exist" && exit 1
|
||||
[ -h ${df} ] && echo "is symlink" && exit 1
|
||||
rm -rf "${tmpd}"/qwert
|
||||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
[ ! -e "${df}" ] && echo "does not exist" && exit 1
|
||||
[ -h "${df}" ] && echo "is symlink" && exit 1
|
||||
|
||||
# ----------------------------------------------------------
|
||||
echo -e "\n======> import with link_on_import=link and link_dotfile_default=nolink and --link=nolink"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert
|
||||
rm -rf "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -319,28 +320,28 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V --link=nolink
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 "${df}" -V --link=nolink
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:nolink,'
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "f_$(basename "${df}")" | head -1 | grep ',link:nolink,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
[ ! -e ${df} ] && echo "does not exist" && exit 1
|
||||
[ -h ${df} ] && echo "is symlink" && exit 1
|
||||
rm -rf "${tmpd}"/qwert
|
||||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
[ ! -e "${df}" ] && echo "does not exist" && exit 1
|
||||
[ -h "${df}" ] && echo "is symlink" && exit 1
|
||||
|
||||
# ----------------------------------------------------------
|
||||
echo -e "\n======> import with all default and --link=link"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert
|
||||
rm -rf "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -351,28 +352,28 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} --link=absolute -p p1 ${df} -V
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" --link=absolute -p p1 "${df}" -V
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:absolute,'
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "f_$(basename "${df}")" | head -1 | grep ',link:absolute,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
[ ! -e ${df} ] && echo "does not exist" && exit 1
|
||||
[ ! -h ${df} ] && echo "not a symlink" && exit 1
|
||||
rm -rf "${tmpd}"/qwert
|
||||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
[ ! -e "${df}" ] && echo "does not exist" && exit 1
|
||||
[ ! -h "${df}" ] && echo "not a symlink" && exit 1
|
||||
|
||||
# ----------------------------------------------------------
|
||||
echo -e "\n======> import with all default and --link=link_children"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert
|
||||
rm -rf "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -384,24 +385,24 @@ _EOF
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
set +e
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} --link=link_children -p p1 ${df} -V
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" --link=link_children -p p1 "${df}" -V
|
||||
[ "$?" = "0" ] && echo "link_children with file should fail" && exit 1
|
||||
set -e
|
||||
|
||||
# ----------------------------------------------------------
|
||||
echo -e "\n======> import with all default and --link=link_children"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
mkdir -p ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert/file
|
||||
mkdir -p ${tmpd}/qwert/directory
|
||||
echo "test" > ${tmpd}/qwert/directory/file
|
||||
rm -rf "${tmpd}"/qwert
|
||||
mkdir -p "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert/file
|
||||
mkdir -p "${tmpd}"/qwert/directory
|
||||
echo "test" > "${tmpd}"/qwert/directory/file
|
||||
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -412,34 +413,34 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} --link=link_children -p p1 ${df} -V
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" --link=link_children -p p1 "${df}" -V
|
||||
|
||||
# checks
|
||||
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
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "d_$(basename "${df}")" | head -1 | grep ',link:link_children,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
[ ! -e ${df} ] && echo "does not exist" && exit 1
|
||||
[ -h ${df} ] && echo "is 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/file ] && echo "directory/file is a symlink" && exit 1
|
||||
rm -rf "${tmpd}"/qwert
|
||||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
[ ! -e "${df}" ] && echo "does not exist" && exit 1
|
||||
[ -h "${df}" ] && echo "is 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/file ] && echo "directory/file is a symlink" && exit 1
|
||||
|
||||
echo -e "\n======> import with link_on_import=link_children and link_dotfile_default=nolink"
|
||||
# create the source
|
||||
rm -rf ${tmpd}/qwert
|
||||
mkdir -p ${tmpd}/qwert
|
||||
echo "test" > ${tmpd}/qwert/file
|
||||
mkdir -p ${tmpd}/qwert/directory
|
||||
echo "test" > ${tmpd}/qwert/directory/file
|
||||
rm -rf "${tmpd}"/qwert
|
||||
mkdir -p "${tmpd}"/qwert
|
||||
echo "test" > "${tmpd}"/qwert/file
|
||||
mkdir -p "${tmpd}"/qwert/directory
|
||||
echo "test" > "${tmpd}"/qwert/directory/file
|
||||
|
||||
# clean
|
||||
rm -rf ${tmps}/dotfiles
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
rm -rf "${tmps}"/dotfiles
|
||||
mkdir -p "${tmps}"/dotfiles
|
||||
# config file
|
||||
cat > ${cfg} << _EOF
|
||||
cat > "${cfg}" << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
@@ -452,11 +453,11 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V
|
||||
cd "${ddpath}" | ${bin} import -f -c "${cfg}" -p p1 "${df}" -V
|
||||
|
||||
# checks
|
||||
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
|
||||
cd "${ddpath}" | ${bin} files -c "${cfg}" -p p1 -V -G | grep "d_$(basename "${df}")" | head -1 | grep ',link:link_children,'
|
||||
|
||||
# try to install
|
||||
rm -rf "${tmpd}"/qwert
|
||||
|
||||
2
tests-ng/notemplate.sh
vendored
2
tests-ng/notemplate.sh
vendored
@@ -238,7 +238,7 @@ _EOF
|
||||
#cat ${cfg}
|
||||
|
||||
# clean destination
|
||||
rm -rf "${tmpd}"/*
|
||||
rm -rf "${tmpd:?}"/*
|
||||
|
||||
# install
|
||||
cd "${ddpath}" | ${bin} install -f --showdiff -c "${cfg}" -p p1 -V
|
||||
|
||||
7
tests-ng/update-ignore-missing.sh
vendored
7
tests-ng/update-ignore-missing.sh
vendored
@@ -44,13 +44,6 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sg
|
||||
# this is the test
|
||||
################################################################
|
||||
|
||||
# $1 pattern
|
||||
# $2 path
|
||||
grep_or_fail()
|
||||
{
|
||||
grep "${1}" "${2}" >/dev/null 2>&1 || (echo "pattern not found in ${2}" && exit 1)
|
||||
}
|
||||
|
||||
# dotdrop directory
|
||||
tmps=$(mktemp -d --suffix='-dotdrop-tests-source' || mktemp -d)
|
||||
dt="${tmps}/dotfiles"
|
||||
|
||||
6
tests-ng/uservariables.sh
vendored
6
tests-ng/uservariables.sh
vendored
@@ -97,7 +97,11 @@ echo "var4: {{@@ var4 @@}}" >> "${tmps}"/dotfiles/abc
|
||||
|
||||
# install
|
||||
echo "step 1"
|
||||
cd "${ddpath}" | echo -e 'var1contentxxx\nvar2contentyyy\nvar3\nvar4\n' | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
(
|
||||
cd "${ddpath}"
|
||||
printf 'var1contentxxx\nvar2contentyyy\nvar3\nvar4\n' | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||
exit ${?}
|
||||
)
|
||||
|
||||
cat "${tmpd}"/abc
|
||||
|
||||
|
||||
1
tests-ng/workdir-compare.sh
vendored
1
tests-ng/workdir-compare.sh
vendored
@@ -49,7 +49,6 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sg
|
||||
# this is the test
|
||||
################################################################
|
||||
unset DOTDROP_WORKDIR
|
||||
string="blabla"
|
||||
|
||||
# the dotfile source
|
||||
tmp=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||
|
||||
Reference in New Issue
Block a user