Exemple #1
0
def load_yaml_reader(reader):
    documents = yaml.safe_load_all(reader)
    list_of_artifacts = []
    for data in documents:
        requirements = data['requires']

        if isinstance(requirements, list):
            for artifact_description in requirements:
                artifact = artifacts.Artifact(artifact_description)
                if artifact not in list_of_artifacts:
                    list_of_artifacts.append(artifact)

        if isinstance(requirements, dict):
            if 'stable' in requirements.keys():
                for artifact_description in requirements['stable']:
                    artifact = artifacts.Artifact(artifact_description,
                                                  build_type='stable')
                    if artifact not in list_of_artifacts:
                        list_of_artifacts.append(artifact)
            if 'snapshot' in requirements.keys():
                for artifact_description in requirements['snapshot']:
                    artifact = artifacts.Artifact(artifact_description,
                                                  build_type='snapshot')
                    if artifact not in list_of_artifacts:
                        list_of_artifacts.append(artifact)

    return list_of_artifacts
Exemple #2
0
 def test_install_package(self):
     self.test_copy_stable_package()
     artifacts.install_package(
         artifacts.Artifact('cpp-pthread-Darwin-1.11.0'), 'x86',
         self.workspace)
     artifacts.install_package(
         artifacts.Artifact('cpp-pthread-Darwin-1.11.0'), 'x86',
         self.workspace)
     artifacts.install_package(
         artifacts.Artifact('cpp-pthread-Darwin-1.11.0'), 'x86',
         self.workspace)
    def test_description_string(self):

        artefact = artifacts.Artifact('common', version='2.2.1', os='qnx', description='very clever...')
        self.assertEqual("common / 2.2.1 (os: qnx, build type: snapshot): very clever...",
                         artefact.desc(),
                         msg="description string is not what we expected")

        artefact = artifacts.Artifact('artefact-name-qnx-1.2.3-SNAPSHOT', description='very clever snapshot version...')
        self.assertEqual("artefact-name / 1.2.3 (os: qnx, build type: snapshot): very clever snapshot version...",
                         artefact.desc(),
                         msg="description string is not what we expected")
    def test_explicit_artifact_init(self):

        artefact = artifacts.Artifact('one', version='2.2.1', os='qnx', description='very clever...')
        self.assertEqual(artefact.__str__(),
                         "one-qnx-2.2.1-snapshot")

        artefact = artifacts.Artifact('two', version='2.2.1', build_type='stable', os='qnx', description='very clever...')
        self.assertEqual(artefact,
                         "two-qnx-2.2.1")

        with self.assertRaises(Exception, msg="Wouaw is not a valid build type value"):
            artefact = artifacts.Artifact('two', version='2.2.1', build_type='Wouaw', os='qnx', description='very clever...')
    def parse_description_string(self, description_string):

        assert description_string.endswith(
            ".tar.gz"
        ), "package description '{}' doesn't end with '{}'.".format(
            description_string, self.type())

        description_string = re.sub("{}$".format(re.escape(self.type())), '',
                                    description_string)

        seperator = '-'
        tokens = description_string.split(seperator)
        number_of_tokens = len(tokens)
        last_token = number_of_tokens - 1

        arch_position = 0
        for token in tokens:
            if token in KNOWN_ARCHS:
                self.target_arch(token)
                break

            arch_position += 1

        tokens = tokens[0:arch_position]
        self.artifact = artifacts.Artifact('-'.join(tokens))
    def test_packaging_archive_digest(self):
        package = artifacts.Package(artifacts.Artifact('common-qnx-1.2.3'), 'x86')
        self.assertEqual(package.archive_digest(),
                         "common-qnx-1.2.3-x86.tar.gz.md5",
                         msg="wrong packaging archive digest name for artefact '{}'".format(package))

        package.target_arch('armv7')
        self.assertEqual(package.archive_digest(),
                         "common-qnx-1.2.3-armv7.tar.gz.md5",
                         msg="wrong packaging archive digest name for artefact '{}'".format(package))
    def test_packaging_archive(self):
        package = artifacts.Package(artifacts.Artifact('common-qnx-1.2.3'), 'x86')
        self.assertEqual(package.archive(),
                         "common-qnx-1.2.3-x86.tar.gz",
                         msg="wrong packaging archive name for package \n{}".format(package))

        package.target_arch('armv7')
        self.assertEqual(package.archive(),
                         "common-qnx-1.2.3-armv7.tar.gz",
                         msg="wrong packaging archive name for package \n{}".format(package))
    def test_parse_artifact_description_string_init(self):
        artifact = artifacts.Artifact('one-1.2.3')
        self.assertEqual("one-1.2.3",
                         artifact.id(),
                         msg="pattern 'one-1.2.3' init failed")

        artifact = artifacts.Artifact('two-qnx-1.2.3')
        self.assertEqual(artifact,
                         "two-qnx-1.2.3",
                         msg="pattern 'two-qnx-1.2.3' init failed")

        artifact = artifacts.Artifact('three-1.2.3-snapshot')
        self.assertEqual(artifact,
                         "three-1.2.3-snapshot",
                         msg="pattern 'three-1.2.3-snapshot' init failed")

        artifact = artifacts.Artifact('five-qnx-1.2.3-SNAPSHOT')
        self.assertEqual(artifact,
                         "five-qnx-1.2.3-snapshot",
                         msg="pattern 'five-qnx-1.2.3-SNAPSHOT' init failed")

        with self.assertRaises(Exception, msg="pattern 'six-qnx-1.2.3-Wouaw' should not be accpeted"):
            artifacts.Artifact('six-qnx-1.2.3-Wouaw')

        artifact = artifacts.Artifact('seven-qnx-1.2.3', build_type='stable')
        self.assertEqual(artifact,
                         "seven-qnx-1.2.3",
                         msg="pattern 'seven-1.2.3-snapshot' plus attribute build_type='stable' init failed")
Exemple #9
0
def load_plain_text_reader(reader):
    list_of_artifacts = []
    for artifact in reader.readlines():
        list_of_artifacts.append(artifacts.Artifact(artifact.strip(' ')))

    return list_of_artifacts