mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-09 08:19:17 +00:00
disable debug in tests with env var
This commit is contained in:
@@ -18,6 +18,8 @@ from dotdrop.config import Cfg
|
|||||||
ENV_PROFILE = 'DOTDROP_PROFILE'
|
ENV_PROFILE = 'DOTDROP_PROFILE'
|
||||||
ENV_CONFIG = 'DOTDROP_CONFIG'
|
ENV_CONFIG = 'DOTDROP_CONFIG'
|
||||||
ENV_NOBANNER = 'DOTDROP_NOBANNER'
|
ENV_NOBANNER = 'DOTDROP_NOBANNER'
|
||||||
|
ENV_DEBUG = 'DOTDROP_DEBUG'
|
||||||
|
ENV_NODEBUG = 'DOTDROP_FORCE_NODEBUG'
|
||||||
BACKUP_SUFFIX = '.dotdropbak'
|
BACKUP_SUFFIX = '.dotdropbak'
|
||||||
|
|
||||||
PROFILE = socket.gethostname()
|
PROFILE = socket.gethostname()
|
||||||
@@ -98,6 +100,10 @@ class Options(AttrMonitor):
|
|||||||
self.args = docopt(USAGE, version=VERSION)
|
self.args = docopt(USAGE, version=VERSION)
|
||||||
self.log = Logger()
|
self.log = Logger()
|
||||||
self.debug = self.args['--verbose']
|
self.debug = self.args['--verbose']
|
||||||
|
if not self.debug and ENV_DEBUG in os.environ:
|
||||||
|
self.debug = True
|
||||||
|
if ENV_NODEBUG in os.environ:
|
||||||
|
self.debug = False
|
||||||
self.profile = self.args['--profile']
|
self.profile = self.args['--profile']
|
||||||
self.confpath = os.path.expanduser(self.args['--cfg'])
|
self.confpath = os.path.expanduser(self.args['--cfg'])
|
||||||
if self.debug:
|
if self.debug:
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ profiles:
|
|||||||
- d_dir
|
- d_dir
|
||||||
- d_dlink
|
- d_dlink
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo 'test' > ${tmps}/dotfiles/abc
|
echo 'test' > ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -103,12 +103,12 @@ cd ${ddpath} | ${bin} compare -c ${cfg} --verbose --ignore=${patt}
|
|||||||
[ "$?" = "0" ] && exit 1
|
[ "$?" = "0" ] && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# adding ignore in dotfile
|
# adding ignore in dotfile
|
||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*/config/b"' ${cfg} > ${cfg2}
|
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*/config/b"' ${cfg} > ${cfg2}
|
||||||
cat ${cfg2}
|
#cat ${cfg2}
|
||||||
|
|
||||||
# expects one diff
|
# expects one diff
|
||||||
echo "[+] comparing with ignore in dotfile - 1 diff"
|
echo "[+] comparing with ignore in dotfile - 1 diff"
|
||||||
@@ -121,7 +121,7 @@ set -e
|
|||||||
cfg2="${basedir}/config2.yaml"
|
cfg2="${basedir}/config2.yaml"
|
||||||
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*b"' ${cfg} > ${cfg2}
|
sed '/d_config:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*b"' ${cfg} > ${cfg2}
|
||||||
sed -i '/d_program:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*b"' ${cfg2}
|
sed -i '/d_program:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*b"' ${cfg2}
|
||||||
cat ${cfg2}
|
#cat ${cfg2}
|
||||||
|
|
||||||
# expects no diff
|
# expects no diff
|
||||||
patt="*b"
|
patt="*b"
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the imported one
|
# create the imported one
|
||||||
mkdir -p ${tmps}/dotfiles/${tmpd}
|
mkdir -p ${tmps}/dotfiles/${tmpd}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "test" > ${tmps}/dotfiles/abc
|
echo "test" > ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ dpath @@}}" > ${tmps}/dotfiles/abc
|
echo "{{@@ dpath @@}}" > ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ profiles:
|
|||||||
include:
|
include:
|
||||||
- profile{{@@ dvar1 @@}}
|
- profile{{@@ dvar1 @@}}
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
c1="content:abc"
|
c1="content:abc"
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ var1 @@}}" > ${tmps}/dotfiles/abc
|
echo "{{@@ var1 @@}}" > ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ header() @@}}" > ${tmps}/dotfiles/abc
|
echo "{{@@ header() @@}}" > ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "this is the test dotfile" > ${tmps}/dotfiles/abc
|
echo "this is the test dotfile" > ${tmps}/dotfiles/abc
|
||||||
@@ -83,12 +83,12 @@ echo "{%@@ if exists('/dev/abcdef') @@%}" >> ${tmps}/dotfiles/abc
|
|||||||
echo "this should not exist" >> ${tmps}/dotfiles/abc
|
echo "this should not exist" >> ${tmps}/dotfiles/abc
|
||||||
echo "{%@@ endif @@%}" >> ${tmps}/dotfiles/abc
|
echo "{%@@ endif @@%}" >> ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
cat ${tmps}/dotfiles/abc
|
#cat ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||||
|
|
||||||
cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
|
|
||||||
grep '^this should exist' ${tmpd}/abc >/dev/null
|
grep '^this should exist' ${tmpd}/abc >/dev/null
|
||||||
grep -v '^this should not exist' ${tmpd}/abc >/dev/null
|
grep -v '^this should not exist' ${tmpd}/abc >/dev/null
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmps}/dotfiles/abc
|
mkdir -p ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
mkdir -p ${tmps}/dotfiles/abc
|
mkdir -p ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/abc
|
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "===================" > ${tmps}/dotfiles/abc
|
echo "===================" > ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "var3: {{@@ var3 @@}}" > ${tmps}/dotfiles/abc
|
echo "var3: {{@@ var3 @@}}" > ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ profiles:
|
|||||||
- f_def
|
- f_def
|
||||||
- d_ghi
|
- d_ghi
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the base64 dotfile
|
# create the base64 dotfile
|
||||||
tmpf=`mktemp --suffix='-dotdrop-tests'`
|
tmpf=`mktemp --suffix='-dotdrop-tests'`
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
#tree ${dt}
|
#tree ${dt}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "head" > ${tmps}/dotfiles/abc
|
echo "head" > ${tmps}/dotfiles/abc
|
||||||
@@ -92,14 +92,14 @@ echo "is p1" >> ${tmpd}/abc
|
|||||||
echo "tail" >> ${tmpd}/abc
|
echo "tail" >> ${tmpd}/abc
|
||||||
|
|
||||||
# update
|
# update
|
||||||
cat ${tmps}/dotfiles/abc
|
#cat ${tmps}/dotfiles/abc
|
||||||
set +e
|
set +e
|
||||||
patch=`cd ${ddpath} | ${bin} update -P -p p1 -k f_abc --cfg ${cfg} 2>&1 | grep 'try patching with' | sed 's/"//g'`
|
patch=`cd ${ddpath} | ${bin} update -P -p p1 -k f_abc --cfg ${cfg} 2>&1 | grep 'try patching with' | sed 's/"//g'`
|
||||||
set -e
|
set -e
|
||||||
patch=`echo ${patch} | sed 's/^.*: //g'`
|
patch=`echo ${patch} | sed 's/^.*: //g'`
|
||||||
echo "patching with: ${patch}"
|
echo "patching with: ${patch}"
|
||||||
eval ${patch}
|
eval ${patch}
|
||||||
cat ${tmps}/dotfiles/abc
|
#cat ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
## CLEANING
|
## CLEANING
|
||||||
rm -rf ${tmps} ${tmpd} ${tmpw}
|
rm -rf ${tmps} ${tmpd} ${tmpw}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ var1 @@}}" > ${tmps}/dotfiles/abc
|
echo "{{@@ var1 @@}}" > ${tmps}/dotfiles/abc
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ profile @@}}" > ${tmpf}/abc
|
echo "{{@@ profile @@}}" > ${tmpf}/abc
|
||||||
@@ -138,7 +138,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ profile @@}}" > ${tmpf}/abc
|
echo "{{@@ profile @@}}" > ${tmpf}/abc
|
||||||
@@ -189,7 +189,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ profile @@}}" > ${tmpf}/abc
|
echo "{{@@ profile @@}}" > ${tmpf}/abc
|
||||||
|
|||||||
3
tests.sh
3
tests.sh
@@ -25,6 +25,9 @@ which ${nosebin} 2>/dev/null
|
|||||||
[ "$?" != "0" ] && echo "Install nosetests" && exit 1
|
[ "$?" != "0" ] && echo "Install nosetests" && exit 1
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# comment this to get debug info
|
||||||
|
export DOTDROP_FORCE_NODEBUG=
|
||||||
|
|
||||||
# execute tests with coverage
|
# execute tests with coverage
|
||||||
PYTHONPATH=dotdrop ${nosebin} -s --with-coverage --cover-package=dotdrop
|
PYTHONPATH=dotdrop ${nosebin} -s --with-coverage --cover-package=dotdrop
|
||||||
#PYTHONPATH=dotdrop python3 -m pytest tests
|
#PYTHONPATH=dotdrop python3 -m pytest tests
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import string
|
|||||||
import random
|
import random
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from dotdrop.options import Options
|
from dotdrop.options import Options, ENV_NODEBUG
|
||||||
from dotdrop.linktypes import LinkTypes
|
from dotdrop.linktypes import LinkTypes
|
||||||
from dotdrop.utils import strip_home
|
from dotdrop.utils import strip_home
|
||||||
|
|
||||||
@@ -128,6 +128,8 @@ def load_options(confpath, profile):
|
|||||||
o.link = LinkTypes.NOLINK.value
|
o.link = LinkTypes.NOLINK.value
|
||||||
o.install_showdiff = True
|
o.install_showdiff = True
|
||||||
o.debug = True
|
o.debug = True
|
||||||
|
if ENV_NODEBUG in os.environ:
|
||||||
|
o.debug = False
|
||||||
o.compare_dopts = ''
|
o.compare_dopts = ''
|
||||||
o.variables = {}
|
o.variables = {}
|
||||||
return o
|
return o
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ class TestCompare(unittest.TestCase):
|
|||||||
def compare(self, o, tmp, nbdotfiles):
|
def compare(self, o, tmp, nbdotfiles):
|
||||||
dotfiles = o.dotfiles
|
dotfiles = o.dotfiles
|
||||||
self.assertTrue(len(dotfiles) == nbdotfiles)
|
self.assertTrue(len(dotfiles) == nbdotfiles)
|
||||||
t = Templategen(base=o.dotpath, debug=True)
|
t = Templategen(base=o.dotpath, debug=o.debug)
|
||||||
inst = Installer(create=o.create, backup=o.backup,
|
inst = Installer(create=o.create, backup=o.backup,
|
||||||
dry=o.dry, base=o.dotpath, debug=True)
|
dry=o.dry, base=o.dotpath, debug=o.debug)
|
||||||
comp = Comparator()
|
comp = Comparator()
|
||||||
results = {}
|
results = {}
|
||||||
for dotfile in dotfiles:
|
for dotfile in dotfiles:
|
||||||
|
|||||||
@@ -186,7 +186,6 @@ exec bspwm
|
|||||||
# install them
|
# install them
|
||||||
o = load_options(confpath, profile)
|
o = load_options(confpath, profile)
|
||||||
o.safe = False
|
o.safe = False
|
||||||
o.debug = True
|
|
||||||
o.install_showdiff = True
|
o.install_showdiff = True
|
||||||
o.variables = {}
|
o.variables = {}
|
||||||
cmd_install(o)
|
cmd_install(o)
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ class TestUpdate(unittest.TestCase):
|
|||||||
create=self.CONFIG_CREATE)
|
create=self.CONFIG_CREATE)
|
||||||
self.assertTrue(os.path.exists(confpath))
|
self.assertTrue(os.path.exists(confpath))
|
||||||
o = load_options(confpath, profile)
|
o = load_options(confpath, profile)
|
||||||
o.debug = True
|
|
||||||
o.update_showpatch = True
|
o.update_showpatch = True
|
||||||
dfiles = [d1, dir1, d2, d3t, dsubstmp]
|
dfiles = [d1, dir1, d2, d3t, dsubstmp]
|
||||||
|
|
||||||
@@ -105,7 +104,6 @@ class TestUpdate(unittest.TestCase):
|
|||||||
# get new config
|
# get new config
|
||||||
o = load_options(confpath, profile)
|
o = load_options(confpath, profile)
|
||||||
o.safe = False
|
o.safe = False
|
||||||
o.debug = True
|
|
||||||
o.update_showpatch = True
|
o.update_showpatch = True
|
||||||
trans = Transform('trans', 'cp -r {0} {1}')
|
trans = Transform('trans', 'cp -r {0} {1}')
|
||||||
d3tb = os.path.basename(d3t)
|
d3tb = os.path.basename(d3t)
|
||||||
|
|||||||
Reference in New Issue
Block a user