コード例 #1
0
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')
コード例 #2
0
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)
コード例 #3
0
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')
コード例 #4
0
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')
コード例 #5
0
def test_CompilationToolBase():
    r"""Test error in CompilationToolBase."""
    with pytest.raises(RuntimeError):
        CompiledModelDriver.CompilationToolBase(invalid='invalid')
コード例 #6
0
def test_find_compilation_tool():
    r"""Test errors raised by find_compilation_tool."""
    with pytest.raises(RuntimeError):
        CompiledModelDriver.find_compilation_tool('archiver', 'cmake')
コード例 #7
0
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')
コード例 #8
0
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)