aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-07-18 15:37:48 +0300
committerGuido Günther <agx@sigxcpu.org>2014-12-05 15:43:55 +0100
commit194b6b8652784ebbcb64dada2836f9983b9daefe (patch)
treeaa04a3f3bde141242bab3d801b1d055f1d98ab31
parent0e7cb0dfa90aa34d7bf9d319d4a2abe45df3ff4f (diff)
ComponentTestBase: add dirs argument to _check_repo_state()
Make difference between regular files and directories, eliminating the requirement of listing directories in the file list. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r--tests/component/__init__.py21
-rw-r--r--tests/component/rpm/test_import_srpm.py11
2 files changed, 18 insertions, 14 deletions
diff --git a/tests/component/__init__.py b/tests/component/__init__.py
index ae815775..cfa04223 100644
--- a/tests/component/__init__.py
+++ b/tests/component/__init__.py
@@ -135,7 +135,8 @@ class ComponentTestBase(object):
assert not extra and not missing, assert_msg
@classmethod
- def _check_repo_state(cls, repo, current_branch, branches, files=None):
+ def _check_repo_state(cls, repo, current_branch, branches, files=None,
+ dirs=None):
"""Check that repository is clean and given branches exist"""
branch = repo.branch
eq_(branch, current_branch)
@@ -144,20 +145,24 @@ class ComponentTestBase(object):
assert_msg = "Branches: expected %s, found %s" % (branches,
local_branches)
eq_(set(local_branches), set(branches), assert_msg)
- if files is not None:
+ if files is not None or dirs is not None:
# Get files of the working copy recursively
- local = set()
+ local_f = set()
+ local_d = set()
for dirpath, dirnames, filenames in os.walk(repo.path):
# Skip git dir(s)
if '.git' in dirnames:
dirnames.remove('.git')
for filename in filenames:
- local.add(os.path.relpath(os.path.join(dirpath, filename),
- repo.path))
+ local_f.add(os.path.relpath(os.path.join(dirpath, filename),
+ repo.path))
for dirname in dirnames:
- local.add(os.path.relpath(os.path.join(dirpath, dirname),
- repo.path) + '/')
- cls.check_files(files, local)
+ local_d.add(os.path.relpath(os.path.join(dirpath, dirname),
+ repo.path) + '/')
+ if files is not None:
+ cls.check_files(files, local_f)
+ if dirs is not None:
+ cls.check_files(dirs, local_d)
def _capture_log(self, capture=True):
""" Capture log"""
diff --git a/tests/component/rpm/test_import_srpm.py b/tests/component/rpm/test_import_srpm.py
index d0e71701..acd8443b 100644
--- a/tests/component/rpm/test_import_srpm.py
+++ b/tests/component/rpm/test_import_srpm.py
@@ -94,7 +94,7 @@ class TestImportPacked(ComponentTestBase):
srpm = os.path.join(DATA_DIR, 'gbp-test-native-1.0-1.src.rpm')
eq_(mock_import(['--native', srpm]), 0)
# Check repository state
- files = {'.gbp.conf', 'Makefile', 'README', 'dummy.sh', 'packaging/',
+ files = {'.gbp.conf', 'Makefile', 'README', 'dummy.sh',
'packaging/gbp-test-native.spec'}
repo = GitRepository('gbp-test-native')
self._check_repo_state(repo, 'master', ['master'], files)
@@ -195,11 +195,10 @@ class TestImportPacked(ComponentTestBase):
srpm]), 0)
# Check repository state
repo = GitRepository('gbp-test2')
- files = {'Makefile', 'README', 'dummy.sh', 'packaging/',
- 'packaging/bar.tar.gz', 'packaging/foo.txt',
- 'packaging/gbp-test2.spec', 'packaging/gbp-test2-alt.spec',
- 'packaging/my.patch', 'packaging/my2.patch',
- 'packaging/my3.patch'}
+ files = {'Makefile', 'README', 'dummy.sh', 'packaging/bar.tar.gz',
+ 'packaging/foo.txt', 'packaging/gbp-test2.spec',
+ 'packaging/gbp-test2-alt.spec', 'packaging/my.patch',
+ 'packaging/my2.patch', 'packaging/my3.patch'}
self._check_repo_state(repo, 'pack', ['pack', 'orig'], files)
eq_(len(repo.get_commits()), 2)
# Check packaging dir