Ejemplo n.º 1
0
def run(args, project_options):  # noqa
    lifecycle_command = _get_lifecycle_command(args)
    argless_command = _get_command_from_arg(args)
    if lifecycle_command:
        lifecycle.execute(
            lifecycle_command, project_options, args['<part>'])
    elif argless_command:
        argless_command()
    elif args['clean']:
        _run_clean(args, project_options)
    elif args['cleanbuild']:
        lifecycle.cleanbuild(project_options),
    elif _is_store_command(args):
        _run_store_command(args)
    elif args['tour']:
        _scaffold_examples(args['<directory>'] or _SNAPCRAFT_TOUR_DIR)
    elif args['help']:
        snapcraft.topic_help(args['<topic>'] or args['<plugin>'],
                             args['--devel'], args['topics'])
    elif args['update']:
        parts.update()
    elif args['define']:
        parts.define(args['<part-name>'])
    elif args['search']:
        parts.search(' '.join(args['<query>']))
    else:  # snap by default:
        lifecycle.snap(project_options, args['<directory>'], args['--output'])

    return project_options
Ejemplo n.º 2
0
    def test_config_composes_with_remote_parts(self, mock_loadPlugin):
        self.make_snapcraft_yaml("""name: test
version: "1"
summary: test
description: test
confinement: strict

parts:
  part1:
    stage-packages: [fswebcam]
""")

        parts.update()
        internal_yaml.Config()

        mock_loadPlugin.assert_called_with('part1', 'go', {
            'source': 'http://source.tar.gz', 'stage-packages': ['fswebcam'],
            'stage': [], 'snap': []})
Ejemplo n.º 3
0
    def test_config_composes_with_a_non_existent_remote_part(self):
        self.make_snapcraft_yaml("""name: test
version: "1"
summary: test
description: test
confinement: strict

parts:
  non-existing-part:
    stage-packages: [fswebcam]
""")

        parts.update()

        with self.assertRaises(internal_yaml.SnapcraftLogicError) as raised:
            internal_yaml.Config()
        self.assertEqual(
            str(raised.exception),
            '{!r} is missing the `plugin` entry and is not defined in the '
            'current remote parts cache, try to run `snapcraft update` '
            'to refresh'.format('non-existing-part'))
Ejemplo n.º 4
0
    def test_config_uses_remote_part_from_after(self, mock_load):
        self.useFixture(fixture_setup.FakeParts())

        self.make_snapcraft_yaml("""name: test
version: "1"
summary: test
description: test
confinement: strict

parts:
  part1:
    after:
      - curl
    plugin: go
    stage-packages: [fswebcam]
""")

        def load_effect(*args, **kwargs):
            mock_part = unittest.mock.Mock()
            mock_part.code.build_packages = []
            mock_part.deps = []
            mock_part.name = args[0]

            return mock_part

        mock_load.side_effect = load_effect

        project_options = snapcraft.ProjectOptions()

        parts.update()
        internal_yaml.Config(project_options)

        call1 = unittest.mock.call('part1', 'go', {
            'stage': [], 'snap': [], 'stage-packages': ['fswebcam']},
            project_options, self.part_schema)
        call2 = unittest.mock.call('curl', 'autotools', {
            'source': 'http://curl.org'},
            project_options, self.part_schema)

        mock_load.assert_has_calls([call1, call2])
Ejemplo n.º 5
0
    def test_config_after_is_an_undefined_part(self):
        self.make_snapcraft_yaml("""name: test
version: "1"
summary: test
description: test
confinement: strict

parts:
  part1:
    plugin: nil
    after: [non-existing-part]
""")

        parts.update()

        with self.assertRaises(internal_yaml.SnapcraftLogicError) as raised:
            internal_yaml.Config()
        self.assertEqual(
            str(raised.exception),
            'Cannot find definition for part {!r}. It may be a '
            'remote part, run `snapcraft update` to '
            'refresh the remote parts cache'.format('non-existing-part'))