Warning!

Notice: the grml team is migrating from Mercurial to Git.
Please visit git.grml.org instead!

reposearch: change and unittest searching in current directory
authorMichael Gebetsroither <michael.geb@gmx.at>
Sat Mar 29 14:04:38 2008 +0100 (8 months ago)
changeset 18986b21ea39b2e
manifest86b21ea39b2e
parent 188b557ae7e33cd
child 1907ecc67a45181
reposearch: change and unittest searching in current directory
reposearch
tests/reposearch_data/repoinner/git.git/config
tests/reposearch_data/repoinner/git/.git/config
tests/reposearch_tests.py
--- a/reposearch Sat Mar 29 13:06:39 2008 +0100
+++ b/reposearch Sat Mar 29 14:04:38 2008 +0100
@@ -32,9 +32,10 @@ def repofilter(dir, x):
return os.path.isdir(os.path.join(dir, x))
def gitbarefilter(dir, x):
- if dir.endswith(x):
- if len(os.path.basename(dir)) >4:
- if os.path.exists(os.path.join(dir, 'config')):
+ tmp = os.path.abspath(dir)
+ if tmp.endswith(x):
+ if len(os.path.basename(tmp)) >4:
+ if os.path.exists(os.path.join(tmp, 'config')):
return True
return False
--- a/tests/reposearch_tests.py Sat Mar 29 13:06:39 2008 +0100
+++ b/tests/reposearch_tests.py Sat Mar 29 14:04:38 2008 +0100
@@ -15,18 +15,18 @@ class Base(unittest.TestCase):
old = op.abspath(os.curdir)
dir = self.dir
if append_dir != None:
- op.join(dir, append_dir)
- os.chdir(self.dir)
+ dir = op.join(dir, append_dir)
+ os.chdir(dir)
try:
tmp = f()
finally:
os.chdir(old)
return tmp
- def innerT(self, walkfun, testdir, repotype, filter_fun=None):
+ def innerT(self, walkfun, testdir, repotype, filter_fun=None, append_dir=None):
'''Test walkfun()/2 inside testdir on repotype'''
filter_fun = filter_fun or rs.repo_types[repotype]
should = self.data
- curr = sorted(self.inner(lambda: list(walkfun(testdir, filter_fun))))
+ curr = sorted(self.inner(lambda: list(walkfun(testdir, filter_fun)), append_dir))
self.assertEqual(should, curr)
def outerT(self, walkfun, testdir, repotype, filter_fun=None):
'''Test walkfun()/2 from outside testdir on repotype'''
@@ -88,6 +88,17 @@ class CompoundRec(Base):
filter_fun = rs.create_filter('git gitbare bzr'.split())
self.innerT(rs.walkrepos, 'compound', None, filter_fun)
+class RepoInner(Base):
+ data = ['.']
+ def test_git_within_flat(self):
+ self.innerT(rs.walkrepos_flat, '.', 'git', append_dir='repoinner/git')
+ def test_git_within_rec(self):
+ self.innerT(rs.walkrepos, '.', 'git', append_dir='repoinner/git')
+ def test_gitbare_within_flat(self):
+ self.innerT(rs.walkrepos_flat, '.', 'gitbare', append_dir='repoinner/git.git')
+ def test_gitbare_within_rec(self):
+ self.innerT(rs.walkrepos, '.', 'gitbare', append_dir='repoinner/git.git')
+
if __name__ == "__main__":
unittest.main()