1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 18:34:48 +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`
# create the config file
cfg1="${tmps}/config1.yaml"
cfg2="${tmps}/config2.yaml"
varf="${tmps}/variables.yaml"
cfg="${tmps}/config.yaml"
cat > ${cfg1} << _EOF
cat > ${cfg} << _EOF
config:
backup: true
create: true
dotpath: dotfiles
import_configs:
- ${cfg2}
dotfiles:
f_abc:
dst: ${tmpd}/abc
@@ -71,40 +67,33 @@ profiles:
p0:
dotfiles:
- f_abc
_EOF
cat > ${cfg2} << _EOF
config:
backup: true
create: true
dotpath: dotfiles-other
import_variables:
- ${varf}
dotfiles:
profiles:
_EOF
cat > ${varf} << _EOF
variables:
var1: var1value
dynvariables:
dvar1: "echo dvar1value"
global: global_var
local: local_var
_EOF
# create the source
mkdir -p ${tmps}/dotfiles/
echo "start" > ${tmps}/dotfiles/abc
echo "{{@@ var1 @@}}" >> ${tmps}/dotfiles/abc
echo "{{@@ dvar1 @@}}" >> ${tmps}/dotfiles/abc
echo "end" >> ${tmps}/dotfiles/abc
cat > ${tmps}/dotfiles/macro_file << _EOF
{%@@ macro macro(var) @@%}
{{@@ global @@}}
{{@@ var @@}}
{%@@ endmacro @@%}
_EOF
cat > ${tmps}/dotfiles/abc << _EOF
{%@@ from 'macro_file' import macro @@%}
{{@@ macro(local) @@}}
_EOF
# install
cd ${ddpath} | ${bin} install -c ${cfg1} -p p0 -V
cd ${ddpath} | ${bin} install -c ${cfg} -p p0 -V
# test file content
cat ${tmpd}/abc
grep 'var1value' ${tmpd}/abc >/dev/null 2>&1
grep 'dvar1value' ${tmpd}/abc >/dev/null 2>&1
grep 'global_var' ${tmpd}/abc >/dev/null 2>&1
grep 'local_var' ${tmpd}/abc >/dev/null 2>&1
## CLEANING
rm -rf ${tmps} ${tmpd}