1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-08 21:19:15 +00:00

improve tests

This commit is contained in:
deadc0de6
2022-05-03 23:13:51 +02:00
committed by deadc0de
parent c31f8ffcd5
commit 3dfa53469e
26 changed files with 108 additions and 71 deletions

View File

@@ -70,9 +70,9 @@ create_conf ${cfg} # sets token
# import
echo "[+] import"
cd ${ddpath} | ${bin} import --verbose -c ${cfg} ${tmpd}/program || exit 1
cd ${ddpath} | ${bin} import --verbose -c ${cfg} ${tmpd}/config || exit 1
cd ${ddpath} | ${bin} import --verbose -c ${cfg} ${tmpd}/vscode || 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}/vscode || exit 1
# add files on filesystem
echo "[+] add files"
@@ -149,7 +149,7 @@ mkdir -p ${tmpd}/.zsh/plugins
touch ${tmpd}/.zsh/plugins/someplugin
echo "[+] import .zsh"
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/.zsh
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/.zsh
# no diff expected
echo "[+] comparing .zsh"

View File

@@ -71,9 +71,9 @@ create_conf ${cfg} # sets token
# import
echo "[+] import"
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/program
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/config
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/vscode
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}/vscode
# add files
echo "[+] add files"
@@ -174,7 +174,7 @@ create_conf ${cfg} # sets token
# import
echo "[+] import"
cd ${ddpath} | ${bin} import -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
touch ${tmpd}/program/.DS_Store

View File

@@ -95,8 +95,8 @@ create_conf ${cfg} # sets token
# import dir1
echo "[+] import"
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/dir1
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/uniquefile
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/dir1
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/uniquefile
cat ${cfg}
# let's see the dotpath

View File

@@ -73,7 +73,7 @@ _EOF
# import
echo "[+] import"
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/singlefile
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/singlefile
# modify the file
echo "modified" > ${tmpd}/singlefile

View File

@@ -62,7 +62,7 @@ cfg="${basedir}/config.yaml"
create_conf ${cfg} # sets token
# import the dir
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}
# change token
echo "changed" > ${token}

View File

@@ -90,7 +90,7 @@ mkdir -p ${tmpd}/sub/sub
echo "test2" > ${tmpd}/sub/sub/abc
# import
cd ${ddpath} | ${bin} import --verbose -c ${cfg} -p p2 \
cd ${ddpath} | ${bin} import -f --verbose -c ${cfg} -p p2 \
${tmpd}/abc \
${tmpd}/sub/abc \
${tmpd}/sub/abc \

View File

@@ -75,7 +75,7 @@ variables:
var1: "this is some test"
var2: "the_dvar4"
dynvariables:
dvar1: head -1 /proc/meminfo
dvar1: head -1 ${cur}/helpers
dvar2: "echo 'this is some test' | rev | tr ' ' ','"
dvar3: ${scr}
dvar4: "echo {{@@ var2 @@}} | rev"
@@ -101,10 +101,12 @@ echo "test" >> ${tmps}/dotfiles/abc
# install
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
echo "-----"
cat ${tmpd}/abc
echo "-----"
grep '^this is some test' ${tmpd}/abc >/dev/null
grep "^MemTotal" ${tmpd}/abc >/dev/null
grep '^# author: deadc0de6' ${tmpd}/abc >/dev/null
grep '^tset,emos,si,siht' ${tmpd}/abc >/dev/null
grep "^${TESTENV}" ${tmpd}/abc > /dev/null
grep '^4ravd_eht' ${tmpd}/abc >/dev/null

View File

@@ -75,8 +75,8 @@ _EOF
# import
echo "[+] import"
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/program
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/config
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/program
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/config
# add files
echo "[+] add files"

View File

@@ -63,3 +63,33 @@ dotfiles:
profiles:
_EOF
}
# osx tricks
# brew install coreutils gnu-sed
if [[ $OSTYPE == 'darwin'* ]]; then
mktemp() {
gmktemp "$@"
}
stat() {
gstat "$@"
}
sed() {
gsed "$@"
}
wc() {
gwc "$@"
}
date() {
gdate "$@"
}
chmod() {
gchmod "$@"
}
export -f mktemp
export -f stat
export -f sed
export -f wc
export -f date
export -f chmod
fi

View File

