def test_dependencies_not_changed(self):
     package_1_desc = PackageDescriptor('fake/path')
     package_1_desc.name = 'baz'
     package_1_desc.dependencies['run'] = ['foo']
     package_1_desc.dependencies['test'] = ['bar']
     package_1 = PackageDecorator(package_1_desc)
     decorators = [package_1]
     self.assertTrue(
         package_dependencies_changed(self.path_context, decorators))
     update_dependencies_cache(self.path_context)
     self.assertFalse(
         package_dependencies_changed(self.path_context, decorators))
 def test_dependencies_changed(self):
     package_1_desc = PackageDescriptor('fake/path')
     package_1_desc.name = 'package1'
     package_1_desc.dependencies['run'] = [DependencyDescriptor('foo')]
     package_1 = PackageDecorator(package_1_desc)
     decorators = [package_1]
     self.assertTrue(
         package_dependencies_changed(self.path_context, decorators))
     update_dependencies_cache(self.path_context)
     package_1_desc.dependencies['run'] = [
         DependencyDescriptor('foo'), 'baz'
     ]
     package_1 = PackageDecorator(package_1_desc)
     decorators = [package_1]
     self.assertTrue(
         package_dependencies_changed(self.path_context, decorators))
Пример #3
0
    def _manage_dependencies(self, context,
                             path_context,
                             upgrade_deps_graph):
        destinations = self.task_argument_destinations
        decorators = get_packages(context.args,
                                  additional_argument_names=destinations,
                                  recursive_categories=('run',))
        if len(decorators) == 0:
            estr = 'We did not find any packages to add to the '\
                   'bundle. This might be because you are not '\
                   'in the right directory, or your workspace is '\
                   'not setup correctly for colcon. Please see '\
                   'https://github.com/colcon/colcon-ros-bundle/issues/13' \
                   'for some possible suggestions. If you are still having ' \
                   'trouble please post to our' \
                   'issues: https://github.com/colcon/colcon-bundle/issues '\
                   'and we will be happy to help.'
            raise RuntimeError(estr)

        self._installer_manager.setup_installers(context)

        print('Checking if dependency tarball exists...')
        logger.info('Checking if dependency tarball exists...')

        jobs = self._get_jobs(context.args,
                              self._installer_manager.installers,
                              decorators)
        rc = execute_jobs(context, jobs)
        if rc != 0:
            return rc

        direct_dependencies_changed = package_dependencies_changed(
            path_context, decorators)
        installer_parameters_changed = \
            self._installer_manager.cache_invalid()

        if not os.path.exists(path_context.dependencies_overlay_path()):
            self._installer_manager.run_installers(
                include_sources=context.args.include_sources)
            return True
        elif upgrade_deps_graph:
            print('Checking if dependency graph has changed since last '
                  'bundle...')
            logger.info('Checking if dependency graph has changed since last'
                        ' bundle...')
            if self._installer_manager.run_installers(
                    include_sources=context.args.include_sources):
                print('All dependencies in dependency graph not changed, '
                      'skipping dependencies update...')
                logger.info('All dependencies in dependency graph not changed,'
                            ' skipping dependencies update...')
                return False
        else:
            print('Checking if local dependencies have changed since last'
                  ' bundle...')
            logger.info(
                'Checking if local dependencies have changed since last'
                ' bundle...')
            if not direct_dependencies_changed and \
                    not installer_parameters_changed:
                print('Local dependencies not changed, skipping dependencies'
                      ' update...')
                logger.info(
                    'Local dependencies not changed, skipping dependencies'
                    ' update...')
                return False
            self._installer_manager.run_installers(
                include_sources=context.args.include_sources)
        return True