mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 18:34:48 +00:00
improve diffing
This commit is contained in:
@@ -46,6 +46,15 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)"
|
||||
# this is the test
|
||||
################################################################
|
||||
|
||||
# $1 pattern
|
||||
# $2 path
|
||||
grep_or_fail()
|
||||
{
|
||||
set +e
|
||||
grep "${1}" "${2}" >/dev/null 2>&1 || (echo "pattern not found in ${2}" && exit 1)
|
||||
set -e
|
||||
}
|
||||
|
||||
# the action temp
|
||||
tmpa=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
||||
# the dotfile source
|
||||
@@ -136,38 +145,36 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
|
||||
# checks
|
||||
[ ! -e ${tmpa}/pre ] && echo 'pre action not executed' && exit 1
|
||||
grep pre ${tmpa}/pre >/dev/null
|
||||
grep_or_fail pre ${tmpa}/pre
|
||||
[ ! -e ${tmpa}/naked ] && echo 'naked action not executed' && exit 1
|
||||
grep naked ${tmpa}/naked >/dev/null
|
||||
grep_or_fail naked ${tmpa}/naked
|
||||
|
||||
[ ! -e ${tmpa}/multiple ] && echo 'pre action multiple not executed' && exit 1
|
||||
grep multiple ${tmpa}/multiple >/dev/null
|
||||
grep_or_fail multiple ${tmpa}/multiple
|
||||
[ "`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
|
||||
grep pre2 ${tmpa}/pre2 >/dev/null
|
||||
grep_or_fail pre2 ${tmpa}/pre2
|
||||
[ ! -e ${tmpa}/naked2 ] && echo 'naked action 2 not executed' && exit 1
|
||||
grep naked2 ${tmpa}/naked2 >/dev/null
|
||||
grep_or_fail naked2 ${tmpa}/naked2
|
||||
|
||||
[ ! -e ${tmpa}/multiple2 ] && echo 'pre action multiple 2 not executed' && exit 1
|
||||
grep multiple2 ${tmpa}/multiple2 >/dev/null
|
||||
grep_or_fail multiple2 ${tmpa}/multiple2
|
||||
[ "`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
|
||||
grep naked3 ${tmpa}/naked3 >/dev/null
|
||||
grep_or_fail naked3 ${tmpa}/naked3
|
||||
|
||||
|
||||
# remove the pre action result and re-run
|
||||
# remove the pre action result and re-install
|
||||
rm ${tmpa}/pre
|
||||
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1
|
||||
[ -e ${tmpa}/pre ] && exit 1
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||
[ -e ${tmpa}/pre ] && echo "pre exists" && exit 1
|
||||
|
||||
# ensure failing actions make the installation fail
|
||||
# install
|
||||
set +e
|
||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p2 -V
|
||||
set -e
|
||||
[ -e ${tmpd}/fail ] && exit 1
|
||||
[ -e ${tmpd}/fail ] && echo "fail exists" && exit 1
|
||||
|
||||
## CLEANING
|
||||
rm -rf ${tmps} ${tmpd} ${tmpa}
|
||||
|
||||
@@ -262,7 +262,7 @@ 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
|
||||
cd ${ddpath} | printf 'y\ny\n' | ${bin} install -c ${cfg} -p p2 -V f_nomode
|
||||
has_rights "${tmpd}/nomode" "600"
|
||||
|
||||
## CLEANING
|
||||
|
||||
@@ -172,7 +172,7 @@ profiles:
|
||||
dotfiles:
|
||||
- f_asub
|
||||
_EOF
|
||||
cd ${ddpath} | ${bin} install -c ${cfg1} -p p2 -V
|
||||
cd ${ddpath} | ${bin} install -c ${cfg1} -p p2 -V -f
|
||||
cd ${ddpath} | ${bin} compare -c ${cfg1} -p p2 -V
|
||||
|
||||
## CLEANING
|
||||
|
||||
@@ -46,6 +46,15 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)"
|
||||
# this is the test
|
||||
################################################################
|
||||
|
||||
# $1 pattern
|
||||
# $2 path
|
||||
grep_or_fail()
|
||||
{
|
||||
set +e
|
||||
grep "${1}" "${2}" >/dev/null 2>&1 || (echo "pattern not found in ${2}" && exit 1)
|
||||
set -e
|
||||
}
|
||||
|
||||
# dotdrop directory
|
||||
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
||||
dt="${tmps}/dotfiles"
|
||||
@@ -98,7 +107,7 @@ cd ${ddpath} | ${bin} update -f -c ${cfg} --verbose --profile=p1 --key f_abc
|
||||
#tree ${dt}
|
||||
|
||||
# check files haven't been updated
|
||||
grep 'b' ${dt}/a/c/acfile >/dev/null
|
||||
grep_or_fail 'b' "${dt}/a/c/acfile"
|
||||
[ -e ${dt}/a/newfile ] && echo "should not have been updated" && exit 1
|
||||
|
||||
## CLEANING
|
||||
|
||||
Reference in New Issue
Block a user