summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/test/config.py29
-rw-r--r--lib/spack/spack/test/conftest.py46
-rw-r--r--lib/spack/spack/test/data/config/concretizer.yaml2
-rw-r--r--lib/spack/spack/test/data/config/config.yaml6
-rw-r--r--lib/spack/spack/test/data/config/modules.yaml46
5 files changed, 60 insertions, 69 deletions
diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py
index 64fe403daa..14b76b06bf 100644
--- a/lib/spack/spack/test/config.py
+++ b/lib/spack/spack/test/config.py
@@ -492,7 +492,7 @@ full_padded_string = os.path.join(os.sep + "path", os.sep.join(reps))[:MAX_PADDE
],
)
def test_parse_install_tree(config_settings, expected, mutable_config):
- expected_root = expected[0] or spack.store.DEFAULT_INSTALL_TREE_ROOT
+ expected_root = expected[0] or mutable_config.get("config:install_tree:root")
expected_unpadded_root = expected[1] or expected_root
expected_proj = expected[2] or spack.directory_layout.default_projections
@@ -575,7 +575,7 @@ def test_change_or_add(mutable_config, mock_packages):
],
)
def test_parse_install_tree_padded(config_settings, expected, mutable_config):
- expected_root = expected[0] or spack.store.DEFAULT_INSTALL_TREE_ROOT
+ expected_root = expected[0] or mutable_config.get("config:install_tree:root")
expected_unpadded_root = expected[1] or expected_root
expected_proj = expected[2] or spack.directory_layout.default_projections
@@ -761,25 +761,20 @@ def test_internal_config_from_data():
assert config.get("config:checksum", scope="higher") is True
-def test_keys_are_ordered():
+def test_keys_are_ordered(configuration_dir):
"""Test that keys in Spack YAML files retain their order from the file."""
expected_order = (
- "bin",
- "man",
- "share/man",
- "share/aclocal",
- "lib",
- "lib64",
- "include",
- "lib/pkgconfig",
- "lib64/pkgconfig",
- "share/pkgconfig",
- "",
+ "./bin",
+ "./man",
+ "./share/man",
+ "./share/aclocal",
+ "./lib/pkgconfig",
+ "./lib64/pkgconfig",
+ "./share/pkgconfig",
+ "./",
)
- config_scope = spack.config.ConfigScope(
- "modules", os.path.join(spack.paths.test_path, "data", "config")
- )
+ config_scope = spack.config.ConfigScope("modules", configuration_dir.join("site"))
data = config_scope.get_section("modules")
diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py
index 99eac4004f..7a6bd0622f 100644
--- a/lib/spack/spack/test/conftest.py
+++ b/lib/spack/spack/test/conftest.py
@@ -12,6 +12,7 @@ import itertools
import json
import os
import os.path
+import pathlib
import re
import shutil
import stat
@@ -32,6 +33,7 @@ import llnl.util.tty as tty
from llnl.util.filesystem import copy_tree, mkdirp, remove_linked_tree, touchp, working_dir
import spack.binary_distribution
+import spack.bootstrap.core
import spack.caches
import spack.cmd.buildcache
import spack.compiler
@@ -682,36 +684,34 @@ def configuration_dir(tmpdir_factory, linux_os):
directory path.
"""
tmpdir = tmpdir_factory.mktemp("configurations")
+ install_tree_root = tmpdir_factory.mktemp("opt")
+ modules_root = tmpdir_factory.mktemp("share")
+ tcl_root = modules_root.ensure("modules", dir=True)
+ lmod_root = modules_root.ensure("lmod", 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"))
+ test_config = pathlib.Path(spack.paths.test_path) / "data" / "config"
+ shutil.copytree(test_config, tmpdir.join("site"))
# Create temporary 'defaults', 'site' and 'user' folders
tmpdir.ensure("user", dir=True)
- # Slightly modify config.yaml and compilers.yaml
- if sys.platform == "win32":
- locks = False
- else:
- locks = True
-
+ # Fill out config.yaml, compilers.yaml and modules.yaml templates.
solver = os.environ.get("SPACK_TEST_SOLVER", "clingo")
- config_yaml = test_config.join("config.yaml")
- modules_root = tmpdir_factory.mktemp("share")
- tcl_root = modules_root.ensure("modules", dir=True)
- lmod_root = modules_root.ensure("lmod", dir=True)
- content = "".join(config_yaml.read()).format(solver, locks, str(tcl_root), str(lmod_root))
- t = tmpdir.join("site", "config.yaml")
- t.write(content)
-
- compilers_yaml = test_config.join("compilers.yaml")
- content = "".join(compilers_yaml.read()).format(
- linux_os=linux_os, target=str(archspec.cpu.host().family)
- )
- t = tmpdir.join("site", "compilers.yaml")
- t.write(content)
+ locks = sys.platform != "win32"
+ config = tmpdir.join("site", "config.yaml")
+ config_template = test_config / "config.yaml"
+ config.write(config_template.read_text().format(install_tree_root, solver, locks))
+
+ target = str(archspec.cpu.host().family)
+ compilers = tmpdir.join("site", "compilers.yaml")
+ compilers_template = test_config / "compilers.yaml"
+ compilers.write(compilers_template.read_text().format(linux_os=linux_os, target=target))
+
+ modules = tmpdir.join("site", "modules.yaml")
+ modules_template = test_config / "modules.yaml"
+ modules.write(modules_template.read_text().format(tcl_root, lmod_root))
yield tmpdir
@@ -1702,7 +1702,7 @@ def mock_executable(tmp_path):
executable_path = executable_dir / name
if sys.platform == "win32":
executable_path = executable_dir / (name + ".bat")
- executable_path.write_text(f"{ shebang }{ output }\n")
+ executable_path.write_text(f"{shebang}{output}\n")
executable_path.chmod(0o755)
return executable_path
diff --git a/lib/spack/spack/test/data/config/concretizer.yaml b/lib/spack/spack/test/data/config/concretizer.yaml
index 538182c957..a89a42a906 100644
--- a/lib/spack/spack/test/data/config/concretizer.yaml
+++ b/lib/spack/spack/test/data/config/concretizer.yaml
@@ -1,5 +1,5 @@
concretizer:
- reuse: True
+ reuse: true
targets:
granularity: microarchitectures
host_compatible: false
diff --git a/lib/spack/spack/test/data/config/config.yaml b/lib/spack/spack/test/data/config/config.yaml
index eb239a5b99..4a8da4e25f 100644
--- a/lib/spack/spack/test/data/config/config.yaml
+++ b/lib/spack/spack/test/data/config/config.yaml
@@ -1,6 +1,6 @@
config:
install_tree:
- root: $spack/opt/spack
+ root: {0}
template_dirs:
- $spack/share/spack/templates
- $spack/lib/spack/spack/test/data/templates
@@ -13,5 +13,5 @@ config:
ssl_certs: $SSL_CERT_FILE
checksum: true
dirty: false
- concretizer: {0}
- locks: {1}
+ concretizer: {1}
+ locks: {2}
diff --git a/lib/spack/spack/test/data/config/modules.yaml b/lib/spack/spack/test/data/config/modules.yaml
index f217dd7eaf..bd19ca066a 100644
--- a/lib/spack/spack/test/data/config/modules.yaml
+++ b/lib/spack/spack/test/data/config/modules.yaml
@@ -14,29 +14,25 @@
# ~/.spack/modules.yaml
# -------------------------------------------------------------------------
modules:
- default: {}
prefix_inspections:
- bin:
- - PATH
- man:
- - MANPATH
- share/man:
- - MANPATH
- share/aclocal:
- - ACLOCAL_PATH
- lib:
- - LIBRARY_PATH
- - LD_LIBRARY_PATH
- lib64:
- - LIBRARY_PATH
- - LD_LIBRARY_PATH
- include:
- - CPATH
- lib/pkgconfig:
- - PKG_CONFIG_PATH
- lib64/pkgconfig:
- - PKG_CONFIG_PATH
- share/pkgconfig:
- - PKG_CONFIG_PATH
- '':
- - CMAKE_PREFIX_PATH
+ ./bin: [PATH]
+ ./man: [MANPATH]
+ ./share/man: [MANPATH]
+ ./share/aclocal: [ACLOCAL_PATH]
+ ./lib/pkgconfig: [PKG_CONFIG_PATH]
+ ./lib64/pkgconfig: [PKG_CONFIG_PATH]
+ ./share/pkgconfig: [PKG_CONFIG_PATH]
+ ./: [CMAKE_PREFIX_PATH]
+ default:
+ roots:
+ tcl: {0}
+ lmod: {1}
+ enable: []
+ tcl:
+ all:
+ autoload: direct
+ lmod:
+ all:
+ autoload: direct
+ hierarchy:
+ - mpi