tests: make the dependency patching test more complete

- dependency patching test didn't attempt to apply patches; just to see
  whether they were on the spec.

- it applies the patch now and verifies that that patch was applied.
This commit is contained in:
Todd Gamblin 2018-08-14 00:07:46 -07:00
parent 85d00c5ef4
commit 62026ce302
5 changed files with 33 additions and 5 deletions

View File

@ -388,6 +388,7 @@ def install_mockery(tmpdir, config, mock_packages):
with spack.config.override('config:checksum', False):
yield
tmpdir.join('opt').remove()
spack.store.store = real_store

View File

@ -31,6 +31,7 @@
import spack.paths
import spack.util.compression
from spack.util.executable import Executable
from spack.stage import Stage
from spack.spec import Spec
@ -108,16 +109,32 @@ def test_patch_in_spec(mock_packages, config):
spec.variants['patches'].value)
def test_patched_dependency(mock_packages, config):
def test_patched_dependency(
mock_packages, config, install_mockery, mock_fetch):
"""Test whether patched dependencies work."""
spec = Spec('patch-a-dependency')
spec.concretize()
assert 'patches' in list(spec['libelf'].variants.keys())
# foo
assert (('b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c',) ==
# make sure the patch makes it into the dependency spec
assert (('c45c1564f70def3fc1a6e22139f62cb21cd190cc3a7dbe6f4120fa59ce33dcb8',) ==
spec['libelf'].variants['patches'].value)
# make sure the patch in the dependent's directory is applied to the
# dependency
libelf = spec['libelf']
pkg = libelf.package
pkg.do_patch()
with pkg.stage:
with working_dir(pkg.stage.source_path):
# output a Makefile with 'echo Patched!' as the default target
configure = Executable('./configure')
configure()
# Make sure the Makefile contains the patched text
with open('Makefile') as mf:
assert 'Patched!' in mf.read()
def test_multiple_patched_dependencies(mock_packages, config):
"""Test whether multiple patched dependencies work."""

View File

@ -0,0 +1,11 @@
--- patch-a-dependency/configure 2018-08-13 23:13:51.000000000 -0700
+++ patch-a-dependency/configure.patched 2018-08-13 23:14:15.000000000 -0700
@@ -2,7 +2,7 @@
prefix=$(echo $1 | sed 's/--prefix=//')
cat > Makefile <<EOF
all:
- echo Building...
+ echo Patched!
install:
mkdir -p $prefix

View File

@ -33,7 +33,7 @@ class PatchADependency(Package):
version('1.0', '0123456789abcdef0123456789abcdef')
depends_on('libelf', patches=patch('foo.patch'))
depends_on('libelf', patches=patch('libelf.patch'))
def install(self, spec, prefix):
pass