More stage tests.
This commit is contained in:
parent
ff2018bc85
commit
344e902b15
2 changed files with 49 additions and 14 deletions
|
@ -247,17 +247,16 @@ class SomePackage(Package):
|
|||
"""
|
||||
|
||||
#
|
||||
# These variables are per-package metadata will be defined by subclasses.
|
||||
# These variables are defaults for the various relations defined on
|
||||
# packages. Subclasses will have their own versions of these.
|
||||
#
|
||||
"""By default a package has no dependencies."""
|
||||
"""Specs of dependency packages, keyed by name."""
|
||||
dependencies = {}
|
||||
|
||||
"""List of specs of virtual packages provided by this package."""
|
||||
"""Specs of virtual packages provided by this package, keyed by name."""
|
||||
provided = {}
|
||||
|
||||
"""List of specs of conflicting packages.
|
||||
TODO: implement conflicts.
|
||||
"""
|
||||
"""Specs of conflicting packages, keyed by name. """
|
||||
conflicted = {}
|
||||
|
||||
#
|
||||
|
@ -272,6 +271,7 @@ class SomePackage(Package):
|
|||
"""Controls whether install and uninstall check deps before running."""
|
||||
ignore_dependencies = False
|
||||
|
||||
|
||||
def __init__(self, spec):
|
||||
# These attributes are required for all packages.
|
||||
attr_required(self, 'homepage')
|
||||
|
@ -292,18 +292,17 @@ def __init__(self, spec):
|
|||
validate.url(self.url)
|
||||
|
||||
# Set up version
|
||||
# TODO: get rid of version attr and use spec
|
||||
# TODO: roll this into available_versions
|
||||
if not hasattr(self, 'version'):
|
||||
try:
|
||||
self.version = url.parse_version(self.url)
|
||||
except UndetectableVersionError:
|
||||
tty.die("Couldn't extract a default version from %s. You " +
|
||||
"must specify it explicitly in the package." % self.url)
|
||||
elif type(self.version) == string:
|
||||
elif type(self.version) != Version:
|
||||
self.version = Version(self.version)
|
||||
|
||||
# Empty at first; only compute dependent packages if necessary
|
||||
self._dependents = None
|
||||
|
||||
# This is set by scraping a web page.
|
||||
self._available_versions = None
|
||||
|
||||
|
@ -312,6 +311,9 @@ def __init__(self, spec):
|
|||
if self.versions and type(self.versions) != VersionList:
|
||||
self.versions = VersionList(self.versions)
|
||||
|
||||
# Empty at first; only compute dependent packages if necessary
|
||||
self._dependents = None
|
||||
|
||||
# stage used to build this package.
|
||||
# TODO: hash the concrete spec and use that as the stage name.
|
||||
self.stage = Stage(self.url, "%s-%s" % (self.name, self.version))
|
||||
|
@ -390,6 +392,7 @@ def dependents(self):
|
|||
|
||||
|
||||
def preorder_traversal(self, visited=None):
|
||||
"""This does a preorder traversal of the package's dependence DAG."""
|
||||
if visited is None:
|
||||
visited = set()
|
||||
|
||||
|
|
|
@ -118,15 +118,19 @@ def check_setup(self, stage, stage_name):
|
|||
|
||||
def check_fetch(self, stage, stage_name):
|
||||
stage_path = self.get_stage_path(stage, stage_name)
|
||||
self.assertTrue(archive_name in os.listdir(stage_path))
|
||||
self.assertIn(archive_name, os.listdir(stage_path))
|
||||
self.assertEqual(new_path(stage_path, archive_name),
|
||||
stage.archive_file)
|
||||
|
||||
|
||||
def check_expand_archive(self, stage, stage_name):
|
||||
stage_path = self.get_stage_path(stage, stage_name)
|
||||
self.assertTrue(archive_name in os.listdir(stage_path))
|
||||
self.assertTrue(archive_dir in os.listdir(stage_path))
|
||||
self.assertIn(archive_name, os.listdir(stage_path))
|
||||
self.assertIn(archive_dir, os.listdir(stage_path))
|
||||
|
||||
self.assertEqual(
|
||||
new_path(stage_path, archive_dir),
|
||||
stage.expanded_archive_path)
|
||||
|
||||
readme = new_path(stage_path, archive_dir, readme_name)
|
||||
self.assertTrue(os.path.isfile(readme))
|
||||
|
@ -226,7 +230,7 @@ def test_expand_archive(self):
|
|||
self.check_destroy(stage, stage_name)
|
||||
|
||||
|
||||
def test_zexpand_archive(self):
|
||||
def test_expand_archive(self):
|
||||
stage = Stage(archive_url, stage_name)
|
||||
|
||||
stage.fetch()
|
||||
|
@ -240,3 +244,31 @@ def test_zexpand_archive(self):
|
|||
|
||||
stage.destroy()
|
||||
self.check_destroy(stage, stage_name)
|
||||
|
||||
|
||||
def test_restage(self):
|
||||
stage = Stage(archive_url, stage_name)
|
||||
|
||||
stage.fetch()
|
||||
stage.expand_archive()
|
||||
stage.chdir_to_archive()
|
||||
self.check_expand_archive(stage, stage_name)
|
||||
self.check_chdir_to_archive(stage, stage_name)
|
||||
|
||||
# Try to make a file in the old archive dir
|
||||
with closing(open('foobar', 'w')) as file:
|
||||
file.write("this file is to be destroyed.")
|
||||
|
||||
self.assertIn('foobar', os.listdir(stage.expanded_archive_path))
|
||||
|
||||
# Make sure the file is not there after restage.
|
||||
stage.restage()
|
||||
self.check_chdir(stage, stage_name)
|
||||
self.check_fetch(stage, stage_name)
|
||||
|
||||
stage.chdir_to_archive()
|
||||
self.check_chdir_to_archive(stage, stage_name)
|
||||
self.assertNotIn('foobar', os.listdir(stage.expanded_archive_path))
|
||||
|
||||
stage.destroy()
|
||||
self.check_destroy(stage, stage_name)
|
||||
|
|
Loading…
Reference in a new issue