better debugging for wrong type, fix emulator tests, fixes #176

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
Nico Schottelius 2013-05-27 16:36:20 +02:00
parent 9647d8f7e5
commit 3d73cd2fd3
2 changed files with 9 additions and 4 deletions

View file

@ -184,7 +184,12 @@ class Emulator(object):
if len(requirement) == 0: continue if len(requirement) == 0: continue
# Raises an error, if object cannot be created # Raises an error, if object cannot be created
try:
cdist_object = self.cdist_object.object_from_name(requirement) cdist_object = self.cdist_object.object_from_name(requirement)
except core.cdist_type.NoSuchTypeError:
self.log.error("%s requires object %s with non-existing type at %s" % (self.cdist_object.name, requirement, self.object_source))
raise
self.log.debug("Recording requirement: " + requirement) self.log.debug("Recording requirement: " + requirement)

View file

@ -63,13 +63,13 @@ class EmulatorTestCase(test.CdistTestCase):
def test_nonexistent_type_exec(self): def test_nonexistent_type_exec(self):
argv = ['__does-not-exist'] argv = ['__does-not-exist']
self.assertRaises(core.NoSuchTypeError, emulator.Emulator, argv, env=self.env) self.assertRaises(core.cdist_type.NoSuchTypeError, emulator.Emulator, argv, env=self.env)
def test_nonexistent_type_requirement(self): def test_nonexistent_type_requirement(self):
argv = ['__file', '/tmp/foobar'] argv = ['__file', '/tmp/foobar']
self.env['require'] = '__does-not-exist/some-id' self.env['require'] = '__does-not-exist/some-id'
emu = emulator.Emulator(argv, env=self.env) emu = emulator.Emulator(argv, env=self.env)
self.assertRaises(core.NoSuchTypeError, emu.run) self.assertRaises(core.cdist_type.NoSuchTypeError, emu.run)
def test_illegal_object_id_requirement(self): def test_illegal_object_id_requirement(self):
argv = ['__file', '/tmp/foobar'] argv = ['__file', '/tmp/foobar']
@ -81,7 +81,7 @@ class EmulatorTestCase(test.CdistTestCase):
argv = ['__file', '/tmp/foobar'] argv = ['__file', '/tmp/foobar']
self.env['require'] = '__file' self.env['require'] = '__file'
emu = emulator.Emulator(argv, env=self.env) emu = emulator.Emulator(argv, env=self.env)
self.assertRaises(core.IllegalObjectIdError, emu.run) self.assertRaises(core.cdist_object.MissingObjectIdError, emu.run)
def test_singleton_object_requirement(self): def test_singleton_object_requirement(self):
argv = ['__file', '/tmp/foobar'] argv = ['__file', '/tmp/foobar']