1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 17:24:46 +00:00

improve tests

This commit is contained in:
deadc0de6
2020-11-14 15:01:56 +01:00
parent 81d585a37f
commit 87b70053c8
3 changed files with 59 additions and 10 deletions

View File

@@ -94,7 +94,7 @@ profiles:
_EOF
#cat ${cfg}
# import without --preserve-mode
# import
for i in ${toimport}; do
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 ${i}
done
@@ -111,7 +111,6 @@ chmod 700 ${flink}
set +e
cnt=`cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 2>&1 | grep 'modes differ' | wc -l`
set -e
[ "${cnt}" != "5" ] && echo "compare modes failed" && exit 1
## CLEANING

View File

@@ -67,7 +67,7 @@ mkdir -p ${tmps}/dotfiles
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
#echo "dotfile destination: ${tmpd}"
# create the dotfile
# create the dotfiles
dnormal="${tmpd}/dir_normal"
mkdir -p ${dnormal}
echo "dir_normal/f1" > ${dnormal}/file1
@@ -120,8 +120,8 @@ cat ${cfg}
cd ${ddpath} | ${bin} detail -c ${cfg} -p p1 -V
tot=`echo ${toimport} | wc -w`
cnt=`cat ${cfg} | grep chmod | wc -l`
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted" && exit 1
cnt=`cat ${cfg} | grep "chmod: '777'" | wc -l`
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (1)" && exit 1
## with link
cat > ${cfg} << _EOF
@@ -138,7 +138,6 @@ rm -rf ${tmps}/dotfiles
mkdir -p ${tmps}/dotfiles
# import without --preserve-mode and link
for i in ${toimport}; do
cd ${ddpath} | ${bin} import -c ${cfg} -l link -f -p p1 -V ${i}
done
@@ -149,8 +148,12 @@ cat ${cfg}
cd ${ddpath} | ${bin} detail -c ${cfg} -p p1 -V
tot=`echo ${toimport} | wc -w`
cnt=`cat ${cfg} | grep chmod | wc -l`
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted" && exit 1
cnt=`cat ${cfg} | grep "chmod: '777'" | wc -l`
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (2)" && exit 1
tot=`echo ${toimport} | wc -w`
cnt=`cat ${cfg} | grep 'link: link' | wc -l`
[ "${cnt}" != "${tot}" ] && echo "not all link inserted" && exit 1
## --preserve-mode
cat > ${cfg} << _EOF
@@ -178,8 +181,8 @@ cat ${cfg}
cd ${ddpath} | ${bin} detail -c ${cfg} -p p1 -V
tot=`echo ${toimport} | wc -w`
cnt=`cat ${cfg} | grep chmod | wc -l`
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted" && exit 1
cnt=`cat ${cfg} | grep "chmod: " | wc -l`
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (3)" && exit 1
## import normal
cat > ${cfg} << _EOF

View File

@@ -58,6 +58,22 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)"
# this is the test
################################################################
get_file_mode()
{
u=`umask`
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
@@ -98,6 +114,8 @@ echo '{{@@ profile @@}}' > ${tmps}/dotfiles/symlinktemplate
mkdir -p ${tmps}/dotfiles/symlinktemplatedir
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/symlinktemplatedir/t
echo 'nomode' > ${tmps}/dotfiles/nomode
cat > ${cfg} << _EOF
config:
backup: true
@@ -145,6 +163,9 @@ dotfiles:
dst: ${tmpd}/symlinktemplatedir
chmod: 777
link: link
f_nomode:
src: nomode
dst: ${tmpd}/nomode
profiles:
p1:
dotfiles:
@@ -157,12 +178,14 @@ profiles:
- d_linkchildren
- f_symlinktemplate
- d_symlinktemplatedir
- f_nomode
p2:
dotfiles:
- f_exists
- f_existslink
- d_linkchildren
- f_symlinktemplate
- f_nomode
_EOF
#cat ${cfg}
@@ -182,6 +205,8 @@ has_rights "${tmpd}/linkchildren/f1" "644"
has_rights "${tmpd}/linkchildren/d1" "755"
has_rights "${tmpd}/linkchildren/d1/f2" "644"
has_rights "${tmpd}/symlinktemplate" "777"
m=`get_file_mode`
has_rights "${tmpd}/nomode" "${m}"
grep 'p1' ${tmpd}/symlinktemplate
grep 'p1' ${tmpd}/symlinktemplatedir/t
@@ -207,6 +232,28 @@ has_rights "${tmpd}/linkchildren/f1" "644"
has_rights "${tmpd}/linkchildren/d1" "755"
has_rights "${tmpd}/linkchildren/d1/f2" "644"
has_rights "${tmpd}/symlinktemplate" "777"
m=`get_file_mode`
has_rights "${tmpd}/nomode" "${m}"
## no user confirmation expected
## same mode
echo "same mode"
echo "nomode" > ${tmps}/dotfiles/nomode
chmod 600 ${tmps}/dotfiles/nomode
echo "nomode" > ${tmpd}/nomode
chmod 600 ${tmpd}/nomode
cd ${ddpath} | ${bin} install -c ${cfg} -p p2 -V f_nomode
has_rights "${tmpd}/nomode" "600"
## user confirmation expected
## different mode
echo "different mode"
echo "nomode" > ${tmps}/dotfiles/nomode
chmod 600 ${tmps}/dotfiles/nomode
echo "nomode" > ${tmpd}/nomode
chmod 700 ${tmpd}/nomode
cd ${ddpath} | printf 'y\n' | ${bin} install -c ${cfg} -p p2 -V f_nomode
has_rights "${tmpd}/nomode" "600"
## CLEANING
rm -rf ${tmps} ${tmpd}