Fixed failing unit tests

- Tests based on TestArchitecture
- Tests on non-buildable external
This commit is contained in:
Massimiliano Culpo 2020-09-30 20:48:57 +02:00 committed by Todd Gamblin
parent 2ea8bd0b19
commit c065245f14
2 changed files with 11 additions and 10 deletions

View File

@ -14,9 +14,9 @@ class Test(Platform):
if platform.system().lower() == 'darwin': if platform.system().lower() == 'darwin':
binary_formats = ['macho'] binary_formats = ['macho']
front_end = 'x86_64' front_end = 'x86_64'
back_end = 'broadwell' back_end = 'core2'
default = 'broadwell' default = 'core2'
front_os = 'redhat6' front_os = 'redhat6'
back_os = 'debian6' back_os = 'debian6'

View File

@ -99,9 +99,10 @@ def current_host(request, monkeypatch):
# this function is memoized, so clear its state for testing # this function is memoized, so clear its state for testing
spack.architecture.get_platform.cache.clear() spack.architecture.get_platform.cache.clear()
monkeypatch.setattr(spack.platforms.test.Test, 'default', cpu)
monkeypatch.setattr(spack.platforms.test.Test, 'front_end', cpu)
if not is_preference: if not is_preference:
monkeypatch.setattr(archspec.cpu, 'host', lambda: target) monkeypatch.setattr(archspec.cpu, 'host', lambda: target)
monkeypatch.setattr(spack.platforms.test.Test, 'default', cpu)
yield target yield target
else: else:
with spack.config.override('packages:all', {'target': [cpu]}): with spack.config.override('packages:all', {'target': [cpu]}):
@ -380,13 +381,12 @@ def test_external_package_module(self):
assert spec['externalmodule'].compiler.satisfies('gcc') assert spec['externalmodule'].compiler.satisfies('gcc')
def test_nobuild_package(self): def test_nobuild_package(self):
got_error = False """Test that a non-buildable package raise an error if no specs
in packages.yaml are compatible with the request.
"""
spec = Spec('externaltool%clang') spec = Spec('externaltool%clang')
try: with pytest.raises(spack.error.SpecError):
spec.concretize() spec.concretize()
except spack.concretize.NoBuildError:
got_error = True
assert got_error
def test_external_and_virtual(self): def test_external_and_virtual(self):
spec = Spec('externaltest') spec = Spec('externaltest')
@ -634,7 +634,7 @@ def test_adjusting_default_target_based_on_compiler(
else current_host else current_host
with spack.concretize.disable_compiler_existence_check(): with spack.concretize.disable_compiler_existence_check():
s = Spec(spec).concretized() s = Spec(spec).concretized()
assert str(s.architecture.target) == str(expected) assert str(s.architecture.target) == str(expected), str(best_achievable)
@pytest.mark.regression('8735,14730') @pytest.mark.regression('8735,14730')
def test_compiler_version_matches_any_entry_in_compilers_yaml(self): def test_compiler_version_matches_any_entry_in_compilers_yaml(self):
@ -643,6 +643,7 @@ def test_compiler_version_matches_any_entry_in_compilers_yaml(self):
with pytest.raises(spack.concretize.UnavailableCompilerVersionError): with pytest.raises(spack.concretize.UnavailableCompilerVersionError):
s = Spec('mpileaks %gcc@4.5') s = Spec('mpileaks %gcc@4.5')
s.concretize() s.concretize()
pass
# An abstract compiler with a version list could resolve to 4.5.0 # An abstract compiler with a version list could resolve to 4.5.0
s = Spec('mpileaks %gcc@4.5:') s = Spec('mpileaks %gcc@4.5:')