Prefer later versions of compilers by default (#5234)

* Prefer later versions of compilers by default

* update test to make it less fragile
This commit is contained in:
scheibelp 2017-09-21 17:16:19 -07:00 committed by becker33
parent 3817111454
commit 45a8c03bdf
3 changed files with 18 additions and 24 deletions

View file

@ -317,6 +317,9 @@ def _proper_compiler_style(cspec, aspec):
# No compiler with a satisfactory spec was found
raise UnavailableCompilerVersionError(other_compiler)
# By default, prefer later versions of compilers
compiler_list = sorted(
compiler_list, key=lambda x: (x.name, x.version), reverse=True)
ppk = PackagePrefs(other_spec.name, 'compiler')
matches = sorted(compiler_list, key=ppk)

View file

@ -259,7 +259,10 @@ def _refresh():
with spack.store.db.write_transaction():
for spec in spack.store.db.query():
if spec.package.installed:
t.uninstall(spec)
else:
spack.store.db.remove(spec)
install_path.remove(rec=1)
spack.store.root = str(spack_install_path)

View file

@ -25,6 +25,7 @@
import pytest
import shlex
import spack
import spack.spec as sp
from spack.parse import Token
from spack.spec import *
@ -314,33 +315,20 @@ def test_multiple_specs_with_hash(self, database):
assert len(specs) == 2
def test_ambiguous_hash(self, database):
dbspecs = database.mock.db.query()
def find_ambiguous(specs, keyfun):
"""Return the first set of specs that's ambiguous under a
particular key function."""
key_to_spec = {}
for spec in specs:
key = keyfun(spec)
speclist = key_to_spec.setdefault(key, [])
speclist.append(spec)
if len(speclist) > 1:
return (key, speclist)
# If we fail here, we may need to guarantee that there are
# some ambiguos specs by adding more specs to the test DB
# until this succeeds.
raise RuntimeError("no ambiguous specs found for keyfun!")
x1 = Spec('a')
x1._hash = 'xy'
x1._concrete = True
x2 = Spec('a')
x2._hash = 'xx'
x2._concrete = True
database.mock.db.add(x1, spack.store.layout)
database.mock.db.add(x2, spack.store.layout)
# ambiguity in first hash character
char, specs = find_ambiguous(dbspecs, lambda s: s.dag_hash()[0])
self._check_raises(AmbiguousHashError, ['/' + char])
self._check_raises(AmbiguousHashError, ['/x'])
# ambiguity in first hash character AND spec name
t, specs = find_ambiguous(dbspecs,
lambda s: (s.name, s.dag_hash()[0]))
name, char = t
self._check_raises(AmbiguousHashError, [name + '/' + char])
self._check_raises(AmbiguousHashError, ['a/x'])
def test_invalid_hash(self, database):
mpileaks_zmpi = database.mock.db.query_one('mpileaks ^zmpi')