From ffc91bd86ee6ff98a1307ddefb84a6b1783c96a9 Mon Sep 17 00:00:00 2001
From: Todd Gamblin <tgamblin@llnl.gov>
Date: Tue, 31 Dec 2019 12:56:21 -0800
Subject: [PATCH] tests: move mock config.yaml files to common directory

Test configuration files (except modules.yaml) were in the root level of
test/data, but should really just be in their own directory.  The absence
of modules.yaml was also breaking module tests if we got module
preferences after tests started, as the mock modules.yaml was not in the
test directory.
---
 lib/spack/spack/test/conftest.py              | 23 +++++++------------
 .../test/data/{ => config}/compilers.yaml     |  0
 .../spack/test/data/{ => config}/config.yaml  |  0
 .../test/data/{ => config}/packages.yaml      |  0
 .../spack/test/data/{ => config}/repos.yaml   |  0
 5 files changed, 8 insertions(+), 15 deletions(-)
 rename lib/spack/spack/test/data/{ => config}/compilers.yaml (100%)
 rename lib/spack/spack/test/data/{ => config}/config.yaml (100%)
 rename lib/spack/spack/test/data/{ => config}/packages.yaml (100%)
 rename lib/spack/spack/test/data/{ => config}/repos.yaml (100%)

diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py
index 572a38c225..7fb99a4147 100644
--- a/lib/spack/spack/test/conftest.py
+++ b/lib/spack/spack/test/conftest.py
@@ -363,23 +363,16 @@ def configuration_dir(tmpdir_factory, linux_os):
     """
     tmpdir = tmpdir_factory.mktemp('configurations')
 
-    # Name of the yaml files in the test/data folder
-    test_path = py.path.local(spack.paths.test_path)
-    compilers_yaml = test_path.join('data', 'compilers.yaml')
-    packages_yaml = test_path.join('data', 'packages.yaml')
-    config_yaml = test_path.join('data', 'config.yaml')
-    repos_yaml = test_path.join('data', 'repos.yaml')
-
-    # Create temporary 'site' and 'user' folders
-    tmpdir.ensure('site', dir=True)
-    tmpdir.ensure('user', dir=True)
+    # <test_path>/data/config has mock config yaml files in it
+    # copy these to the site config.
+    test_config = py.path.local(spack.paths.test_path).join('data', 'config')
+    test_config.copy(tmpdir.join('site'))
 
-    # Copy the configurations that don't need further work
-    packages_yaml.copy(tmpdir.join('site', 'packages.yaml'))
-    config_yaml.copy(tmpdir.join('site', 'config.yaml'))
-    repos_yaml.copy(tmpdir.join('site', 'repos.yaml'))
+    # Create temporary 'defaults', 'site' and 'user' folders
+    tmpdir.ensure('user', dir=True)
 
-    # Write the one that needs modifications
+    # Slightly modify compilers.yaml to look like Linux
+    compilers_yaml = test_config.join('compilers.yaml')
     content = ''.join(compilers_yaml.read()).format(linux_os)
     t = tmpdir.join('site', 'compilers.yaml')
     t.write(content)
diff --git a/lib/spack/spack/test/data/compilers.yaml b/lib/spack/spack/test/data/config/compilers.yaml
similarity index 100%
rename from lib/spack/spack/test/data/compilers.yaml
rename to lib/spack/spack/test/data/config/compilers.yaml
diff --git a/lib/spack/spack/test/data/config.yaml b/lib/spack/spack/test/data/config/config.yaml
similarity index 100%
rename from lib/spack/spack/test/data/config.yaml
rename to lib/spack/spack/test/data/config/config.yaml
diff --git a/lib/spack/spack/test/data/packages.yaml b/lib/spack/spack/test/data/config/packages.yaml
similarity index 100%
rename from lib/spack/spack/test/data/packages.yaml
rename to lib/spack/spack/test/data/config/packages.yaml
diff --git a/lib/spack/spack/test/data/repos.yaml b/lib/spack/spack/test/data/config/repos.yaml
similarity index 100%
rename from lib/spack/spack/test/data/repos.yaml
rename to lib/spack/spack/test/data/config/repos.yaml
-- 
GitLab