summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-12-27 15:30:32 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2018-12-30 00:19:08 -0800
commit2e3303abd08aec1c7a53e78fabbbf13f6de5b5b3 (patch)
tree9675dcba0c62816f071b529dbfd9af202ce245dc /lib
parentd763e921418dab339e45406c6083b3540695abd6 (diff)
downloadspack-2e3303abd08aec1c7a53e78fabbbf13f6de5b5b3.tar.gz
spack-2e3303abd08aec1c7a53e78fabbbf13f6de5b5b3.tar.bz2
spack-2e3303abd08aec1c7a53e78fabbbf13f6de5b5b3.tar.xz
spack-2e3303abd08aec1c7a53e78fabbbf13f6de5b5b3.zip
bugfix: nested directives were broken in python 3
- The nested directive implementation was broken for python 3 - directive results were not properly removed from the directive list when it was processed in the DirectiveMeta metaclass. - the issue was that remove_directives only descended into a list or tuple, but in Python3, the initial value passed to the function is a view of dictionary values. - make it a list to fix things, and add a regression test.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/directives.py2
-rw-r--r--lib/spack/spack/test/patch.py24
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py
index 5b2bf652ed..8e9cf4dbcc 100644
--- a/lib/spack/spack/directives.py
+++ b/lib/spack/spack/directives.py
@@ -194,7 +194,7 @@ class DirectiveMeta(type):
# Nasty, but it's the best way I can think of to avoid
# side effects if directive results are passed as args
remove_directives(args)
- remove_directives(kwargs.values())
+ remove_directives(list(kwargs.values()))
# A directive returns either something that is callable on a
# package or a sequence of them
diff --git a/lib/spack/spack/test/patch.py b/lib/spack/spack/test/patch.py
index 33db0d2a39..bdc67968f6 100644
--- a/lib/spack/spack/test/patch.py
+++ b/lib/spack/spack/test/patch.py
@@ -11,6 +11,7 @@ from llnl.util.filesystem import working_dir, mkdirp
import spack.patch
import spack.paths
+import spack.repo
import spack.util.compression
from spack.util.executable import Executable
from spack.stage import Stage
@@ -102,6 +103,29 @@ def test_patch_in_spec(mock_packages, config):
spec.variants['patches'].value)
+def test_nested_directives(mock_packages):
+ """Ensure pkg data structures are set up properly by nested directives."""
+ # this ensures that the patch() directive results were removed
+ # properly from the DirectiveMeta._directives_to_be_executed list
+ patcher = spack.repo.path.get_pkg_class('patch-several-dependencies')
+ assert len(patcher.patches) == 0
+
+ # this ensures that results of dependency patches were properly added
+ # to Dependency objects.
+ libelf_dep = next(iter(patcher.dependencies['libelf'].values()))
+ assert len(libelf_dep.patches) == 1
+ assert len(libelf_dep.patches[Spec('libelf')]) == 1
+
+ libdwarf_dep = next(iter(patcher.dependencies['libdwarf'].values()))
+ assert len(libdwarf_dep.patches) == 2
+ assert len(libdwarf_dep.patches[Spec('libdwarf')]) == 1
+ assert len(libdwarf_dep.patches[Spec('libdwarf@20111030')]) == 1
+
+ fake_dep = next(iter(patcher.dependencies['fake'].values()))
+ assert len(fake_dep.patches) == 1
+ assert len(fake_dep.patches[Spec('fake')]) == 2
+
+
def test_patched_dependency(
mock_packages, config, install_mockery, mock_fetch):
"""Test whether patched dependencies work."""