Added back unit tests to detect compiler versions
This commit is contained in:
parent
8edf6b7c81
commit
2c2d0e2c44
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
@ -26,6 +28,28 @@
|
|||||||
from spack.compiler import Compiler
|
from spack.compiler import Compiler
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def make_args_for_version(monkeypatch):
|
||||||
|
|
||||||
|
def _factory(version, path='/usr/bin/gcc'):
|
||||||
|
class MockOs(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
compiler_name = 'gcc'
|
||||||
|
compiler_cls = compilers.class_for_compiler_name(compiler_name)
|
||||||
|
monkeypatch.setattr(compiler_cls, 'cc_version', lambda x: version)
|
||||||
|
|
||||||
|
compiler_id = compilers.CompilerID(
|
||||||
|
os=MockOs, compiler_name=compiler_name, version=None
|
||||||
|
)
|
||||||
|
variation = compilers.NameVariation(prefix='', suffix='')
|
||||||
|
return compilers.DetectVersionArgs(
|
||||||
|
id=compiler_id, variation=variation, language='cc', path=path
|
||||||
|
)
|
||||||
|
|
||||||
|
return _factory
|
||||||
|
|
||||||
|
|
||||||
def test_get_compiler_duplicates(config):
|
def test_get_compiler_duplicates(config):
|
||||||
# In this case there is only one instance of the specified compiler in
|
# In this case there is only one instance of the specified compiler in
|
||||||
# the test configuration (so it is not actually a duplicate), but the
|
# the test configuration (so it is not actually a duplicate), but the
|
||||||
@ -45,16 +69,22 @@ def test_all_compilers(config):
|
|||||||
assert len(filtered) == 1
|
assert len(filtered) == 1
|
||||||
|
|
||||||
|
|
||||||
# FIXME: Write better unit tests for this function
|
@pytest.mark.skipif(
|
||||||
# def test_version_detection_is_empty():
|
sys.version_info[0] == 2, reason='make_args_for_version requires python 3'
|
||||||
# version = detect_version(lambda x: None, path='/usr/bin/gcc')
|
)
|
||||||
# expected = (None, "Couldn't get version for compiler /usr/bin/gcc")
|
@pytest.mark.parametrize('input_version,expected_version,expected_error', [
|
||||||
# assert version == expected
|
(None, None, "Couldn't get version for compiler /usr/bin/gcc"),
|
||||||
#
|
('4.9', '4.9', None)
|
||||||
#
|
])
|
||||||
# def test_version_detection_is_successful():
|
def test_version_detection_is_empty(
|
||||||
# version = detect_version(lambda x: '4.9', path='/usr/bin/gcc')
|
make_args_for_version, input_version, expected_version, expected_error
|
||||||
# assert version == (('4.9', '/usr/bin/gcc'), None)
|
):
|
||||||
|
args = make_args_for_version(version=input_version)
|
||||||
|
result, error = compilers.detect_version(args)
|
||||||
|
if not error:
|
||||||
|
assert result.id.version == expected_version
|
||||||
|
|
||||||
|
assert error == expected_error
|
||||||
|
|
||||||
|
|
||||||
def test_compiler_flags_from_config_are_grouped():
|
def test_compiler_flags_from_config_are_grouped():
|
||||||
|
Loading…
Reference in New Issue
Block a user