diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-01-04 18:39:43 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2013-03-22 21:10:54 +0100 |
commit | 3b873f75ef32c500e69da22dcfc73155414bb6d0 (patch) | |
tree | cd6c403958e45288cf804fd8b86c86a52e9436ab | |
parent | 57bbd0abde12e1dafd2ca31a4bcf63c639b5ae6c (diff) |
ComponentTestBase: capability to check files of repo
Makes it possible to check that the correct files are present in
the working copy of the repo.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | tests/component/__init__.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/component/__init__.py b/tests/component/__init__.py index 3aca00c5..115f9951 100644 --- a/tests/component/__init__.py +++ b/tests/component/__init__.py @@ -116,12 +116,29 @@ class ComponentTestBase(object): self._capture_log(False) @classmethod - def _check_repo_state(cls, repo, current_branch, branches): + def _check_repo_state(cls, repo, current_branch, branches, files=None): """Check that repository is clean and given branches exist""" branch = repo.branch assert branch == current_branch assert repo.is_clean() assert set(repo.get_local_branches()) == set(branches) + if files is not None: + # Get files of the working copy recursively + local = 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)) + for dirname in dirnames: + local.add(os.path.relpath(os.path.join(dirpath, dirname), + repo.path) + '/') + extra = local - set(files) + assert not extra, "Unexpected files in repo: %s" % list(extra) + missing = set(files) - local + assert not missing, "Files missing from repo: %s" % list(missing) def _capture_log(self, capture=True): """ Capture log""" |