1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-05 20:48:00 +00:00

add more tests and add jhelper methods

This commit is contained in:
deadc0de6
2019-05-04 17:52:40 +02:00
parent d21eca8437
commit 34a8947fc1
3 changed files with 31 additions and 0 deletions

View File

@@ -50,6 +50,8 @@ class Templategen:
# adding helper methods
self.env.globals['exists'] = jhelpers.exists
self.env.globals['exists_in_path'] = jhelpers.exists_in_path
self.env.globals['basename'] = jhelpers.basename
self.env.globals['dirname'] = jhelpers.dirname
def generate(self, src):
"""render template from path"""

View File

@@ -73,14 +73,19 @@ _EOF
# create the dotfile
echo 'src:{{@@ _dotfile_abs_src @@}}' > ${tmps}/dotfiles/abc
echo 'dst:{{@@ _dotfile_abs_dst @@}}' >> ${tmps}/dotfiles/abc
echo 'key:{{@@ _dotfile_key @@}}' >> ${tmps}/dotfiles/abc
echo 'link:{{@@ _dotfile_link @@}}' >> ${tmps}/dotfiles/abc
# install
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
# checks
[ ! -e ${tmpd}/abc ] && echo 'dotfile not installed' && exit 1
#cat ${tmpd}/abc
grep "src:${tmps}/dotfiles/abc" ${tmpd}/abc >/dev/null
grep "dst:${tmpd}/abc" ${tmpd}/abc >/dev/null
grep "key:f_abc" ${tmpd}/abc >/dev/null
grep "link:nolink" ${tmpd}/abc >/dev/null
## CLEANING
rm -rf ${tmps} ${tmpd}

View File

@@ -64,10 +64,14 @@ dotfiles:
f_abc:
dst: ${tmpd}/abc
src: abc
f_def:
dst: ${tmpd}/def
src: def
profiles:
p1:
dotfiles:
- f_abc
- f_def
_EOF
#cat ${cfg}
@@ -98,6 +102,22 @@ _EOF
#cat ${tmps}/dotfiles/abc
echo "this is def" > ${tmps}/dotfiles/def
# test basename
cat >> ${tmps}/dotfiles/def << _EOF
{%@@ set dotfile_filename = basename( _dotfile_abs_dst ) @@%}
dotfile dst filename: {{@@ dotfile_filename @@}}
_EOF
# test dirname
cat >> ${tmps}/dotfiles/def << _EOF
{%@@ set dotfile_dirname= dirname( _dotfile_abs_dst ) @@%}
dotfile dst dirname: {{@@ dotfile_dirname @@}}
_EOF
#cat ${tmps}/dotfiles/def
# install
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
@@ -112,6 +132,10 @@ set -e
#cat ${tmpd}/abc
# test def
grep "dotfile dst filename: `basename ${tmpd}/def`" ${tmpd}/def
grep "dotfile dst dirname: `dirname ${tmpd}/def`" ${tmpd}/def
## CLEANING
rm -rf ${tmps} ${tmpd} ${scr}