mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 18:34:48 +00:00
fix tests and compare return value
This commit is contained in:
@@ -112,17 +112,19 @@ def install(opts, conf):
|
|||||||
|
|
||||||
|
|
||||||
def compare(opts, conf, tmp, focus=None):
|
def compare(opts, conf, tmp, focus=None):
|
||||||
|
'''compare dotfiles and return True if all same'''
|
||||||
dotfiles = conf.get_dotfiles(opts['profile'])
|
dotfiles = conf.get_dotfiles(opts['profile'])
|
||||||
if dotfiles == []:
|
if dotfiles == []:
|
||||||
LOG.err('no dotfiles defined for this profile (\"%s\")' %
|
LOG.err('no dotfiles defined for this profile (\"%s\")' %
|
||||||
(str(opts['profile'])))
|
(str(opts['profile'])))
|
||||||
return False
|
return True
|
||||||
t = Templategen(base=opts['dotpath'])
|
t = Templategen(base=opts['dotpath'])
|
||||||
inst = Installer(create=opts['create'], backup=opts['backup'],
|
inst = Installer(create=opts['create'], backup=opts['backup'],
|
||||||
dry=opts['dry'], base=opts['dotpath'],
|
dry=opts['dry'], base=opts['dotpath'],
|
||||||
quiet=opts['quiet'])
|
quiet=opts['quiet'])
|
||||||
|
|
||||||
# compare only specific files
|
# compare only specific files
|
||||||
|
ret = True
|
||||||
selected = dotfiles
|
selected = dotfiles
|
||||||
if focus:
|
if focus:
|
||||||
selected = []
|
selected = []
|
||||||
@@ -132,11 +134,11 @@ def compare(opts, conf, tmp, focus=None):
|
|||||||
selected.append(df)
|
selected.append(df)
|
||||||
else:
|
else:
|
||||||
LOG.err('no dotfile matches \"%s\"' % (selection))
|
LOG.err('no dotfile matches \"%s\"' % (selection))
|
||||||
|
ret = False
|
||||||
|
|
||||||
if len(selected) < 1:
|
if len(selected) < 1:
|
||||||
return True
|
return ret
|
||||||
|
|
||||||
ret = True
|
|
||||||
for dotfile in selected:
|
for dotfile in selected:
|
||||||
same, diff = inst.compare(t, tmp, opts['profile'],
|
same, diff = inst.compare(t, tmp, opts['profile'],
|
||||||
dotfile.src, dotfile.dst,
|
dotfile.src, dotfile.dst,
|
||||||
|
|||||||
@@ -135,9 +135,9 @@ class TestCompare(unittest.TestCase):
|
|||||||
self.assertTrue(results == expected)
|
self.assertTrue(results == expected)
|
||||||
|
|
||||||
# test compare from dotdrop
|
# test compare from dotdrop
|
||||||
self.assertTrue(compare(opts, conf, tmp))
|
self.assertFalse(compare(opts, conf, tmp))
|
||||||
# test focus
|
# test focus
|
||||||
self.assertTrue(compare(opts, conf, tmp, focus=d4))
|
self.assertFalse(compare(opts, conf, tmp, focus=d4))
|
||||||
self.assertFalse(compare(opts, conf, tmp, focus='/tmp/fake'))
|
self.assertFalse(compare(opts, conf, tmp, focus='/tmp/fake'))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user