Ejemplo n.º 1
0
 def _generic_library(self, directory: str, **kwargs) -> Path:
     t = templates.TemplateGroup(_TEMPLATES_DIR / directory)
     result = t.render(**kwargs)
     _tracked_paths.add(result)
     metadata.add_template_source(name=directory,
                                  origin="synthtool.gcp",
                                  version=__main__.VERSION)
     return result
Ejemplo n.º 2
0
def test_add_template_source():
    metadata.reset()

    metadata.add_template_source(name="name", version="1.2.3")

    current = metadata.get()

    assert current.sources[0].template.name == "name"
    assert current.sources[0].template.version == "1.2.3"
Ejemplo n.º 3
0
    def _generic_library(self, directory: str, **kwargs) -> Path:
        # load common repo meta information (metadata that's not language specific).
        if "metadata" in kwargs:
            self._load_generic_metadata(kwargs["metadata"])
            # if no samples were found, don't attempt to render a
            # samples/README.md.
            if not kwargs["metadata"]["samples"]:
                self.excludes.append("samples/README.md")

        t = templates.TemplateGroup(_TEMPLATES_DIR / directory, self.excludes)
        result = t.render(**kwargs)
        _tracked_paths.add(result)
        metadata.add_template_source(name=directory,
                                     origin="synthtool.gcp",
                                     version=__main__.VERSION)
        return result
Ejemplo n.º 4
0
def test_git_sources_are_sorted(source_tree: SourceTree):
    metadata_path = source_tree.tmpdir / "synth.metadata"
    with metadata.MetadataTrackerAndWriter(metadata_path):
        metadata.add_generator_source(name="a-generator",
                                      version="1",
                                      docker_image="x")
        metadata.add_generator_source(name="b-generator",
                                      version="2",
                                      docker_image="y")
        metadata.add_template_source(name="a-template",
                                     origin="andromeda",
                                     version="3")
        metadata.add_template_source(name="b-template",
                                     origin="milky way",
                                     version="4")
        metadata.add_git_source(name="a-git", sha="1a")
        metadata.add_git_source(name="b-git", sha="1b")
    m1 = metadata._read_or_empty(metadata_path)
    # Add the same sources in reverse order.
    metadata.reset()
    with metadata.MetadataTrackerAndWriter(metadata_path):
        metadata.add_git_source(name="b-git", sha="1b")
        metadata.add_git_source(name="a-git", sha="1a")
        metadata.add_template_source(name="b-template",
                                     origin="milky way",
                                     version="4")
        metadata.add_template_source(name="a-template",
                                     origin="andromeda",
                                     version="3")
        metadata.add_generator_source(name="b-generator",
                                      version="2",
                                      docker_image="y")
        metadata.add_generator_source(name="a-generator",
                                      version="1",
                                      docker_image="x")
    m2 = metadata._read_or_empty(metadata_path)
    assert m1.sources == m2.sources