Refactor mock_repo: add a destroy() method.

- classes using mock_repo need not know about its stage now.
This commit is contained in:
Todd Gamblin 2016-01-25 00:32:14 -08:00
parent d3ff8ca00f
commit a48d0a494f
6 changed files with 20 additions and 28 deletions

View File

@ -56,10 +56,7 @@ def setUp(self):
def tearDown(self):
"""Destroy the stage space used by this test."""
super(GitFetchTest, self).tearDown()
if self.repo.stage is not None:
self.repo.stage.destroy()
self.repo.destroy()
self.pkg.do_clean()

View File

@ -53,10 +53,7 @@ def setUp(self):
def tearDown(self):
"""Destroy the stage space used by this test."""
super(HgFetchTest, self).tearDown()
if self.repo.stage is not None:
self.repo.stage.destroy()
self.repo.destroy()
self.pkg.do_clean()

View File

@ -59,9 +59,7 @@ def setUp(self):
def tearDown(self):
super(InstallTest, self).tearDown()
if self.repo.stage is not None:
self.repo.stage.destroy()
self.repo.destroy()
# Turn checksumming back on
spack.do_checksum = True

View File

@ -44,8 +44,16 @@ def setUp(self):
self.repos = {}
def tearDown(self):
"""Destroy all the stages created by the repos in setup."""
super(MirrorTest, self).tearDown()
for repo in self.repos.values():
repo.destroy()
self.repos.clear()
def set_up_package(self, name, MockRepoClass, url_attr):
"""Use this to set up a mock package to be mirrored.
"""Set up a mock package to be mirrored.
Each package needs us to:
1. Set up a mock repo/archive to fetch from.
2. Point the package's version args at that repo.
@ -65,17 +73,6 @@ def set_up_package(self, name, MockRepoClass, url_attr):
pkg.versions[v][url_attr] = repo.url
def tearDown(self):
"""Destroy all the stages created by the repos in setup."""
super(MirrorTest, self).tearDown()
for name, repo in self.repos.items():
if repo.stage:
pass #repo.stage.destroy()
self.repos.clear()
def check_mirror(self):
stage = Stage('spack-mirror-test')
mirror_root = join_path(stage.path, 'test-mirror')
@ -129,7 +126,7 @@ def check_mirror(self):
self.assertTrue(all(l in exclude for l in dcmp.left_only))
finally:
pass #stage.destroy()
stage.destroy()
def test_git_mirror(self):

View File

@ -55,6 +55,12 @@ def __init__(self, stage_name, repo_name):
mkdirp(self.path)
def destroy(self):
"""Destroy resources associated with this mock repo."""
if self.stage:
self.stage.destroy()
class MockArchive(MockRepo):
"""Creates a very simple archive directory with a configure script and a
makefile that installs to a prefix. Tars it up into an archive."""

View File

@ -55,10 +55,7 @@ def setUp(self):
def tearDown(self):
"""Destroy the stage space used by this test."""
super(SvnFetchTest, self).tearDown()
if self.repo.stage is not None:
self.repo.stage.destroy()
self.repo.destroy()
self.pkg.do_clean()