summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2018-07-09 11:04:37 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2018-07-24 11:27:17 -0700
commit7a49ba56b65174488e7b1f16018c1bb1874bce20 (patch)
treecadc589110e85f62a2f44dda252e914a89ca2af8
parentff83003eafd4ebe9d76b9850dc1be836a77828df (diff)
downloadspack-7a49ba56b65174488e7b1f16018c1bb1874bce20.tar.gz
spack-7a49ba56b65174488e7b1f16018c1bb1874bce20.tar.bz2
spack-7a49ba56b65174488e7b1f16018c1bb1874bce20.tar.xz
spack-7a49ba56b65174488e7b1f16018c1bb1874bce20.zip
Added blacklisting of implicit modules in docs + regression tests
fixes #4400 The feature requested in #4400 was already part of the module file configuration, but it was neither tested nor documented. This commit takes care of adding a few lines in the documentation and a regression test.
-rw-r--r--lib/spack/docs/tutorial_modules.rst20
-rw-r--r--lib/spack/spack/schema/modules.py4
-rw-r--r--lib/spack/spack/test/conftest.py2
-rw-r--r--lib/spack/spack/test/data/modules/tcl/blacklist_implicits.yaml6
-rw-r--r--lib/spack/spack/test/modules/tcl.py21
5 files changed, 52 insertions, 1 deletions
diff --git a/lib/spack/docs/tutorial_modules.rst b/lib/spack/docs/tutorial_modules.rst
index 1ae4bd79ea..59a52b87df 100644
--- a/lib/spack/docs/tutorial_modules.rst
+++ b/lib/spack/docs/tutorial_modules.rst
@@ -555,6 +555,26 @@ you'll see that now the module for ``gcc@7.2.0`` has reappeared:
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".
+An additional possibility that you can leverage to unclutter the environment
+is that of preventing the generation of module files for implicitly installed
+packages. In this case all one needs to do is to add the following line:
+
+.. code-block:: yaml
+ :emphasize-lines: 3
+
+ modules:
+ tcl:
+ blacklist_implicits: true
+ whitelist:
+ - gcc
+ blacklist:
+ - '%gcc@5.4.0'
+ all:
+ filter:
+ environment_blacklist: ['CPATH', 'LIBRARY_PATH']
+
+to ``modules.yaml`` and regenerate the module file tree as above.
+
^^^^^^^^^^^^^^^^^^^^^^^^^
Change module file naming
^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/lib/spack/spack/schema/modules.py b/lib/spack/spack/schema/modules.py
index efd093a9cb..458b40b81d 100644
--- a/lib/spack/spack/schema/modules.py
+++ b/lib/spack/spack/schema/modules.py
@@ -121,6 +121,10 @@ schema = {
'$ref': '#/definitions/array_of_strings'},
'blacklist': {
'$ref': '#/definitions/array_of_strings'},
+ 'blacklist_implicits': {
+ 'type': 'boolean',
+ 'default': False
+ },
'naming_scheme': {
'type': 'string' # Can we be more specific here?
}
diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py
index 44350dfb50..860732b873 100644
--- a/lib/spack/spack/test/conftest.py
+++ b/lib/spack/spack/test/conftest.py
@@ -327,7 +327,7 @@ def _populate(mock_db):
def _install(spec):
s = spack.spec.Spec(spec).concretized()
pkg = spack.repo.get(s)
- pkg.do_install(fake=True)
+ pkg.do_install(fake=True, explicit=True)
# Transaction used to avoid repeated writes.
with mock_db.write_transaction():
diff --git a/lib/spack/spack/test/data/modules/tcl/blacklist_implicits.yaml b/lib/spack/spack/test/data/modules/tcl/blacklist_implicits.yaml
new file mode 100644
index 0000000000..4d5fbfb04a
--- /dev/null
+++ b/lib/spack/spack/test/data/modules/tcl/blacklist_implicits.yaml
@@ -0,0 +1,6 @@
+enable:
+ - tcl
+tcl:
+ blacklist_implicits: true
+ all:
+ autoload: 'direct'
diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py
index 52415bd791..21e9ae0209 100644
--- a/lib/spack/spack/test/modules/tcl.py
+++ b/lib/spack/spack/test/modules/tcl.py
@@ -274,3 +274,24 @@ class TestTcl(object):
short_description = 'module-whatis "This package updates the context for TCL modulefiles."' # NOQA: ignore=E501
assert short_description in content
+
+ @pytest.mark.regression('4400')
+ @pytest.mark.db
+ def test_blacklist_implicits(
+ self, modulefile_content, module_configuration, database
+ ):
+ module_configuration('blacklist_implicits')
+
+ # mpileaks has been installed explicitly when setting up
+ # the tests database
+ mpileaks_specs = database.query('mpileaks')
+ for item in mpileaks_specs:
+ writer = writer_cls(item)
+ assert not writer.conf.blacklisted
+
+ # callpath is a dependency of mpileaks, and has been pulled
+ # in implicitly
+ callpath_specs = database.query('callpath')
+ for item in callpath_specs:
+ writer = writer_cls(item)
+ assert writer.conf.blacklisted