Skip to content
Snippets Groups Projects
Commit 2e3303ab authored by Todd Gamblin's avatar Todd Gamblin
Browse files

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.
parent d763e921
Branches
Tags
No related merge requests found
......@@ -194,7 +194,7 @@ def remove_directives(arg):
# 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
......
......@@ -11,6 +11,7 @@
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."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment