mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 10:59:16 +00:00
improve tests
This commit is contained in:
@@ -94,7 +94,7 @@ profiles:
|
|||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# import without --preserve-mode
|
# 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
|
||||||
@@ -111,7 +111,6 @@ chmod 700 ${flink}
|
|||||||
set +e
|
set +e
|
||||||
cnt=`cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 2>&1 | grep 'modes differ' | wc -l`
|
cnt=`cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 2>&1 | grep 'modes differ' | wc -l`
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
[ "${cnt}" != "5" ] && echo "compare modes failed" && exit 1
|
[ "${cnt}" != "5" ] && echo "compare modes failed" && exit 1
|
||||||
|
|
||||||
## CLEANING
|
## CLEANING
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ mkdir -p ${tmps}/dotfiles
|
|||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
# create the dotfile
|
# 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
|
||||||
@@ -120,8 +120,8 @@ cat ${cfg}
|
|||||||
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: '777'" | wc -l`
|
||||||
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted" && exit 1
|
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (1)" && exit 1
|
||||||
|
|
||||||
## with link
|
## with link
|
||||||
cat > ${cfg} << _EOF
|
cat > ${cfg} << _EOF
|
||||||
@@ -138,7 +138,6 @@ 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 link -f -p p1 -V ${i}
|
cd ${ddpath} | ${bin} import -c ${cfg} -l link -f -p p1 -V ${i}
|
||||||
done
|
done
|
||||||
@@ -149,8 +148,12 @@ cat ${cfg}
|
|||||||
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: '777'" | wc -l`
|
||||||
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted" && exit 1
|
[ "${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
|
## --preserve-mode
|
||||||
cat > ${cfg} << _EOF
|
cat > ${cfg} << _EOF
|
||||||
@@ -178,8 +181,8 @@ cat ${cfg}
|
|||||||
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" && exit 1
|
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (3)" && exit 1
|
||||||
|
|
||||||
## import normal
|
## import normal
|
||||||
cat > ${cfg} << _EOF
|
cat > ${cfg} << _EOF
|
||||||
|
|||||||
@@ -58,6 +58,22 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)"
|
|||||||
# this is the test
|
# 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
|
# 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
|
||||||
@@ -98,6 +114,8 @@ 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
|
||||||
|
|
||||||
cat > ${cfg} << _EOF
|
cat > ${cfg} << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
@@ -145,6 +163,9 @@ dotfiles:
|
|||||||
dst: ${tmpd}/symlinktemplatedir
|
dst: ${tmpd}/symlinktemplatedir
|
||||||
chmod: 777
|
chmod: 777
|
||||||
link: link
|
link: link
|
||||||
|
f_nomode:
|
||||||
|
src: nomode
|
||||||
|
dst: ${tmpd}/nomode
|
||||||
profiles:
|
profiles:
|
||||||
p1:
|
p1:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
@@ -157,12 +178,14 @@ profiles:
|
|||||||
- d_linkchildren
|
- d_linkchildren
|
||||||
- f_symlinktemplate
|
- f_symlinktemplate
|
||||||
- d_symlinktemplatedir
|
- d_symlinktemplatedir
|
||||||
|
- f_nomode
|
||||||
p2:
|
p2:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- f_exists
|
- f_exists
|
||||||
- f_existslink
|
- f_existslink
|
||||||
- d_linkchildren
|
- d_linkchildren
|
||||||
- f_symlinktemplate
|
- f_symlinktemplate
|
||||||
|
- f_nomode
|
||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
@@ -182,6 +205,8 @@ 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`
|
||||||
|
has_rights "${tmpd}/nomode" "${m}"
|
||||||
|
|
||||||
grep 'p1' ${tmpd}/symlinktemplate
|
grep 'p1' ${tmpd}/symlinktemplate
|
||||||
grep 'p1' ${tmpd}/symlinktemplatedir/t
|
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" "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`
|
||||||
|
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
|
## CLEANING
|
||||||
rm -rf ${tmps} ${tmpd}
|
rm -rf ${tmps} ${tmpd}
|
||||||
|
|||||||
Reference in New Issue
Block a user