Fix bug in tests.

This commit is contained in:
Todd Gamblin 2016-01-02 14:25:10 -08:00
parent e8e6368cc8
commit 20b7f8a8e0
2 changed files with 17 additions and 14 deletions

View file

@ -46,6 +46,7 @@
_imported_compilers_module = 'spack.compilers' _imported_compilers_module = 'spack.compilers'
_required_instance_vars = ['cc', 'cxx', 'f77', 'fc'] _required_instance_vars = ['cc', 'cxx', 'f77', 'fc']
# TODO: customize order in config file
_default_order = ['gcc', 'intel', 'pgi', 'clang', 'xlc'] _default_order = ['gcc', 'intel', 'pgi', 'clang', 'xlc']
def _auto_compiler_spec(function): def _auto_compiler_spec(function):
@ -132,7 +133,7 @@ def remove_compiler_from_config(compiler_spec, arch=None, scope=None):
spack.config.update_config('compilers', update, scope) spack.config.update_config('compilers', update, scope)
def all_compilers(arch=None, scope=None): def all_compilers_config(arch=None, scope=None):
"""Return a set of specs for all the compiler versions currently """Return a set of specs for all the compiler versions currently
available to build with. These are instances of CompilerSpec. available to build with. These are instances of CompilerSpec.
""" """
@ -144,25 +145,25 @@ def all_compilers(arch=None, scope=None):
merged_config = get_compiler_config('all', scope=scope) merged_config = get_compiler_config('all', scope=scope)
merged_config = spack.config._merge_yaml(merged_config, arch_config) merged_config = spack.config._merge_yaml(merged_config, arch_config)
# Return compiler specs for the result. return merged_config
return [spack.spec.CompilerSpec(s) for s in merged_config]
def all_compilers(arch=None, scope=None):
# Return compiler specs from the merged config.
return [spack.spec.CompilerSpec(s)
for s in all_compilers_config(arch, scope)]
_cached_default_compiler = None
def default_compiler(): def default_compiler():
global _cached_default_compiler
if _cached_default_compiler:
return _cached_default_compiler
versions = [] versions = []
for name in _default_order: # TODO: customize order. for name in _default_order:
versions = find(name) versions = find(name)
if versions: break if versions:
break
if not versions: else:
raise NoCompilersError() raise NoCompilersError()
_cached_default_compiler = sorted(versions)[-1] return sorted(versions)[-1]
return _cached_default_compiler
def find_compilers(*path): def find_compilers(*path):
@ -224,7 +225,7 @@ def compilers_for_spec(compiler_spec, arch=None, scope=None):
"""This gets all compilers that satisfy the supplied CompilerSpec. """This gets all compilers that satisfy the supplied CompilerSpec.
Returns an empty list if none are found. Returns an empty list if none are found.
""" """
config = get_compiler_config(arch, scope) config = all_compilers_config(arch, scope)
def get_compiler(cspec): def get_compiler(cspec):
items = config[str(cspec)] items = config[str(cspec)]

View file

@ -24,6 +24,7 @@
############################################################################## ##############################################################################
import sys import sys
import os import os
import shutil
import unittest import unittest
import tempfile import tempfile
from ordereddict_backport import OrderedDict from ordereddict_backport import OrderedDict
@ -103,6 +104,7 @@ def cleanmock(self):
"""Restore the real packages path after any test.""" """Restore the real packages path after any test."""
spack.repo.swap(self.db) spack.repo.swap(self.db)
spack.config.config_scopes = self.real_scopes spack.config.config_scopes = self.real_scopes
shutil.rmtree(self.temp_config, ignore_errors=True)
spack.config.clear_config_caches() spack.config.clear_config_caches()
# Restore dependency changes that happened during the test # Restore dependency changes that happened during the test