Esempio n. 1
0
    def test_merge_target_data(self, d):
        os.chdir(d.path)

        # create project
        project = Project()
        project.config['name'] = Constants.PROJECT_NAME

        # create dependency
        dep_repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/dep-repository-test',
            rep_version='1.0.0',
        )

        dependency = Dependency(name='repository-test',
                                repository=dep_repository)

        project.dependencies = [dependency]

        # create target
        target_repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/target-repository-test',
            rep_version='1.0.0',
        )

        target1 = Target(name='test', repository=target_repository)

        target2 = Target(name='test', repository=target_repository)

        project.targets = [target1, target2]

        # process data
        process_data = ProcessData()
        process_data.reset()
        process_data.project_name = project.get_config_value('name')

        # process target data
        for target in project.targets:
            # get all target data from project dependencies
            print('Who is the target:')
            print(target.get_name())
            print("")

            target_data = TargetData()

            for dependency in project.dependencies:
                print('Who is the dependency:')
                print(dependency.get_name())
                print("")

                dependency.prepare_from_process_data(process_data)

                new_target_data = TargetData()
                new_target_data.c_flags.extend(['flag'])
                target_data.merge(new_target_data)

            self.assertEqual(len(target_data.c_flags), 1)
Esempio n. 2
0
    def test_get_name(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_ZIP,
            rep_path='http://ezored.com/downloads/dependency-sample.zip',
            rep_version='')

        self.assertEqual(repository.get_name(), 'dependency-sample')
Esempio n. 3
0
    def test_match_target_name_and_target_data(self):
        # create dependency
        dep_repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='dep-repository-test',
            rep_version='1.0.0',
        )

        dependency = Dependency(name='repository-test',
                                repository=dep_repository)

        # check match
        match = dependency.match_name('test1-test2', 'test1-test2')
        self.assertEqual(match, True)

        match = dependency.match_name('test', 'test1-test2')
        self.assertEqual(match, True)

        match = dependency.match_name('test1', 'test1-test2')
        self.assertEqual(match, True)

        match = dependency.match_name('test2', 'test1-test2')
        self.assertEqual(match, True)

        match = dependency.match_name('-', 'test1-test2')
        self.assertEqual(match, True)

        match = dependency.match_name('arm', 'armv7-linux')
        self.assertEqual(match, True)

        match = dependency.match_name('linux', 'armv7-linux')
        self.assertEqual(match, True)
Esempio n. 4
0
    def test_git_get_name(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_GIT,
            rep_path='https://github.com/ezored/dependency-sample.git',
            rep_version='t:1.0.0',
        )

        self.assertEqual(repository.get_name(), 'dependency-sample')
Esempio n. 5
0
    def test_local_get_name(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/repository-test',
            rep_version='1.0.0',
        )

        self.assertEqual(repository.get_name(), 'repository-test')
Esempio n. 6
0
    def test_github_get_name(self):
        repository = Repository(
            rep_type=Repository.TYPE_GITHUB,
            rep_name='ezored/dependency-sample',
            rep_version='b:master',
        )

        self.assertEqual(repository.get_name(), 'ezored-dependency-sample')
Esempio n. 7
0
    def test_local_get_name(self):
        repository = Repository(
            rep_type=Repository.TYPE_LOCAL,
            rep_name='/tmp/repository-test',
            rep_version='1.0.0',
        )

        self.assertEqual(repository.get_name(), 'repository-test')
Esempio n. 8
0
    def test_local_get_name_with_null_name(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/repository-test',
            rep_version='1.0.0',
        )

        dependency = Dependency(name=None, repository=repository)

        self.assertEqual(dependency.get_name(), None)
Esempio n. 9
0
    def test_local_get_name_with_different_name_from_repository(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/repository-test',
            rep_version='1.0.0',
        )

        target = Target(name='repository-test-diff', repository=repository)

        self.assertEqual(target.get_name(), 'repository-test-diff')
Esempio n. 10
0
    def test_local_get_name_with_null_name(self):
        repository = Repository(
            rep_type=Repository.TYPE_LOCAL,
            rep_name='/tmp/repository-test',
            rep_version='1.0.0',
        )

        target = Target(name=None, repository=repository)

        self.assertEqual(target.get_name(), 'repository-test')
Esempio n. 11
0
    def test_constructor(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/repository-test',
            rep_version='1.0.0',
        )

        self.assertEqual(repository.rep_type, Constants.REPOSITORY_TYPE_LOCAL)
        self.assertEqual(repository.rep_path, '/tmp/repository-test')
        self.assertEqual(repository.rep_version, '1.0.0')
Esempio n. 12
0
    def test_local_get_name_with_null_name(self):
        repository = Repository(
            rep_type=Repository.TYPE_LOCAL,
            rep_name='/tmp/repository-test',
            rep_version='1.0.0',
        )

        dependency = Dependency(repository=repository)

        self.assertEqual(dependency.get_name(), 'repository-test')
Esempio n. 13
0
    def test_constructor(self):
        repository = Repository(
            rep_type=Repository.TYPE_LOCAL,
            rep_name='/tmp/repository-test',
            rep_version='1.0.0',
        )

        self.assertEqual(repository.rep_type, Repository.TYPE_LOCAL)
        self.assertEqual(repository.rep_name, '/tmp/repository-test')
        self.assertEqual(repository.rep_version, '1.0.0')
Esempio n. 14
0
    def test_constructor(self):
        repository = Repository(
            rep_type=Repository.TYPE_LOCAL,
            rep_name='/tmp/repository-test',
            rep_version='1.0.0',
        )

        target = Target(name='repository-test', repository=repository)

        self.assertEqual(target.get_name(), 'repository-test')
        self.assertEqual(target.repository.rep_type, Repository.TYPE_LOCAL)
        self.assertEqual(target.repository.rep_name, '/tmp/repository-test')
        self.assertEqual(target.repository.rep_version, '1.0.0')
Esempio n. 15
0
    def test_constructor(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/repository-test',
            rep_version='1.0.0',
        )

        target = Target(name='repository-test', repository=repository)

        self.assertEqual(target.get_name(), 'repository-test')
        self.assertEqual(target.repository.rep_type,
                         Constants.REPOSITORY_TYPE_LOCAL)
        self.assertEqual(target.repository.rep_path, '/tmp/repository-test')
        self.assertEqual(target.repository.rep_version, '1.0.0')
Esempio n. 16
0
    def test_constructor(self):
        repository = Repository(
            rep_type=Repository.TYPE_LOCAL,
            rep_name='/tmp/repository-test',
            rep_version='1.0.0',
        )

        dependency = Dependency(repository=repository)

        self.assertEqual(dependency.get_name(), 'repository-test')
        self.assertEqual(dependency.repository.rep_type, Repository.TYPE_LOCAL)
        self.assertEqual(dependency.repository.rep_name,
                         '/tmp/repository-test')
        self.assertEqual(dependency.repository.rep_version, '1.0.0')