summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/test/conftest.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py
index 6703742142..a186463907 100644
--- a/lib/spack/spack/test/conftest.py
+++ b/lib/spack/spack/test/conftest.py
@@ -301,8 +301,17 @@ def use_configuration(config):
"""Context manager to swap out the global Spack configuration."""
saved = spack.config.config
spack.config.config = config
+
+ # Avoid using real spack configuration that has been cached by other
+ # tests, and avoid polluting the cache with spack test configuration
+ # (including modified configuration)
+ saved_compiler_cache = spack.compilers._cache_config_file
+ spack.compilers._cache_config_file = []
+
yield
+
spack.config.config = saved
+ spack.compilers._cache_config_file = saved_compiler_cache
@contextlib.contextmanager
@@ -427,10 +436,6 @@ def mutable_config(tmpdir_factory, configuration_dir, monkeypatch):
*[spack.config.ConfigScope(name, str(mutable_dir))
for name in ['site', 'system', 'user']])
- # This is essential, otherwise the cache will create weird side effects
- # that will compromise subsequent tests if compilers.yaml is modified
- monkeypatch.setattr(spack.compilers, '_cache_config_file', [])
-
with use_configuration(cfg):
yield cfg