@@ -77,17 +77,17 @@ _EOF
#cat ${cfg}
# import
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/adir
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/file3
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/file3
echo "import --as dotfiles"
cd ${ddpath} | ${bin} import -c ${cfg} -p p2 -V ${tmpd}/adir --as ~/config/adir
cd ${ddpath} | ${bin} import -c ${cfg} -p p2 -V ${tmpd}/file3 --as ~/config2/file3
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
cat ${cfg}
set +e
cd ${ddpath} | ${bin} import -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
cat ${cfg} | grep should_not && echo "dual dst imported" && exit 1
@@ -137,7 +137,7 @@ dotfiles:
profiles:
_EOF
cd ${ddpath} | ${bin} import -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}
[ ! -e ~/.dotdrop-dotfiles-test/dotfiles/whatever ] && echo 'tild imported' && exit 1

View File

@@ -93,8 +93,8 @@ _EOF
cat ${cfg}
# import
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/.mutt/colors
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/.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
cat ${cfg}

View File

@@ -58,13 +58,13 @@ tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
mkdir -p ${tmps}/dotfiles
# the dotfile destination
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
mkdir -p ${tmpd}
#echo "dotfile destination: ${tmpd}"
clear_on_exit "${tmps}"
clear_on_exit "${tmpd}"
# dotdrop directory
mkdir -p ${tmpd}
mkdir -p ${tmpd}/a/{b,c}
echo 'a' > ${tmpd}/a/b/abfile
echo 'a' > ${tmpd}/a/c/acfile
@@ -90,7 +90,7 @@ _EOF
# import
echo "[+] import"
cd ${ddpath} | ${bin} import -c ${cfg} --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
[ -e ${tmps}/dotfiles/newdir/newfile ] && echo "newfile not ignored" && exit 1

View File

@@ -89,7 +89,7 @@ profiles:
_EOF
# import
cd ${ddpath} | ${bin} import -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
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "d_`basename ${dt}`" | grep ',link:link_children,'

View File

@@ -96,7 +96,7 @@ profiles:
_EOF
echo "[+] import"
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 --verbose ${dftoimport}
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 --verbose ${dftoimport}
[ "$?" != "0" ] && exit 1
echo "[+] install"

View File

@@ -75,8 +75,8 @@ _EOF
#cat ${cfg}
# import
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/adir
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/file3
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/file3
cat ${cfg}
@@ -97,8 +97,8 @@ nb=`cat ${cfg} | grep f_file3 | wc -l`
cntpre=`find ${tmps}/dotfiles -type f | wc -l`
# reimport
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/adir
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/file3
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/file3
cntpost=`find ${tmps}/dotfiles -type f | wc -l`
@@ -124,7 +124,7 @@ echo "fil2" > ${d}/file2
mkfifo ${d}/fifo
# import
cd ${ddpath} | ${bin} import -c ${cfg} -p p2 -V ${d}
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p2 -V ${d}
# ensure exists and is not link
[ ! -d ${tmps}/dotfiles/${d} ] && echo "not a directory" && exit 1

View File

@@ -71,9 +71,9 @@ create_conf ${cfg} # sets token
# import
echo "[+] import"
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/program
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/config
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/vscode
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}/vscode
# add files on filesystem
echo "[+] add files"
@@ -143,7 +143,7 @@ echo "f1" > ${tmpd}/nvim/dir2/file2
echo "ftop" > ${tmpd}/nvim/ftop
echo "[+] import top"
cd ${ddpath} | ${bin} import -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
mkdir -p ${tmpd}/nvim/templated
@@ -151,8 +151,8 @@ echo "noprofile" > ${tmpd}/nvim/templated/ftemplated
echo "noprofile" > ${tmpd}/nvim/template
echo "[+] import sub"
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${tmpd}/nvim/templated
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${tmpd}/nvim/template
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${tmpd}/nvim/templated
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${tmpd}/nvim/template
cfg2="${basedir}/config2.yaml"
sed '/d_nvim:/a \ \ \ \ instignore:\n\ \ \ \ - "*template*"' ${cfg} > ${cfg2}

View File

@@ -78,8 +78,8 @@ profiles:
_EOF
# import
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/top/.colors
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/.mutt/sub
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} 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'
@@ -103,8 +103,8 @@ profiles:
_EOF
# import
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/top/.colors
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/.mutt/sub
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
cat ${cfg}
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G

View File

@@ -73,7 +73,7 @@ profiles:
_EOF
# import
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/abc
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/abc
# checks
inside="${tmps}/dotfiles/${tmpd}/abc"
@@ -95,7 +95,7 @@ profiles:
_EOF
# import
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V ${tmpd}/abc
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/abc
# checks
inside="${tmps}/dotfiles/${tmpd}/abc"

