1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-11 23:34:00 +00:00

Merge pull request #168 from davla/master

Action-args-template tests + included profile variables
This commit is contained in:
deadc0de
2019-06-19 19:32:01 +02:00
committed by GitHub

View File

@@ -45,6 +45,20 @@ echo -e "\e[96m\e[1m==> RUNNING $(basename $BASH_SOURCE) <==\e[0m"
# this is the test # this is the test
################################################################ ################################################################
# Convenience function to grep into a file and exit with an erro message if the
# content is not found
should_grep() {
SHOULD_GREP_STR="$1"
SHOULD_GREP_FILE="$2"
grep "$SHOULD_GREP_STR" "$SHOULD_GREP_FILE" > /dev/null || {
echo >&2 "$SHOULD_GREP_STR not found in $SHOULD_GREP_FILE"
exit 1
}
unset SHOULD_GREP_FILE SHOULD_GREP_STR
}
# the action temp # the action temp
tmpa=`mktemp -d --suffix='-dotdrop-tests'` tmpa=`mktemp -d --suffix='-dotdrop-tests'`
# the dotfile source # the dotfile source
@@ -63,7 +77,7 @@ actions:
post: post:
postaction: "echo {0} > ${tmpa}/post" postaction: "echo {0} > ${tmpa}/post"
nakedaction: "echo {0} > ${tmpa}/naked" nakedaction: "echo {0} > ${tmpa}/naked"
profileaction: "echo {0} > ${tmpa}/profile" profileaction: "echo {0} >> ${tmpa}/profile"
dynaction: "echo {0} > ${tmpa}/dyn" dynaction: "echo {0} > ${tmpa}/dyn"
config: config:
backup: true backup: true
@@ -84,11 +98,20 @@ profiles:
actions: actions:
- profileaction '{{@@ var_profile @@}}' - profileaction '{{@@ var_profile @@}}'
- dynaction '{{@@ user_name @@}}' - dynaction '{{@@ user_name @@}}'
include:
- p2
p2:
dotfiles:
- f_abc
actions:
- profileaction '{{@@ var_profile_2 @@}}'
variables:
var_profile_2: profile_var_2
variables: variables:
var_pre: abc var_pre: pre_var
var_post: def var_post: post_var
var_naked: ghi var_naked: naked_var
var_profile: jkl var_profile: profile_var
dynvariables: dynvariables:
user_name: 'echo $USER' user_name: 'echo $USER'
_EOF _EOF
@@ -106,16 +129,12 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
[ ! -e ${tmpa}/naked ] && echo 'naked action not executed' && exit 1 [ ! -e ${tmpa}/naked ] && echo 'naked action not executed' && exit 1
[ ! -e ${tmpa}/profile ] && echo 'profile action not executed' && exit 1 [ ! -e ${tmpa}/profile ] && echo 'profile action not executed' && exit 1
[ ! -e ${tmpa}/dyn ] && echo 'dynamic acton action not executed' && exit 1 [ ! -e ${tmpa}/dyn ] && echo 'dynamic acton action not executed' && exit 1
cat ${tmpa}/pre should_grep pre_var ${tmpa}/pre
grep abc ${tmpa}/pre >/dev/null should_grep post_var ${tmpa}/post
cat ${tmpa}/post should_grep naked_var ${tmpa}/naked
grep def ${tmpa}/post >/dev/null should_grep profile_var ${tmpa}/profile
cat ${tmpa}/naked should_grep profile_var_2 ${tmpa}/profile
grep ghi ${tmpa}/naked >/dev/null should_grep "$USER" ${tmpa}/dyn
cat ${tmpa}/profile
grep jkl ${tmpa}/profile >/dev/null
cat ${tmpa}/dyn
grep "$USER" ${tmpa}/dyn >/dev/null
## CLEANING ## CLEANING
rm -rf ${tmps} ${tmpd} ${tmpa} rm -rf ${tmps} ${tmpd} ${tmpa}