示例#1
0
def test_spec_concretizer_args(mutable_config, mutable_database):
    """End-to-end test of CLI concretizer prefs.

    It's here to make sure that everything works from CLI
    options to `solver.py`, and that config options are not
    lost along the way.
    """
    if spack.config.get('config:concretizer') == 'original':
        pytest.xfail('Known failure of the original concretizer')

    # remove two non-preferred mpileaks installations
    # so that reuse will pick up the zmpi one
    uninstall = SpackCommand("uninstall")
    uninstall("-y", "mpileaks^mpich")
    uninstall("-y", "mpileaks^mpich2")

    # get the hash of mpileaks^zmpi
    mpileaks_zmpi = spack.store.db.query_one("mpileaks^zmpi")
    h = mpileaks_zmpi.dag_hash()[:7]

    output = spec("--fresh", "-l", "mpileaks")
    assert h not in output

    output = spec("--reuse", "-l", "mpileaks")
    assert h in output
示例#2
0
def test_spec_parse_unquoted_flags_report():
    """Verify that a useful error message is produced if unquoted compiler flags are
    provided."""
    # This should fail during parsing, since /usr/include is interpreted as a spec hash.
    with pytest.raises(spack.error.SpackError) as cm:
        # We don't try to figure out how many following args were intended to be part of
        # cflags, we just explain how to fix it for the immediate next arg.
        spec(
            'gcc cflags=-Os -pipe -other-arg-that-gets-ignored cflags=-I /usr/include'
        )
    # Verify that the generated error message is nicely formatted.
    assert str(cm.value) == dedent('''\
    No installed spec matches the hash: 'usr'

    Some compiler or linker flags were provided without quoting their arguments,
    which now causes spack to try to parse the *next* argument as a spec component
    such as a variant instead of an additional compiler or linker flag. If the
    intent was to set multiple flags, try quoting them together as described below.

    Possible flag quotation errors (with the correctly-quoted version after the =>):
    (1) cflags=-Os -pipe => cflags="-Os -pipe"
    (2) cflags=-I /usr/include => cflags="-I /usr/include"''')

    # Verify that the same unquoted cflags report is generated in the error message even
    # if it fails during concretization, not just during parsing.
    with pytest.raises(spack.error.SpackError) as cm:
        spec('gcc cflags=-Os -pipe')
    cm = str(cm.value)
    assert cm.startswith(
        'trying to set variant "pipe" in package "gcc", but the package has no such variant [happened during concretization of gcc cflags="-Os" ~pipe]'
    )  # noqa: E501
    assert cm.endswith('(1) cflags=-Os -pipe => cflags="-Os -pipe"')
示例#3
0
def test_spec_parse_error():
    with pytest.raises(spack.error.SpackError) as e:
        spec("1.15:")

    # make sure the error is formatted properly
    error_msg = """\
    1.15:
        ^"""
    assert error_msg in str(e.value)
示例#4
0
def test_spec_parse_error():
    with pytest.raises(spack.spec.SpecParseError) as e:
        spec("1.15:")

    # make sure the error is formatted properly
    error_msg = """\
    1.15:
        ^"""
    assert error_msg in e.value.long_message
示例#5
0
def test_spec_parse_cflags_quoting():
    """Verify that compiler flags can be provided to a spec from the command line."""
    output = spec('--yaml', 'gcc cflags="-Os -pipe" cxxflags="-flto -Os"')
    gh_flagged = spack.spec.Spec.from_yaml(output)

    assert ['-Os', '-pipe'] == gh_flagged.compiler_flags['cflags']
    assert ['-flto', '-Os'] == gh_flagged.compiler_flags['cxxflags']
示例#6
0
def test_spec_parse_dependency_variant_value():
    """Verify that we can provide multiple key=value variants to multiple separate
    packages within a spec string."""
    output = spec('multivalue-variant fee=barbaz ^ a foobar=baz')

    assert 'fee=barbaz' in output
    assert 'foobar=baz' in output
示例#7
0
文件: spec.py 项目: LLNL/spack
def test_spec_deptypes_edges():
    output = spec('--types', '--cover', 'edges', 'dt-diamond')
    types = _parse_types(output)

    assert types['dt-diamond']        == ['    ']
    assert types['dt-diamond-left']   == ['bl  ']
    assert types['dt-diamond-right']  == ['bl  ']
    assert types['dt-diamond-bottom'] == ['b   ', 'blr ']
示例#8
0
def test_spec_deptypes_edges():
    output = spec('--types', '--cover', 'edges', 'dt-diamond')
    types = _parse_types(output)

    assert types['dt-diamond']        == ['    ']
    assert types['dt-diamond-left']   == ['bl  ']
    assert types['dt-diamond-right']  == ['bl  ']
    assert types['dt-diamond-bottom'] == ['b   ', 'blr ']
示例#9
0
文件: spec.py 项目: LLNL/spack
def test_spec():
    output = spec('mpileaks')

    assert '[email protected]' in output
    assert '[email protected]' in output
    assert '[email protected]' in output
    assert 'libdwarf@20130729' in output
    assert '[email protected]' in output
    assert '[email protected]' in output
示例#10
0
def test_spec():
    output = spec('mpileaks')

    assert '[email protected]' in output
    assert '[email protected]' in output
    assert '[email protected]' in output
    assert 'libdwarf@20130729' in output
    assert '[email protected]' in output
    assert '[email protected]' in output
示例#11
0
def test_spec_json():
    output = spec('--json', 'mpileaks')

    mpileaks = spack.spec.Spec.from_json(output)
    assert 'mpileaks' in mpileaks
    assert 'callpath' in mpileaks
    assert 'dyninst' in mpileaks
    assert 'libdwarf' in mpileaks
    assert 'libelf' in mpileaks
    assert 'mpich' in mpileaks
示例#12
0
文件: spec.py 项目: LLNL/spack
def test_spec_yaml():
    output = spec('--yaml', 'mpileaks')

    mpileaks = spack.spec.Spec.from_yaml(output)
    assert 'mpileaks' in mpileaks
    assert 'callpath' in mpileaks
    assert 'dyninst' in mpileaks
    assert 'libdwarf' in mpileaks
    assert 'libelf' in mpileaks
    assert 'mpich' in mpileaks
示例#13
0
def test_env_aware_spec(mutable_mock_env_path):
    env = ev.create('test')
    env.add('mpileaks')

    with env:
        output = spec()
        assert '[email protected]' in output
        assert '[email protected]' in output
        assert '[email protected]' in output
        assert 'libdwarf@20130729' in output
        assert '[email protected]' in output
        assert '[email protected]' in output
示例#14
0
def test_spec_format(database, config):
    output = spec('--format', '{name}-{^mpi.name}', 'mpileaks^mpich')
    assert output.rstrip('\n') == "mpileaks-mpich"
示例#15
0
文件: spec.py 项目: LLNL/spack
def test_spec_returncode():
    with pytest.raises(spack.main.SpackCommandError):
        spec()
    assert spec.returncode == 1
示例#16
0
文件: spec.py 项目: tfgcmn/spack
def test_spec_singlestring():
    spec('multivalue_variant foo=baz target=x86_64 ^[email protected]')

    assert spec.returncode == 0
示例#17
0
def test_spec_returncode():
    with pytest.raises(SpackCommandError):
        spec()
    assert spec.returncode == 1