View File

@@ -79,7 +79,7 @@ _EOF
# import
df="${tmpd}/qwert"
cd ${ddpath} | ${bin} import -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
@@ -113,7 +113,7 @@ _EOF
# import
df="${tmpd}/qwert"
cd ${ddpath} | ${bin} import -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
@@ -147,7 +147,7 @@ _EOF
# import
df="${tmpd}/qwert"
cd ${ddpath} | ${bin} import -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
@@ -181,7 +181,7 @@ _EOF
# import
df="${tmpd}/qwert"
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V --link=link
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V --link=link
# checks
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
@@ -215,7 +215,7 @@ _EOF
# import
df="${tmpd}/qwert"
cd ${ddpath} | ${bin} import -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
@@ -249,7 +249,7 @@ _EOF
# import
df="${tmpd}/qwert"
cd ${ddpath} | ${bin} import -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
@@ -283,7 +283,7 @@ _EOF
# import
df="${tmpd}/qwert"
cd ${ddpath} | ${bin} import -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
@@ -317,7 +317,7 @@ _EOF
# import
df="${tmpd}/qwert"
cd ${ddpath} | ${bin} import -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
@@ -349,7 +349,7 @@ _EOF
# import
df="${tmpd}/qwert"
cd ${ddpath} | ${bin} import -c ${cfg} --link=link -p p1 ${df} -V
cd ${ddpath} | ${bin} import -f -c ${cfg} --link=link -p p1 ${df} -V
# checks
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
@@ -382,7 +382,7 @@ _EOF
# import
df="${tmpd}/qwert"
set +e
cd ${ddpath} | ${bin} import -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
@@ -410,7 +410,7 @@ _EOF
# import
df="${tmpd}/qwert"
cd ${ddpath} | ${bin} import -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
@@ -450,7 +450,7 @@ _EOF
# import
df="${tmpd}/qwert"
cd ${ddpath} | ${bin} import -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

View File

@@ -82,7 +82,7 @@ variables:
gvar1: "global1"
gvar2: "global2"
dynvariables:
gdvar1: head -1 /proc/meminfo
gdvar1: head -1 ${cur}/helpers
gdvar2: "echo 'this is some test' | rev | tr ' ' ','"
gdvar3: ${scr}
dotfiles:
@@ -123,7 +123,7 @@ grep '^local1' ${tmpd}/abc >/dev/null
grep '^global2' ${tmpd}/abc >/dev/null
grep '^local2' ${tmpd}/abc >/dev/null
# test dynvariables
grep "^MemTotal" ${tmpd}/abc >/dev/null
grep "^# author: deadc0de6" ${tmpd}/abc >/dev/null
grep '^tset,emos,si,siht' ${tmpd}/abc >/dev/null
grep "^${TESTENV2}" ${tmpd}/abc > /dev/null
grep "^cba" ${tmpd}/abc >/dev/null

View File

@@ -68,7 +68,7 @@ tokend="compressed archive"
touched="touched"
cat > ${cfg} << _EOF
trans:
trans_read:
base64: cat {0} | base64 -d > {1}
uncompress: mkdir -p {1} && tar -xf {0} -C {1}
trans_write:
@@ -85,12 +85,12 @@ dotfiles:
f_abc:
dst: ${tmpd}/abc
src: abc
trans: base64
trans_read: base64
trans_write: base64
d_ghi:
dst: ${tmpd}/ghi
src: ghi
trans: uncompress
trans_read: uncompress
trans_write: compress
chmod: 700
profiles:

View File

@@ -72,8 +72,8 @@ create_conf ${cfg} # sets token
# import dir1
echo "[+] import"
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpf}
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpf}
# change file
chmod +x ${tmpf}

View File

@@ -73,9 +73,9 @@ create_conf ${cfg} # sets token
# import dir1
echo "[+] import"
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/dir1
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/uniquefile
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/uniquefile2
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}/uniquefile2
# make some modification
echo "[+] modify"

View File

@@ -97,8 +97,8 @@ create_conf ${cfg} # sets token
# import dir1
echo "[+] import"
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/dir1
cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/uniquefile
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/dir1
cd ${ddpath} | ${bin} import -f -c ${cfg} ${tmpd}/uniquefile
# let's see the dotpath
#tree ${basedir}/dotfiles