init: remove template_dirs global
- remove template_dirs global variable from __init__.py - also remove update_template_dirs fixture, which had no effect on test correctness
This commit is contained in:
parent
77bd2dd706
commit
278933e824
@ -38,18 +38,12 @@
|
|||||||
# TODO: Below code should not import modules other than spack.config
|
# TODO: Below code should not import modules other than spack.config
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
import spack.config
|
import spack.config
|
||||||
from spack.util.path import canonicalize_path
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: get this out of __init__.py
|
# TODO: get this out of __init__.py
|
||||||
binary_cache_retrieved_specs = set()
|
binary_cache_retrieved_specs = set()
|
||||||
|
|
||||||
|
|
||||||
#: Directories where to search for templates
|
|
||||||
template_dirs = spack.config.get('config:template_dirs')
|
|
||||||
template_dirs = [canonicalize_path(x) for x in template_dirs]
|
|
||||||
|
|
||||||
|
|
||||||
# If this is True, spack will not clean the environment to remove
|
# If this is True, spack will not clean the environment to remove
|
||||||
# potentially harmful variables before builds.
|
# potentially harmful variables before builds.
|
||||||
dirty = spack.config.get('config:dirty', False)
|
dirty = spack.config.get('config:dirty', False)
|
||||||
|
@ -22,13 +22,14 @@
|
|||||||
# License along with this program; if not, write to the Free Software
|
# License along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
import jinja2
|
import jinja2
|
||||||
import llnl.util.lang
|
import llnl.util.lang
|
||||||
import six
|
import six
|
||||||
import spack
|
|
||||||
|
import spack.config
|
||||||
|
from spack.util.path import canonicalize_path
|
||||||
|
|
||||||
|
|
||||||
TemplateNotFound = jinja2.TemplateNotFound
|
TemplateNotFound = jinja2.TemplateNotFound
|
||||||
@ -90,7 +91,8 @@ def make_environment(dirs=None):
|
|||||||
"""Returns an configured environment for template rendering."""
|
"""Returns an configured environment for template rendering."""
|
||||||
if dirs is None:
|
if dirs is None:
|
||||||
# Default directories where to search for templates
|
# Default directories where to search for templates
|
||||||
dirs = spack.template_dirs
|
dirs = [canonicalize_path(d)
|
||||||
|
for d in spack.config.get('config:template_dirs')]
|
||||||
# Loader for the templates
|
# Loader for the templates
|
||||||
loader = jinja2.FileSystemLoader(dirs)
|
loader = jinja2.FileSystemLoader(dirs)
|
||||||
# Environment of the template engine
|
# Environment of the template engine
|
||||||
|
@ -90,14 +90,6 @@ def _impl(spec_str):
|
|||||||
return _impl
|
return _impl
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
|
||||||
def update_template_dirs(config, monkeypatch):
|
|
||||||
"""Mocks the template directories for tests"""
|
|
||||||
dirs = spack.config.get('config:template_dirs')
|
|
||||||
dirs = [spack.util.path.canonicalize_path(x) for x in dirs]
|
|
||||||
monkeypatch.setattr(spack, 'template_dirs', dirs)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def patch_configuration(monkeypatch, request):
|
def patch_configuration(monkeypatch, request):
|
||||||
"""Reads a configuration file from the mock ones prepared for tests
|
"""Reads a configuration file from the mock ones prepared for tests
|
||||||
|
@ -45,7 +45,6 @@ def test_dotkit(self, modulefile_content, patch_configuration):
|
|||||||
assert '#d mpileaks @2.3' in content
|
assert '#d mpileaks @2.3' in content
|
||||||
assert len([x for x in content if 'dk_op' in x]) == 2
|
assert len([x for x in content if 'dk_op' in x]) == 2
|
||||||
|
|
||||||
@pytest.mark.usefixtures('update_template_dirs')
|
|
||||||
def test_override_template_in_package(
|
def test_override_template_in_package(
|
||||||
self, modulefile_content, patch_configuration
|
self, modulefile_content, patch_configuration
|
||||||
):
|
):
|
||||||
@ -56,7 +55,6 @@ def test_override_template_in_package(
|
|||||||
|
|
||||||
assert 'Override successful!' in content
|
assert 'Override successful!' in content
|
||||||
|
|
||||||
@pytest.mark.usefixtures('update_template_dirs')
|
|
||||||
def test_override_template_in_modules_yaml(
|
def test_override_template_in_modules_yaml(
|
||||||
self, modulefile_content, patch_configuration
|
self, modulefile_content, patch_configuration
|
||||||
):
|
):
|
||||||
|
@ -213,7 +213,6 @@ def test_non_virtual_in_hierarchy(self, factory, patch_configuration):
|
|||||||
with pytest.raises(spack.modules.lmod.NonVirtualInHierarchyError):
|
with pytest.raises(spack.modules.lmod.NonVirtualInHierarchyError):
|
||||||
module.write()
|
module.write()
|
||||||
|
|
||||||
@pytest.mark.usefixtures('update_template_dirs')
|
|
||||||
def test_override_template_in_package(
|
def test_override_template_in_package(
|
||||||
self, modulefile_content, patch_configuration
|
self, modulefile_content, patch_configuration
|
||||||
):
|
):
|
||||||
@ -224,7 +223,6 @@ def test_override_template_in_package(
|
|||||||
|
|
||||||
assert 'Override successful!' in content
|
assert 'Override successful!' in content
|
||||||
|
|
||||||
@pytest.mark.usefixtures('update_template_dirs')
|
|
||||||
def test_override_template_in_modules_yaml(
|
def test_override_template_in_modules_yaml(
|
||||||
self, modulefile_content, patch_configuration
|
self, modulefile_content, patch_configuration
|
||||||
):
|
):
|
||||||
|
@ -241,7 +241,6 @@ def test_setup_environment(self, modulefile_content, patch_configuration):
|
|||||||
[x for x in content if 'setenv FOOBAR "callpath"' in x]
|
[x for x in content if 'setenv FOOBAR "callpath"' in x]
|
||||||
) == 1
|
) == 1
|
||||||
|
|
||||||
@pytest.mark.usefixtures('update_template_dirs')
|
|
||||||
def test_override_template_in_package(
|
def test_override_template_in_package(
|
||||||
self, modulefile_content, patch_configuration
|
self, modulefile_content, patch_configuration
|
||||||
):
|
):
|
||||||
@ -252,7 +251,6 @@ def test_override_template_in_package(
|
|||||||
|
|
||||||
assert 'Override successful!' in content
|
assert 'Override successful!' in content
|
||||||
|
|
||||||
@pytest.mark.usefixtures('update_template_dirs')
|
|
||||||
def test_override_template_in_modules_yaml(
|
def test_override_template_in_modules_yaml(
|
||||||
self, modulefile_content, patch_configuration
|
self, modulefile_content, patch_configuration
|
||||||
):
|
):
|
||||||
@ -265,7 +263,6 @@ def test_override_template_in_modules_yaml(
|
|||||||
content = modulefile_content('mpileaks arch=x86-linux')
|
content = modulefile_content('mpileaks arch=x86-linux')
|
||||||
assert 'Override even better!' in content
|
assert 'Override even better!' in content
|
||||||
|
|
||||||
@pytest.mark.usefixtures('update_template_dirs')
|
|
||||||
def test_extend_context(
|
def test_extend_context(
|
||||||
self, modulefile_content, patch_configuration
|
self, modulefile_content, patch_configuration
|
||||||
):
|
):
|
||||||
|
Loading…
Reference in New Issue
Block a user