Exemplo n.º 1
0
def test_package_hash_consistency(package_spec, expected_hash):
    """Ensure that that package hash is consistent python version to version.

    We assume these tests run across all supported Python versions in CI, and we ensure
    consistency with recorded hashes for some well known inputs.

    If this fails, then something about the way the python AST works has likely changed.
    If Spack is running in a new python version, we might need to modify the unparser to
    handle it. If not, then something has become inconsistent about the way we unparse
    Python code across versions.

    """
    spec = Spec(package_spec)
    filename = os.path.join(datadir, "%s.txt" % spec.name)
    with open(filename) as f:
        source = f.read()
    h = ph.package_hash(spec, source=source)
    assert expected_hash == h
Exemplo n.º 2
0
def test_hash(tmpdir, mock_packages, config):
    package_hash("[email protected]")
Exemplo n.º 3
0
def test_different_variants(tmpdir, mock_packages, config):
    spec1 = Spec("[email protected] +variantx")
    spec2 = Spec("[email protected] +varianty")
    assert package_hash(spec1) == package_hash(spec2)
Exemplo n.º 4
0
def test_hash(tmpdir, builtin_mock, config):
    package_hash("[email protected]")
Exemplo n.º 5
0
def test_hash(mock_packages, config):
    ph.package_hash("[email protected]")
Exemplo n.º 6
0
def pkg_hash(args):
    """dump canonical source code hash for a package spec"""
    specs = spack.cmd.parse_specs(args.spec, concretize=False)

    for spec in specs:
        print(ph.package_hash(spec))