-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:deadc0de6/dotdrop
- Loading branch information
Showing
9 changed files
with
184 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Test latest dotdrop | ||
|
||
If you installed dotdrop from a package but want to test | ||
you current setup with the latest version from git | ||
(or from a specific branch), you can do the following | ||
|
||
```bash | ||
$ cd /tmp/ | ||
$ git clone https://github.com/deadc0de6/dotdrop.git | ||
$ cd dotdrop | ||
## switch to a specific branch if needed | ||
$ git checkout <branch-name> | ||
$ ./dotdrop.sh --cfg <path-to-your-config-file.yaml> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
#!/usr/bin/env bash | ||
# author: deadc0de6 (https://github.com/deadc0de6) | ||
# Copyright (c) 2023, deadc0de6 | ||
# | ||
# test import_variables | ||
# returns 1 in case of error | ||
# see issue 380 | ||
# | ||
|
||
# exit on first error | ||
set -e | ||
|
||
# all this crap to get current path | ||
rl="readlink -f" | ||
if ! ${rl} "${0}" >/dev/null 2>&1; then | ||
rl="realpath" | ||
|
||
if ! hash ${rl}; then | ||
echo "\"${rl}\" not found !" && exit 1 | ||
fi | ||
fi | ||
cur=$(dirname "$(${rl} "${0}")") | ||
|
||
#hash dotdrop >/dev/null 2>&1 | ||
#[ "$?" != "0" ] && echo "install dotdrop to run tests" && exit 1 | ||
|
||
#echo "called with ${1}" | ||
|
||
# dotdrop path can be pass as argument | ||
ddpath="${cur}/../" | ||
[ "${1}" != "" ] && ddpath="${1}" | ||
[ ! -d "${ddpath}" ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1 | ||
|
||
export PYTHONPATH="${ddpath}:${PYTHONPATH}" | ||
bin="python3 -m dotdrop.dotdrop" | ||
if hash coverage 2>/dev/null; then | ||
bin="coverage run -p --source=dotdrop -m dotdrop.dotdrop" | ||
fi | ||
|
||
echo "dotdrop path: ${ddpath}" | ||
echo "pythonpath: ${PYTHONPATH}" | ||
|
||
# get the helpers | ||
# shellcheck source=tests-ng/helpers | ||
source "${cur}"/helpers | ||
|
||
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)" | ||
|
||
################################################################ | ||
# this is the test | ||
################################################################ | ||
|
||
# the dotfile source | ||
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d) | ||
mkdir -p "${tmps}"/dotfiles | ||
# the dotfile destination | ||
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d) | ||
|
||
clear_on_exit "${tmps}" | ||
clear_on_exit "${tmpd}" | ||
|
||
# create the config file | ||
cfg="${tmps}/config.yaml" | ||
cfgvar1="${tmps}/var1.yaml" | ||
cfgvar2="${tmps}/var2.yaml" | ||
|
||
cat << _EOF > "${tmps}/dotfiles/abc" | ||
var1: {{@@ var1 @@}} | ||
var2: {{@@ var2 @@}} | ||
var3: {{@@ var3 @@}} | ||
var4: {{@@ var4 @@}} | ||
var5: {{@@ var5 @@}} | ||
var6: {{@@ var6 @@}} | ||
_EOF | ||
|
||
cat > "${cfg}" << _EOF | ||
config: | ||
backup: true | ||
create: true | ||
dotpath: dotfiles | ||
import_variables: | ||
- ${cfgvar1} | ||
- ${cfgvar2} | ||
variables: | ||
var1: "this is var1 from main config" | ||
var2: "this is var2 from main config" | ||
var3: "this is var3 from main config" | ||
dotfiles: | ||
f_abc: | ||
dst: ${tmpd}/abc | ||
src: 'abc' | ||
profiles: | ||
p1: | ||
dotfiles: | ||
- f_abc | ||
_EOF | ||
echo "main config: ${cfg}" | ||
cat "${cfg}" | ||
|
||
cat << _EOF > "${cfgvar1}" | ||
variables: | ||
var2: "this is var2 from sub1" | ||
var3: "this is var3 from sub1" | ||
var4: "this is var4 from sub1" | ||
var5: "this is var5 from sub1" | ||
_EOF | ||
echo "cfgvar1: ${cfgvar1}" | ||
cat "${cfgvar1}" | ||
|
||
cat << _EOF > "${cfgvar2}" | ||
variables: | ||
var3: "this is var3 from sub2" | ||
var4: "this is var4 from sub2" | ||
var6: "this is var6 from sub2" | ||
_EOF | ||
echo "cfgvar2: ${cfgvar2}" | ||
cat "${cfgvar2}" | ||
|
||
# install | ||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 --verbose | ||
|
||
# test file existence | ||
[ -f "${tmpd}/abc" ] || { | ||
echo 'Dotfile not installed' | ||
exit 1 | ||
} | ||
|
||
# test file content | ||
cat "${tmpd}"/abc | ||
echo "----------------------" | ||
grep '^var1: this is var1 from main config$' "${tmpd}"/abc >/dev/null | ||
echo "var1 ok" | ||
grep '^var2: this is var2 from sub1$' "${tmpd}"/abc >/dev/null | ||
echo "var2 ok" | ||
grep '^var3: this is var3 from sub2$' "${tmpd}"/abc >/dev/null | ||
echo "var3 ok" | ||
grep '^var4: this is var4 from sub2$' "${tmpd}"/abc >/dev/null | ||
echo "var4 ok" | ||
grep '^var5: this is var5 from sub1$' "${tmpd}"/abc >/dev/null | ||
echo "var5 ok" | ||
grep '^var6: this is var6 from sub2$' "${tmpd}"/abc >/dev/null | ||
echo "var6 ok" | ||
|
||
echo "OK" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters