コード例 #1
0
ファイル: spec_syntax.py プロジェクト: t-brown/spack
    def test_parse_yaml_relative_paths(self, mock_packages, tmpdir):
        s = Spec('libdwarf')
        s.concretize()

        specfile = tmpdir.join('libdwarf.yaml')

        with specfile.open('w') as f:
            f.write(s.to_yaml(hash=ht.dag_hash))

        file_name = specfile.basename
        parent_dir = os.path.basename(specfile.dirname)

        # Relative path to specfile
        with fs.working_dir(specfile.dirname):
            # Test for command like: "spack spec libelf.yaml"
            # This should parse a single spec, but should not concretize.
            # See test_parse_filename_missing_slash_as_spec()
            specs = sp.parse('{0}'.format(file_name))
            assert len(specs) == 1

            # Make sure this also works: "spack spec ./libelf.yaml"
            specs = sp.parse('./{0}'.format(file_name))
            assert len(specs) == 1

            # Should also be accepted: "spack spec ../<cur-dir>/libelf.yaml"
            specs = sp.parse('../{0}/{1}'.format(parent_dir, file_name))
            assert len(specs) == 1

            # Should also handle mixed clispecs and relative paths, e.g.:
            #     "spack spec mvapich_foo ../<cur-dir>/libelf.yaml"
            specs = sp.parse('mvapich_foo ../{0}/{1}'.format(
                parent_dir, file_name))
            assert len(specs) == 2
コード例 #2
0
ファイル: spec_syntax.py プロジェクト: matz-e/spack
    def test_multiple_specs_with_hash(self, database):
        mpileaks_zmpi = database.query_one('mpileaks ^zmpi')
        callpath_mpich2 = database.query_one('callpath ^mpich2')

        # name + hash + separate hash
        specs = sp.parse('mpileaks /' + mpileaks_zmpi.dag_hash() + '/' +
                         callpath_mpich2.dag_hash())
        assert len(specs) == 2

        # 2 separate hashes
        specs = sp.parse('/' + mpileaks_zmpi.dag_hash() + '/' +
                         callpath_mpich2.dag_hash())
        assert len(specs) == 2

        # 2 separate hashes + name
        specs = sp.parse('/' + mpileaks_zmpi.dag_hash() + '/' +
                         callpath_mpich2.dag_hash() + ' callpath')
        assert len(specs) == 3

        # hash + 2 names
        specs = sp.parse('/' + mpileaks_zmpi.dag_hash() + ' callpath' +
                         ' callpath')
        assert len(specs) == 3

        # hash + name + hash
        specs = sp.parse('/' + mpileaks_zmpi.dag_hash() + ' callpath' + ' / ' +
                         callpath_mpich2.dag_hash())
        assert len(specs) == 2
コード例 #3
0
ファイル: spec_syntax.py プロジェクト: t-brown/spack
    def test_parse_yaml_dependency_relative_paths(self, mock_packages, tmpdir):
        s = Spec('libdwarf')
        s.concretize()

        specfile = tmpdir.join('libelf.yaml')

        with specfile.open('w') as f:
            f.write(s['libelf'].to_yaml(hash=ht.dag_hash))

        file_name = specfile.basename
        parent_dir = os.path.basename(specfile.dirname)

        # Relative path to specfile
        with fs.working_dir(specfile.dirname):
            # Test for command like: "spack spec libelf.yaml"
            specs = sp.parse('libdwarf^{0}'.format(file_name))
            assert len(specs) == 1

            # Make sure this also works: "spack spec ./libelf.yaml"
            specs = sp.parse('libdwarf^./{0}'.format(file_name))
            assert len(specs) == 1

            # Should also be accepted: "spack spec ../<cur-dir>/libelf.yaml"
            specs = sp.parse('libdwarf^../{0}/{1}'.format(
                parent_dir, file_name))
            assert len(specs) == 1
コード例 #4
0
ファイル: spec_syntax.py プロジェクト: t-brown/spack
    def test_parse_yaml_variant_error(self, mock_packages, tmpdir):
        s = Spec('a')
        s.concretize()

        specfile = tmpdir.join('a.yaml')

        with specfile.open('w') as f:
            f.write(s.to_yaml(hash=ht.dag_hash))

        with pytest.raises(RedundantSpecError):
            # Trying to change a variant on a concrete spec is an error
            sp.parse('{0} ~bvv'.format(specfile.strpath))
コード例 #5
0
ファイル: spec_syntax.py プロジェクト: matz-e/spack
def test_parse_anonymous_specs(spec, anon_spec, spec_name):

    expected = parse(spec)
    spec = parse_anonymous_spec(anon_spec, spec_name)

    assert len(expected) == 1
    assert spec in expected
