Example #1
0
def test_malformed_spec_dict():
    with pytest.raises(SpecError, match='malformed'):
        Spec.from_dict(
            {'spec': {
                'nodes': [{
                    'dependencies': {
                        'name': 'foo'
                    }
                }]
            }})
Example #2
0
def test_spec_dict_hashless_dep():
    with pytest.raises(SpecError, match="Couldn't parse"):
        Spec.from_dict({
            'spec': {
                'nodes': [{
                    'name': 'foo',
                    'hash': 'thehash',
                    'dependencies': [{
                        'name': 'bar'
                    }]
                }]
            }
        })
Example #3
0
    def test_splice_dict_roundtrip(self, transitive):
        spec = Spec('splice-t')
        dep = Spec('splice-h+foo')
        spec.concretize()
        dep.concretize()
        out = spec.splice(dep, transitive)

        # Sanity check all hashes are unique...
        assert spec.full_hash() != dep.full_hash()
        assert out.full_hash() != dep.full_hash()
        assert out.full_hash() != spec.full_hash()
        out_rt_spec = Spec.from_dict(out.to_dict())  # rt is "round trip"
        assert out_rt_spec.full_hash() == out.full_hash()
        out_rt_spec_bld_hash = out_rt_spec.build_spec.full_hash()
        out_rt_spec_h_bld_hash = out_rt_spec['splice-h'].build_spec.full_hash()
        out_rt_spec_z_bld_hash = out_rt_spec['splice-z'].build_spec.full_hash()

        # In any case, the build spec for splice-t (root) should point to the
        # original spec, preserving build provenance.
        assert spec.full_hash() == out_rt_spec_bld_hash
        assert out_rt_spec.full_hash() != out_rt_spec_bld_hash

        # The build spec for splice-h should always point to the introduced
        # spec, since that is the spec spliced in.
        assert dep['splice-h'].full_hash() == out_rt_spec_h_bld_hash

        # The build spec for splice-z will depend on whether or not the splice
        # was transitive.
        expected_z_bld_hash = (dep['splice-z'].full_hash()
                               if transitive else spec['splice-z'].full_hash())
        assert expected_z_bld_hash == out_rt_spec_z_bld_hash
Example #4
0
def test_is_extension_after_round_trip_to_dict(config, spec_str):
    # x is constructed directly from string, y from a
    # round-trip to dict representation
    x = Spec(spec_str)
    x.concretize()
    y = Spec.from_dict(x.to_dict())

    # Using 'y' since the round-trip make us lose build dependencies
    for d in y.traverse():
        assert x[d.name].package.is_extension == y[d.name].package.is_extension
Example #5
0
 def from_dict(d):
     specs = [Spec.from_dict(spec_dict) for spec_dict in d['specs']]
     alias = d.get('alias', None)
     return TestSuite(specs, alias)