示例#1
0
    def test_splice_with_cached_hashes(self, transitive):
        spec = Spec('splice-t')
        dep = Spec('splice-h+foo')
        spec.concretize()
        dep.concretize()

        # monkeypatch hashes so we can test that they are cached
        spec._full_hash = 'aaaaaa'
        spec._build_hash = 'aaaaaa'
        dep._full_hash = 'bbbbbb'
        dep._build_hash = 'bbbbbb'
        spec['splice-h']._full_hash = 'cccccc'
        spec['splice-h']._build_hash = 'cccccc'
        spec['splice-z']._full_hash = 'dddddd'
        spec['splice-z']._build_hash = 'dddddd'
        dep['splice-z']._full_hash = 'eeeeee'
        dep['splice-z']._build_hash = 'eeeeee'

        out = spec.splice(dep, transitive=transitive)
        out_z_expected = (dep if transitive else spec)['splice-z']

        assert out.full_hash() != spec.full_hash()
        assert (out['splice-h'].full_hash() == dep.full_hash()) == transitive
        assert out['splice-z'].full_hash() == out_z_expected.full_hash()

        assert out.build_hash() != spec.build_hash()
        assert (out['splice-h'].build_hash() == dep.build_hash()) == transitive
        assert out['splice-z'].build_hash() == out_z_expected.build_hash()
示例#2
0
 def test_splice(self, transitive):
     # Tests the new splice function in Spec using a somewhat simple case
     # with a variant with a conditional dependency.
     # TODO: Test being able to splice in different provider for a virtual.
     # Example: mvapich for mpich.
     spec = Spec('splice-t')
     dep = Spec('splice-h+foo')
     spec.concretize()
     dep.concretize()
     # Sanity checking that these are not the same thing.
     assert dep.dag_hash() != spec['splice-h'].dag_hash()
     assert dep.build_hash() != spec['splice-h'].build_hash()
     # Do the splice.
     out = spec.splice(dep, transitive)
     # Returned spec should still be concrete.
     assert out.concrete
     # Traverse the spec and assert that all dependencies are accounted for.
     for node in spec.traverse():
         assert node.name in out
     # If the splice worked, then the full hash of the spliced dep should
     # now match the full hash of the build spec of the dependency from the
     # returned spec.
     out_h_build = out['splice-h'].build_spec
     assert out_h_build.full_hash() == dep.full_hash()
     # Transitivity should determine whether the transitive dependency was
     # changed.
     expected_z = dep['splice-z'] if transitive else spec['splice-z']
     assert out['splice-z'].full_hash() == expected_z.full_hash()
     # Sanity check build spec of out should be the original spec.
     assert (out['splice-t'].build_spec.full_hash() ==
             spec['splice-t'].full_hash())
     # Finally, the spec should know it's been spliced:
     assert out.spliced
示例#3
0
    def test_external_packages_have_consistent_hash(self):
        if spack.config.get('config:concretizer') == 'original':
            pytest.skip('This tests needs the ASP-based concretizer')

        s, t = Spec('externaltool'), Spec('externaltool')
        s._old_concretize(), t._new_concretize()

        assert s.dag_hash() == t.dag_hash()
        assert s.build_hash() == t.build_hash()
        assert s.full_hash() == t.full_hash()