summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/data/modules/tcl/module_path_separator.yaml5
-rw-r--r--lib/spack/spack/test/modules/lmod.py17
-rw-r--r--lib/spack/spack/test/modules/tcl.py13
3 files changed, 27 insertions, 8 deletions
diff --git a/lib/spack/spack/test/data/modules/tcl/module_path_separator.yaml b/lib/spack/spack/test/data/modules/tcl/module_path_separator.yaml
new file mode 100644
index 0000000000..683a2ffffd
--- /dev/null
+++ b/lib/spack/spack/test/data/modules/tcl/module_path_separator.yaml
@@ -0,0 +1,5 @@
+enable:
+ - tcl
+tcl:
+ all:
+ autoload: none
diff --git a/lib/spack/spack/test/modules/lmod.py b/lib/spack/spack/test/modules/lmod.py
index 6e172acbf2..f002285ce0 100644
--- a/lib/spack/spack/test/modules/lmod.py
+++ b/lib/spack/spack/test/modules/lmod.py
@@ -2,7 +2,7 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import re
+
import sys
import pytest
@@ -128,21 +128,22 @@ class TestLmod(object):
content = modulefile_content("libdwarf platform=test target=core2")
- assert len([x for x in content if x.startswith('prepend-path("CMAKE_PREFIX_PATH"')]) == 0
+ assert len([x for x in content if x.startswith('prepend_path("CMAKE_PREFIX_PATH"')]) == 0
assert len([x for x in content if 'setenv("FOO", "foo")' in x]) == 0
assert len([x for x in content if 'unsetenv("BAR")' in x]) == 0
def test_prepend_path_separator(self, modulefile_content, module_configuration):
- """Tests modifications to run-time environment."""
+ """Tests that we can use custom delimiters to manipulate path lists."""
module_configuration("module_path_separator")
content = modulefile_content("module-path-separator")
- for line in content:
- if re.match(r'[a-z]+_path\("COLON"', line):
- assert line.endswith('"foo", ":")')
- elif re.match(r'[a-z]+_path\("SEMICOLON"', line):
- assert line.endswith('"bar", ";")')
+ assert len([x for x in content if 'append_path("COLON", "foo", ":")' in x]) == 1
+ assert len([x for x in content if 'prepend_path("COLON", "foo", ":")' in x]) == 1
+ assert len([x for x in content if 'remove_path("COLON", "foo", ":")' in x]) == 1
+ assert len([x for x in content if 'append_path("SEMICOLON", "bar", ";")' in x]) == 1
+ assert len([x for x in content if 'prepend_path("SEMICOLON", "bar", ";")' in x]) == 1
+ assert len([x for x in content if 'remove_path("SEMICOLON", "bar", ";")' in x]) == 1
@pytest.mark.parametrize("config_name", ["exclude", "blacklist"])
def test_exclude(self, modulefile_content, module_configuration, config_name):
diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py
index 95c241f4a1..f289e455e5 100644
--- a/lib/spack/spack/test/modules/tcl.py
+++ b/lib/spack/spack/test/modules/tcl.py
@@ -108,6 +108,19 @@ class TestTcl(object):
assert len([x for x in content if "module load foo/bar" in x]) == 1
assert len([x for x in content if "setenv LIBDWARF_ROOT" in x]) == 1
+ def test_prepend_path_separator(self, modulefile_content, module_configuration):
+ """Tests that we can use custom delimiters to manipulate path lists."""
+
+ module_configuration("module_path_separator")
+ content = modulefile_content("module-path-separator")
+
+ assert len([x for x in content if 'append-path --delim ":" COLON "foo"' in x]) == 1
+ assert len([x for x in content if 'prepend-path --delim ":" COLON "foo"' in x]) == 1
+ assert len([x for x in content if 'remove-path --delim ":" COLON "foo"' in x]) == 1
+ assert len([x for x in content if 'append-path --delim ";" SEMICOLON "bar"' in x]) == 1
+ assert len([x for x in content if 'prepend-path --delim ";" SEMICOLON "bar"' in x]) == 1
+ assert len([x for x in content if 'remove-path --delim ";" SEMICOLON "bar"' in x]) == 1
+
@pytest.mark.parametrize("config_name", ["exclude", "blacklist"])
def test_exclude(self, modulefile_content, module_configuration, config_name):
"""Tests excluding the generation of selected modules."""