コード例 #6
0
ファイル: spec_syntax.py プロジェクト: t-brown/spack
    def test_parse_yaml_simple(self, mock_packages, tmpdir):
        s = Spec('libdwarf')
        s.concretize()

        specfile = tmpdir.join('libdwarf.yaml')

        with specfile.open('w') as f:
            f.write(s.to_yaml(hash=ht.dag_hash))

        # Check an absolute path to spec.yaml by itself:
        #     "spack spec /path/to/libdwarf.yaml"
        specs = sp.parse(specfile.strpath)
        assert len(specs) == 1

        # Check absolute path to spec.yaml mixed with a clispec, e.g.:
        #     "spack spec mvapich_foo /path/to/libdwarf.yaml"
        specs = sp.parse('mvapich_foo {0}'.format(specfile.strpath))
        assert len(specs) == 2
コード例 #7
0
ファイル: spec_syntax.py プロジェクト: t-brown/spack
    def test_parse_yaml_dependency(self, mock_packages, tmpdir):
        s = Spec('libdwarf')
        s.concretize()

        specfile = tmpdir.join('libelf.yaml')

        with specfile.open('w') as f:
            f.write(s['libelf'].to_yaml(hash=ht.dag_hash))

        # Make sure we can use yaml path as dependency, e.g.:
        #     "spack spec libdwarf ^ /path/to/libelf.yaml"
        specs = sp.parse('libdwarf ^ {0}'.format(specfile.strpath))
        assert len(specs) == 1
コード例 #8
0
ファイル: spec_syntax.py プロジェクト: t-brown/spack
    def test_parse_yaml_relative_subdir_path(self, mock_packages, tmpdir):
        s = Spec('libdwarf')
        s.concretize()

        specfile = tmpdir.mkdir('subdir').join('libdwarf.yaml')

        with specfile.open('w') as f:
            f.write(s.to_yaml(hash=ht.dag_hash))

        file_name = specfile.basename

        # Relative path to specfile
        with tmpdir.as_cwd():
            assert os.path.exists('subdir/{0}'.format(file_name))

            # Test for command like: "spack spec libelf.yaml"
            specs = sp.parse('subdir/{0}'.format(file_name))
            assert len(specs) == 1
コード例 #9
0
ファイル: spec_syntax.py プロジェクト: matz-e/spack
    def check_parse(self, expected, spec=None):
        """Assert that the provided spec is able to be parsed.

           If this is called with one argument, it assumes that the
           string is canonical (i.e., no spaces and ~ instead of - for
           variants) and that it will convert back to the string it came
           from.

           If this is called with two arguments, the first argument is
           the expected canonical form and the second is a non-canonical
           input to be parsed.

        """
        if spec is None:
            spec = expected
        output = sp.parse(spec)

        parsed = (" ".join(str(spec) for spec in output))
        assert expected == parsed
コード例 #10
0
ファイル: spec_syntax.py プロジェクト: alfredo-gimenez/spack
    def check_parse(self, expected, spec=None, remove_arch=True):
        """Assert that the provided spec is able to be parsed.

           If this is called with one argument, it assumes that the
           string is canonical (i.e., no spaces and ~ instead of - for
           variants) and that it will convert back to the string it came
           from.

           If this is called with two arguments, the first argument is
           the expected canonical form and the second is a non-canonical
           input to be parsed.

        """
        if spec is None:
            spec = expected
        output = sp.parse(spec)

        parsed = (" ".join(str(spec) for spec in output))
        assert expected == parsed
コード例 #11
0
    def test_parse_filename_missing_slash_as_spec(self, mock_packages, tmpdir):
        """Ensure that libelf.yaml parses as a spec, NOT a file."""
        s = Spec('libelf')
        s.concretize()

        specfile = tmpdir.join('libelf.yaml')

        # write the file to the current directory to make sure it exists,
        # and that we still do not parse the spec as a file.
        with specfile.open('w') as f:
            f.write(s.to_yaml(hash=ht.build_hash))

        # Check the spec `libelf.yaml` in the working directory, which
        # should evaluate to a spec called `yaml` in the `libelf`
        # namespace, NOT a spec for `libelf`.
        with tmpdir.as_cwd():
            specs = sp.parse("libelf.yaml")
        assert len(specs) == 1

        spec = specs[0]
        assert spec.name == "yaml"
        assert spec.namespace == "libelf"
        assert spec.fullname == "libelf.yaml"

        # check that if we concretize this spec, we get a good error
        # message that mentions we might've meant a file.
        with pytest.raises(spack.repo.UnknownPackageError) as exc_info:
            spec.concretize()
        assert exc_info.value.long_message
        assert ("Did you mean to specify a filename with './libelf.yaml'?"
                in exc_info.value.long_message)

        # make sure that only happens when the spec ends in yaml
        with pytest.raises(spack.repo.UnknownPackageError) as exc_info:
            Spec('builtin.mock.doesnotexist').concretize()
        assert (
            not exc_info.value.long_message or (
                "Did you mean to specify a filename with" not in
                exc_info.value.long_message
            )
        )