1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-07 13:58:25 +00:00

Refactoring "import-variables" test to detect the real problem, "macro-with-globals", as explained in #250

This commit is contained in:
Davide Laezza
2020-08-29 19:50:34 +02:00
parent 546e13b4a6
commit bf3f5b9c9c

View File

@@ -52,17 +52,13 @@ mkdir -p ${tmps}/dotfiles
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d` tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
# create the config file # create the config file
cfg1="${tmps}/config1.yaml" cfg="${tmps}/config.yaml"
cfg2="${tmps}/config2.yaml"
varf="${tmps}/variables.yaml"
cat > ${cfg1} << _EOF cat > ${cfg} << _EOF
config: config:
backup: true backup: true
create: true create: true
dotpath: dotfiles dotpath: dotfiles
import_configs:
- ${cfg2}
dotfiles: dotfiles:
f_abc: f_abc:
dst: ${tmpd}/abc dst: ${tmpd}/abc
@@ -71,40 +67,33 @@ profiles:
p0: p0:
dotfiles: dotfiles:
- f_abc - f_abc
_EOF
cat > ${cfg2} << _EOF
config:
backup: true
create: true
dotpath: dotfiles-other
import_variables:
- ${varf}
dotfiles:
profiles:
_EOF
cat > ${varf} << _EOF
variables: variables:
var1: var1value global: global_var
dynvariables: local: local_var
dvar1: "echo dvar1value"
_EOF _EOF
# create the source # create the source
mkdir -p ${tmps}/dotfiles/ mkdir -p ${tmps}/dotfiles/
echo "start" > ${tmps}/dotfiles/abc
echo "{{@@ var1 @@}}" >> ${tmps}/dotfiles/abc cat > ${tmps}/dotfiles/macro_file << _EOF
echo "{{@@ dvar1 @@}}" >> ${tmps}/dotfiles/abc {%@@ macro macro(var) @@%}
echo "end" >> ${tmps}/dotfiles/abc {{@@ global @@}}
{{@@ var @@}}
{%@@ endmacro @@%}
_EOF
cat > ${tmps}/dotfiles/abc << _EOF
{%@@ from 'macro_file' import macro @@%}
{{@@ macro(local) @@}}
_EOF
# install # install
cd ${ddpath} | ${bin} install -c ${cfg1} -p p0 -V cd ${ddpath} | ${bin} install -c ${cfg} -p p0 -V
# test file content # test file content
cat ${tmpd}/abc cat ${tmpd}/abc
grep 'var1value' ${tmpd}/abc >/dev/null 2>&1 grep 'global_var' ${tmpd}/abc >/dev/null 2>&1
grep 'dvar1value' ${tmpd}/abc >/dev/null 2>&1 grep 'local_var' ${tmpd}/abc >/dev/null 2>&1
## CLEANING ## CLEANING
rm -rf ${tmps} ${tmpd} rm -rf ${tmps} ${tmpd}