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

fix bug for #204

This commit is contained in:
deadc0de6
2020-01-21 09:03:24 +01:00
parent d242742d24
commit 53dfbc8aa3
3 changed files with 66 additions and 3 deletions

View File

@@ -53,9 +53,11 @@ tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
#echo "dotfile destination: ${tmpd}"
filter_file=`mktemp`
filter_file2=`mktemp`
filter_file3=`mktemp`
# create the config file
cfg="${tmps}/config.yaml"
cfgext="${tmps}/ext.yaml"
cat > ${cfg} << _EOF
config:
@@ -65,6 +67,8 @@ config:
filter_file:
- ${filter_file}
- ${filter_file2}
import_configs:
- ${cfgext}
dotfiles:
f_abc:
dst: ${tmpd}/abc
@@ -76,6 +80,17 @@ profiles:
_EOF
#cat ${cfg}
cat > ${cfgext} << _EOF
config:
backup: true
create: true
dotpath: dotfiles
filter_file:
- ${filter_file3}
profiles:
dotfiles:
_EOF
cat << _EOF > ${filter_file}
def filter1(arg1):
return "filtered"
@@ -88,6 +103,11 @@ def filter3(integer):
return str(int(integer) - 10)
_EOF
cat << _EOF > ${filter_file3}
def filter_ext(arg1):
return "external"
_EOF
# create the dotfile
echo "this is the test dotfile" > ${tmps}/dotfiles/abc
@@ -95,6 +115,7 @@ echo "this is the test dotfile" > ${tmps}/dotfiles/abc
echo "{{@@ "abc" | filter1 @@}}" >> ${tmps}/dotfiles/abc
echo "{{@@ "arg1" | filter2('arg2') @@}}" >> ${tmps}/dotfiles/abc
echo "{{@@ "13" | filter3() @@}}" >> ${tmps}/dotfiles/abc
echo "{{@@ "something" | filter_ext() @@}}" >> ${tmps}/dotfiles/abc
# install
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
@@ -104,9 +125,13 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
grep '^filtered$' ${tmpd}/abc >/dev/null
grep '^arg2$' ${tmpd}/abc >/dev/null
grep '^3$' ${tmpd}/abc >/dev/null
grep '^external$' ${tmpd}/abc >/dev/null
set +e
grep '^something$' ${tmpd}/abc >/dev/null && exit 1
set -e
## CLEANING
rm -rf ${tmps} ${tmpd} ${filter_file} ${filter_file2}
rm -rf ${tmps} ${tmpd} ${filter_file} ${filter_file2} ${filter_file3}
echo "OK"
exit 0

View File

@@ -53,9 +53,11 @@ tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
#echo "dotfile destination: ${tmpd}"
func_file=`mktemp`
func_file2=`mktemp`
func_file3=`mktemp`
# create the config file
cfg="${tmps}/config.yaml"
cfgext="${tmps}/ext.yaml"
cat > ${cfg} << _EOF
config:
@@ -65,6 +67,8 @@ config:
func_file:
- ${func_file}
- ${func_file2}
import_configs:
- ${cfgext}
dotfiles:
f_abc:
dst: ${tmpd}/abc
@@ -76,6 +80,17 @@ profiles:
_EOF
#cat ${cfg}
cat > ${cfgext} << _EOF
config:
backup: true
create: true
dotpath: dotfiles
func_file:
- ${func_file3}
dotfiles:
profiles:
_EOF
cat << _EOF > ${func_file}
def func1(something):
if something:
@@ -88,6 +103,11 @@ def func2(inp):
return not inp
_EOF
cat << _EOF > ${func_file3}
def func3(inp):
return "external"
_EOF
# create the dotfile
echo "this is the test dotfile" > ${tmps}/dotfiles/abc
@@ -108,6 +128,10 @@ echo "{%@@ if func2(False) @@%}" >> ${tmps}/dotfiles/abc
echo "yes" >> ${tmps}/dotfiles/abc
echo "{%@@ endif @@%}" >> ${tmps}/dotfiles/abc
echo "{%@@ if func3("whatever") == "external" @@%}" >> ${tmps}/dotfiles/abc
echo "externalok" >> ${tmps}/dotfiles/abc
echo "{%@@ endif @@%}" >> ${tmps}/dotfiles/abc
# install
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
@@ -116,12 +140,13 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
grep '^this should exist$' ${tmpd}/abc >/dev/null
grep '^this should exist too$' ${tmpd}/abc >/dev/null
grep '^yes$' ${tmpd}/abc >/dev/null
grep '^externalok$' ${tmpd}/abc >/dev/null
set +e
grep '^nope$' ${tmpd}/abc >/dev/null && exit 1
set -e
## CLEANING
rm -rf ${tmps} ${tmpd} ${func_file} ${func_file2}
rm -rf ${tmps} ${tmpd} ${func_file} ${func_file2} ${func_file3}
echo "OK"
exit 0