diff options
author | Gregory Becker <becker33@llnl.gov> | 2016-01-08 15:13:48 -0800 |
---|---|---|
committer | Gregory Becker <becker33@llnl.gov> | 2016-01-08 15:13:48 -0800 |
commit | aa28e4e81f80a1a388aabe589ca23955ebd9721b (patch) | |
tree | 2e8bf169c7754beee088ac3fe6c0f6defe8bbe8e /lib | |
parent | 6da1a105cb448ec3c4f8ca4910b5bc9f12044001 (diff) | |
download | spack-aa28e4e81f80a1a388aabe589ca23955ebd9721b.tar.gz spack-aa28e4e81f80a1a388aabe589ca23955ebd9721b.tar.bz2 spack-aa28e4e81f80a1a388aabe589ca23955ebd9721b.tar.xz spack-aa28e4e81f80a1a388aabe589ca23955ebd9721b.zip |
Improved error messages for compiler_for_spec when either zero or multiple compilers returned.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/compilers/__init__.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index 87106282cf..3a0a88b5e3 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -219,7 +219,10 @@ def compiler_for_spec(compiler_spec, target): compilers = [c for c in compilers if c.modules is None] elif target.compiler_strategy == "MODULES": compilers = [c for c in compilers if c.modules is not None] - assert(len(compilers) == 1) + if len(compilers) < 1: + raise NoCompilerForSpecError(compiler_spec, target) + if len(compilers) > 1: + raise CompilerSpecInsufficientlySpecificError(compiler_spec) return compilers[0] @@ -253,3 +256,13 @@ class InvalidCompilerConfigurationError(spack.error.SpackError): class NoCompilersError(spack.error.SpackError): def __init__(self): super(NoCompilersError, self).__init__("Spack could not find any compilers!") + +class NoCompilerForSpecError(spack.error.SpackError): + def __init__(self, compiler_spec, target): + super(NoCompilerForSpecError, self).__init__("No compilers for target %s satisfy spec %s", + compiler_spec, target) + +class CompilerSpecInsufficientlySpecificError(spack.error.SpackError): + def __init__(self, compiler_spec): + super(CompilerSpecInsufficientlySpecificError, self).__init__("Multiple compilers satisfy spec %s", + compiler_spec) |