mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-11 05:34:17 +00:00
add more tests
This commit is contained in:
@@ -85,6 +85,12 @@ if [[ $OSTYPE == 'darwin'* ]]; then
|
|||||||
chmod() {
|
chmod() {
|
||||||
gchmod "$@"
|
gchmod "$@"
|
||||||
}
|
}
|
||||||
|
readlink() {
|
||||||
|
greadlink "$@"
|
||||||
|
}
|
||||||
|
realpath() {
|
||||||
|
grealpath "$@"
|
||||||
|
}
|
||||||
|
|
||||||
export -f mktemp
|
export -f mktemp
|
||||||
export -f stat
|
export -f stat
|
||||||
@@ -92,4 +98,6 @@ if [[ $OSTYPE == 'darwin'* ]]; then
|
|||||||
export -f wc
|
export -f wc
|
||||||
export -f date
|
export -f date
|
||||||
export -f chmod
|
export -f chmod
|
||||||
|
export -f readlink
|
||||||
|
export -f realpath
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -51,15 +51,22 @@ mkdir -p ${tmps}/dotfiles
|
|||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
tmpw=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
clear_on_exit "${tmpw}"
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
# test symlink directory
|
# test symlink directory
|
||||||
##################################################
|
##################################################
|
||||||
# create the dotfile
|
# create the file
|
||||||
echo "file1" > ${tmps}/dotfiles/abc
|
echo "file1" > ${tmps}/dotfiles/abc
|
||||||
|
mkdir -p ${tmps}/dotfiles/def
|
||||||
|
echo 'file2' > ${tmps}/dotfiles/def/afile
|
||||||
|
echo '{{@@ header() @@}}' > ${tmps}/dotfiles/ghi
|
||||||
|
mkdir -p ${tmps}/dotfiles/jkl
|
||||||
|
echo '{{@@ header() @@}}' > ${tmps}/dotfiles/jkl/anotherfile
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
@@ -69,20 +76,36 @@ config:
|
|||||||
create: true
|
create: true
|
||||||
dotpath: dotfiles
|
dotpath: dotfiles
|
||||||
link_dotfile_default: nolink
|
link_dotfile_default: nolink
|
||||||
|
workdir: ${tmpw}
|
||||||
dotfiles:
|
dotfiles:
|
||||||
d_abc:
|
f_abc:
|
||||||
dst: ${tmpd}/abc
|
dst: ${tmpd}/abc
|
||||||
src: abc
|
src: abc
|
||||||
link: relative
|
link: relative
|
||||||
d_abc2:
|
f_abc2:
|
||||||
dst: ${tmpd}/abc2
|
dst: ${tmpd}/abc2
|
||||||
src: abc
|
src: abc
|
||||||
link: absolute
|
link: absolute
|
||||||
|
d_def:
|
||||||
|
dst: ${tmpd}/def
|
||||||
|
src: def
|
||||||
|
link: relative
|
||||||
|
f_ghi:
|
||||||
|
dst: ${tmpd}/ghi
|
||||||
|
src: ghi
|
||||||
|
link: relative
|
||||||
|
d_jkl:
|
||||||
|
dst: ${tmpd}/jkl
|
||||||
|
src: jkl
|
||||||
|
link: relative
|
||||||
profiles:
|
profiles:
|
||||||
p1:
|
p1:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- d_abc
|
- f_abc
|
||||||
- d_abc2
|
- f_abc2
|
||||||
|
- d_def
|
||||||
|
- f_ghi
|
||||||
|
- d_jkl
|
||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
@@ -92,15 +115,28 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
|||||||
# ensure exists and is link
|
# ensure exists and is link
|
||||||
[ ! -h ${tmpd}/abc ] && echo "not a symlink" && exit 1
|
[ ! -h ${tmpd}/abc ] && echo "not a symlink" && exit 1
|
||||||
[ ! -h ${tmpd}/abc2 ] && echo "not a symlink" && exit 1
|
[ ! -h ${tmpd}/abc2 ] && echo "not a symlink" && exit 1
|
||||||
|
[ ! -h ${tmpd}/def ] && echo "not a symlink" && exit 1
|
||||||
|
[ ! -d ${tmpd}/def ] && echo "not a symlink" && exit 1
|
||||||
|
[ ! -h ${tmpd}/ghi ] && echo "not a symlink" && exit 1
|
||||||
|
[ ! -h ${tmpd}/jkl ] && echo "not a symlink" && exit 1
|
||||||
|
[ ! -d ${tmpd}/jkl ] && echo "not a symlink" && exit 1
|
||||||
|
|
||||||
ls -l ${tmpd}/abc | grep '..' || exit 1
|
ls -l ${tmpd}/abc | grep '\.\.' || exit 1
|
||||||
ls -l ${tmpd}/abc2
|
ls -l ${tmpd}/abc2
|
||||||
|
ls -l ${tmpd}/def | grep '\.\.' || exit 1
|
||||||
|
ls -l ${tmpd}/ghi | grep '\.\.' || exit 1
|
||||||
|
ls -l ${tmpd}/jkl | grep '\.\.' || exit 1
|
||||||
|
|
||||||
grep 'file1' ${tmpd}/abc
|
grep 'file1' ${tmpd}/abc
|
||||||
grep 'file1' ${tmpd}/abc2
|
grep 'file1' ${tmpd}/abc2
|
||||||
|
grep 'file2' ${tmpd}/def/afile
|
||||||
|
grep 'This dotfile is managed using dotdrop' ${tmpd}/ghi
|
||||||
|
grep 'This dotfile is managed using dotdrop' ${tmpd}/jkl/anotherfile
|
||||||
|
[[ $(realpath --relative-base="${tmpw}" -- "$(realpath ${tmpd}/ghi)") =~ ^/ ]] && echo "ghi not subpath of workdir" && exit 1
|
||||||
|
[[ $(realpath --relative-base="${tmpw}" -- "$(realpath ${tmpd}/jkl)") =~ ^/ ]] && echo "jkl not subpath of workdir" && exit 1
|
||||||
|
|
||||||
## TODO with templates
|
## TODO test with install path children of dotpath
|
||||||
echo "TODO with templates"
|
echo "TODO more tests"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
Reference in New Issue
Block a user