Small fix to prevent this test from interfering with others.

This commit is contained in:
Todd Gamblin 2015-11-12 15:17:09 -08:00
parent 55662eca69
commit 72c9604bcb

View File

@ -26,16 +26,16 @@
import itertools
import spack
test_install = __import__("spack.cmd.test-install",
test_install = __import__("spack.cmd.test-install",
fromlist=["BuildId", "create_test_output", "TestResult"])
class MockOutput(object):
def __init__(self):
self.results = {}
def add_test(self, buildId, passed=True, buildInfo=None):
self.results[buildId] = passed
def write_to(self, stream):
pass
@ -45,14 +45,14 @@ def __init__(self, name, version, hashStr=None):
self.name = name
self.version = version
self.hash = hashStr if hashStr else hash((name, version))
def traverse(self, order=None):
allDeps = itertools.chain.from_iterable(i.traverse() for i in
allDeps = itertools.chain.from_iterable(i.traverse() for i in
self.dependencies.itervalues())
return set(itertools.chain([self], allDeps))
def dag_hash(self):
return self.hash
return self.hash
def to_yaml(self):
return "<<<MOCK YAML {0}>>>".format(test_install.BuildId(self).stringId())
@ -75,47 +75,52 @@ class UnitInstallTest(unittest.TestCase):
def setUp(self):
super(UnitInstallTest, self).setUp()
pkgX.installed = False
pkgY.installed = False
self.saved_db = spack.db
pkgDb = MockPackageDb({specX:pkgX, specY:pkgY})
spack.db = pkgDb
def tearDown(self):
super(UnitInstallTest, self).tearDown()
spack.db = self.saved_db
def test_installing_both(self):
mo = MockOutput()
pkgX.installed = True
pkgY.installed = True
test_install.create_test_output(specX, [specX, specY], mo, getLogFunc=test_fetch_log)
self.assertEqual(mo.results,
{bIdX:test_install.TestResult.PASSED,
self.assertEqual(mo.results,
{bIdX:test_install.TestResult.PASSED,
bIdY:test_install.TestResult.PASSED})
def test_dependency_already_installed(self):
mo = MockOutput()
pkgX.installed = True
pkgY.installed = True
test_install.create_test_output(specX, [specX], mo, getLogFunc=test_fetch_log)
self.assertEqual(mo.results, {bIdX:test_install.TestResult.PASSED})
#TODO: add test(s) where Y fails to install
class MockPackageDb(object):
def __init__(self, init=None):
self.specToPkg = {}
if init:
self.specToPkg.update(init)
def get(self, spec):
return self.specToPkg[spec]
def test_fetch_log(path):
return []