Skip to content
Snippets Groups Projects
Commit 72c9604b authored by Todd Gamblin's avatar Todd Gamblin
Browse files

Small fix to prevent this test from interfering with others.

parent 55662eca
No related branches found
No related tags found
No related merge requests found
...@@ -26,16 +26,16 @@ ...@@ -26,16 +26,16 @@
import itertools import itertools
import spack import spack
test_install = __import__("spack.cmd.test-install", test_install = __import__("spack.cmd.test-install",
fromlist=["BuildId", "create_test_output", "TestResult"]) fromlist=["BuildId", "create_test_output", "TestResult"])
class MockOutput(object): class MockOutput(object):
def __init__(self): def __init__(self):
self.results = {} self.results = {}
def add_test(self, buildId, passed=True, buildInfo=None): def add_test(self, buildId, passed=True, buildInfo=None):
self.results[buildId] = passed self.results[buildId] = passed
def write_to(self, stream): def write_to(self, stream):
pass pass
...@@ -45,14 +45,14 @@ def __init__(self, name, version, hashStr=None): ...@@ -45,14 +45,14 @@ def __init__(self, name, version, hashStr=None):
self.name = name self.name = name
self.version = version self.version = version
self.hash = hashStr if hashStr else hash((name, version)) self.hash = hashStr if hashStr else hash((name, version))
def traverse(self, order=None): 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()) self.dependencies.itervalues())
return set(itertools.chain([self], allDeps)) return set(itertools.chain([self], allDeps))
def dag_hash(self): def dag_hash(self):
return self.hash return self.hash
def to_yaml(self): def to_yaml(self):
return "<<<MOCK YAML {0}>>>".format(test_install.BuildId(self).stringId()) return "<<<MOCK YAML {0}>>>".format(test_install.BuildId(self).stringId())
...@@ -75,47 +75,52 @@ class UnitInstallTest(unittest.TestCase): ...@@ -75,47 +75,52 @@ class UnitInstallTest(unittest.TestCase):
def setUp(self): def setUp(self):
super(UnitInstallTest, self).setUp() super(UnitInstallTest, self).setUp()
pkgX.installed = False pkgX.installed = False
pkgY.installed = False pkgY.installed = False
self.saved_db = spack.db
pkgDb = MockPackageDb({specX:pkgX, specY:pkgY}) pkgDb = MockPackageDb({specX:pkgX, specY:pkgY})
spack.db = pkgDb spack.db = pkgDb
def tearDown(self): def tearDown(self):
super(UnitInstallTest, self).tearDown() super(UnitInstallTest, self).tearDown()
spack.db = self.saved_db
def test_installing_both(self): def test_installing_both(self):
mo = MockOutput() mo = MockOutput()
pkgX.installed = True pkgX.installed = True
pkgY.installed = True pkgY.installed = True
test_install.create_test_output(specX, [specX, specY], mo, getLogFunc=test_fetch_log) test_install.create_test_output(specX, [specX, specY], mo, getLogFunc=test_fetch_log)
self.assertEqual(mo.results, self.assertEqual(mo.results,
{bIdX:test_install.TestResult.PASSED, {bIdX:test_install.TestResult.PASSED,
bIdY:test_install.TestResult.PASSED}) bIdY:test_install.TestResult.PASSED})
def test_dependency_already_installed(self): def test_dependency_already_installed(self):
mo = MockOutput() mo = MockOutput()
pkgX.installed = True pkgX.installed = True
pkgY.installed = True pkgY.installed = True
test_install.create_test_output(specX, [specX], mo, getLogFunc=test_fetch_log) test_install.create_test_output(specX, [specX], mo, getLogFunc=test_fetch_log)
self.assertEqual(mo.results, {bIdX:test_install.TestResult.PASSED}) self.assertEqual(mo.results, {bIdX:test_install.TestResult.PASSED})
#TODO: add test(s) where Y fails to install #TODO: add test(s) where Y fails to install
class MockPackageDb(object): class MockPackageDb(object):
def __init__(self, init=None): def __init__(self, init=None):
self.specToPkg = {} self.specToPkg = {}
if init: if init:
self.specToPkg.update(init) self.specToPkg.update(init)
def get(self, spec): def get(self, spec):
return self.specToPkg[spec] return self.specToPkg[spec]
def test_fetch_log(path): def test_fetch_log(path):
return [] return []
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment