summaryrefslogtreecommitdiff
path: root/lib/spack/spack/cmd/compiler.py
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2020-05-07 14:01:58 -0700
committerGitHub <noreply@github.com>2020-05-07 14:01:58 -0700
commit1ed564a1e623812c3902d8c592e00e5a3367bcb3 (patch)
treeb86aafcf98a41c7cddcbf1383c9a50212e744141 /lib/spack/spack/cmd/compiler.py
parentd7bd070ae9ab6b2094867f39fa7b7fab5520bdb9 (diff)
downloadspack-1ed564a1e623812c3902d8c592e00e5a3367bcb3.tar.gz
spack-1ed564a1e623812c3902d8c592e00e5a3367bcb3.tar.bz2
spack-1ed564a1e623812c3902d8c592e00e5a3367bcb3.tar.xz
spack-1ed564a1e623812c3902d8c592e00e5a3367bcb3.zip
Testing: fix unintended interactions between tests, part 2 (#16429)
This fixes some errors with setting up test configuration. These errors do not cause current Spack tests to fail but do create red herring issues elsewhere (see #15666). Fixing these errors leads to more errors in tests that depended on the original misconfigured state, so those are also addressed here. This is an update to #16003 which accounts for some unit tests with conflicting config/mutable_config fixtures. These conflicts were not exposed until the mutable_config fixture was fixed. Details are included below. The change which builds on #16003 is prefixed with "(new)". * For tests that use the real Spack package repository, the config needs to avoid using MPI providers that are not intended to be installed by Spack. Without this, it is possible that Spack tests which concretize the MPI virtual will end up trying to use an implementation that it shouldn't (e.g. one that is always provided externally). See #15666 for an example. * The mutable_config test fixture was not initializing the scope roots to the right directories (so the resulting config was empty). * The current_host fixture in the concretize.py tests was using the config fixture rather than mutable_config, and was polluting the config cache for other tests. * One test in concretize.py was clearing a nonexistent cache (PackagePrefs._packages_config_cache). This reference has been removed. * The test 'test_preferred_compilers' was was depending on cross test config pollution to succeed. The initial spec before concretization has been updated to updated to be explicit about the desired result. * (new) For tests that use install_mockery and mutable_config, replace install_mockery with a separate install_mockery_mutable_config fixture that is exactly the same as install_mockery but uses the mutable_config fixture to avoid conflicts.
Diffstat (limited to 'lib/spack/spack/cmd/compiler.py')
-rw-r--r--lib/spack/spack/cmd/compiler.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/spack/spack/cmd/compiler.py b/lib/spack/spack/cmd/compiler.py
index 625466f8c7..c8f52af04d 100644
--- a/lib/spack/spack/cmd/compiler.py
+++ b/lib/spack/spack/cmd/compiler.py
@@ -159,7 +159,19 @@ def compiler_list(args):
tty.msg("Available compilers")
index = index_by(spack.compilers.all_compilers(scope=args.scope),
lambda c: (c.spec.name, c.operating_system, c.target))
- ordered_sections = sorted(index.items(), key=lambda item: item[0])
+
+ # For a container, take each element which does not evaluate to false and
+ # convert it to a string. For elements which evaluate to False (e.g. None)
+ # convert them to '' (in which case it still evaluates to False but is a
+ # string type). Tuples produced by this are guaranteed to be comparable in
+ # Python 3
+ convert_str = (
+ lambda tuple_container:
+ tuple(str(x) if x else '' for x in tuple_container))
+
+ index_str_keys = list(
+ (convert_str(x), y) for x, y in index.items())
+ ordered_sections = sorted(index_str_keys, key=lambda item: item[0])
for i, (key, compilers) in enumerate(ordered_sections):
if i >= 1:
print()