def test_get_compilation_tool(): r"""Test get_compilation_tool for different name variations.""" from yggdrasil.drivers.CModelDriver import CModelDriver if CModelDriver.is_language_installed(): tooltype = 'compiler' out = CModelDriver.get_tool('compiler').__class__ toolname = out.toolname.lower() toolpath = os.path.join('somedir', toolname) toolfile = toolpath + '.exe' vals = [toolpath, toolfile] if platform._is_win: vals += [toolname.upper(), toolfile.upper()] for v in vals: assert_equal(CompiledModelDriver.get_compilation_tool(tooltype, v), out) assert_raises(ValueError, CompiledModelDriver.get_compilation_tool, 'compiler', 'invalid') # else: # assert_raises(NotImplementedError, CModelDriver.get_tool, 'compiler') # assert_equal(CModelDriver.get_tool( # 'compiler', default='invalid'), 'invalid') assert_equal( CompiledModelDriver.get_compilation_tool('compiler', 'invalid', default='invalid'), 'invalid')
def test_get_compatible_tool(): r"""Test get_compatible_tool when default provided.""" assert_raises(ValueError, CompiledModelDriver.get_compatible_tool, 'invalid', 'compiler', 'c') assert_equal( CompiledModelDriver.get_compatible_tool('invalid', 'compiler', 'c', default=None), None)
def test_get_compilation_tool(): r"""Test get_compilation_tool for different name variations.""" from yggdrasil.drivers.CModelDriver import CModelDriver tooltype = 'compiler' out = CModelDriver.get_tool('compiler').__class__ toolname = out.toolname.lower() toolpath = os.path.join('somedir', toolname) toolfile = toolpath + '.exe' vals = [toolname.upper(), toolpath, toolfile, toolfile.upper()] for v in vals: assert_equal(CompiledModelDriver.get_compilation_tool(tooltype, v), out) assert_raises(ValueError, CompiledModelDriver.get_compilation_tool, 'compiler', 'invalid')
def test_get_alternate_class(): r"""Test get_alternate_class.""" import_component('model', subtype='c') gcc = CompiledModelDriver.get_compilation_tool('compiler', 'gcc') gcc.get_alternate_class(toolname='clang')
def test_CompilationToolBase(): r"""Test error in CompilationToolBase.""" with pytest.raises(RuntimeError): CompiledModelDriver.CompilationToolBase(invalid='invalid')
def test_find_compilation_tool(): r"""Test errors raised by find_compilation_tool.""" with pytest.raises(RuntimeError): CompiledModelDriver.find_compilation_tool('archiver', 'cmake')
def test_get_compilation_tool_registry(): r"""Test errors raised by get_compilation_tool_registry.""" with pytest.raises(ValueError): CompiledModelDriver.get_compilation_tool_registry('invalid')
def test_get_compatible_tool(): r"""Test get_compatible_tool when default provided.""" with pytest.raises(ValueError): CompiledModelDriver.get_compatible_tool('invalid', 'compiler', 'c') assert (CompiledModelDriver.get_compatible_tool( 'invalid', 'compiler', 'c', default=None) is None)