Example #1
0
    def test_generate_hook_wrappers(self):
        # Set up the prime directory to contain a few hooks in snap/hooks
        snap_hooks_dir = os.path.join(self.prime_dir, "snap", "hooks")
        hook1_path = os.path.join(snap_hooks_dir, "test-hook1")
        hook2_path = os.path.join(snap_hooks_dir, "test-hook2")

        for path in (hook1_path, hook2_path):
            _create_file(path, executable=True)

        # Now generate hook wrappers, and verify that they're correct
        self.generate_meta_yaml()
        for hook in ("test-hook1", "test-hook2"):
            hook_path = os.path.join(self.hooks_dir, hook)
            self.assertThat(hook_path, FileExists())
            self.assertThat(hook_path, unit.IsExecutable())

            # The hook in meta/hooks should exec the one in snap/hooks, as it's
            # a wrapper generated by snapcraft.
            self.assertThat(
                hook_path,
                FileContains(
                    matcher=Contains('exec "$SNAP/snap/hooks/{}"'.format(hook))
                ),
            )
Example #2
0
    def test_sign_build_locally_successfully(
        self,
        mock_installed,
        mock_get_snap_data,
        mock_check_output,
        mock_get_account_info,
    ):
        mock_installed.return_value = True
        mock_get_account_info.return_value = {
            "account_id": "abcd",
            "snaps": {"16": {"test-snap": {"snap-id": "snap-id"}}},
        }
        mock_get_snap_data.return_value = {"name": "test-snap", "grade": "stable"}
        mock_check_output.side_effect = ['[{"name": "default"}]', b"Mocked assertion"]

        result = self.run_command(["sign-build", self.snap_test.snap_path, "--local"])

        self.assertThat(result.exit_code, Equals(0))
        snap_build_path = self.snap_test.snap_path + "-build"
        self.assertThat(
            result.output,
            Contains("Build assertion {} saved to disk.".format(snap_build_path)),
        )
        self.assertThat(snap_build_path, FileExists())
        mock_check_output.assert_called_with(
            [
                "snap",
                "sign-build",
                "--developer-id=abcd",
                "--snap-id=snap-id",
                "--grade=stable",
                "-k",
                "default",
                self.snap_test.snap_path,
            ]
        )
Example #3
0
    def test_origin(self):
        # We stage libc6 for this to work on non xenial
        snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
        snapcraft_yaml.update_part("test-part", {
            "plugin": "nil",
            "stage-packages": ["libc6", "python3"]
        })
        self.useFixture(snapcraft_yaml)

        self.run_snapcraft("prime")

        bin_path = os.path.join(self.prime_dir, "usr", "bin", "python3")
        self.assertThat(bin_path, FileExists())

        # Verify there aren't any duplicate rpath entries
        rpath = (subprocess.check_output(
            [self.patchelf_command, "--print-rpath",
             bin_path]).decode().strip())
        seen = set()
        for i in rpath.split(":"):
            self.assertThat(
                seen, Annotate("A duplicate rpath was found!",
                               Not(Contains(i))))
            seen.add(i)
Example #4
0
    def test_push_without_snap_must_raise_exception(self):
        result = self.run_command(['push'])

        self.assertThat(result.exit_code, Equals(2))
        self.assertThat(result.output, Contains('Usage:'))
Example #5
0
            def __eq__(self, args):
                command = " ".join(args)
                if "debug" in build_attributes:
                    self.test.assertThat(
                        command,
                        MatchesRegex(
                            ".*--cmake-args.*-DCMAKE_BUILD_TYPE=Debug"),
                    )
                else:
                    self.test.assertThat(
                        command,
                        MatchesRegex(
                            ".*--cmake-args.*-DCMAKE_BUILD_TYPE=Release"),
                    )

                if colcon_cmake_args:
                    expected_args = " ".join(colcon_cmake_args)
                    self.test.assertThat(
                        command,
                        MatchesRegex(".*--cmake-args.*{}".format(
                            re.escape(expected_args))),
                    )
                if disable_parallel:
                    self.test.assertThat(
                        command, MatchesRegex(".*--parallel-workers=1"))
                else:
                    self.test.assertThat(
                        command,
                        MatchesRegex(".*--parallel-workers={}".format(
                            plugin.parallel_build_count)),
                    )
                if colcon_catkin_cmake_args:
                    expected_args = " ".join(colcon_catkin_cmake_args)
                    self.test.assertThat(
                        command,
                        MatchesRegex(".*--catkin-cmake-args.*{}".format(
                            re.escape(expected_args))),
                    )
                if colcon_ament_cmake_args:
                    expected_args = " ".join(colcon_ament_cmake_args)
                    self.test.assertThat(
                        command,
                        MatchesRegex(".*--ament-cmake-args.*{}".format(
                            re.escape(expected_args))),
                    )

                if self.test.colcon_packages:
                    self.test.assertThat(
                        command,
                        Contains("--packages-select {}".format(" ".join(
                            self.test.colcon_packages))),
                    )
                else:
                    self.test.assertThat(command,
                                         Not(Contains("--packages-select")))

                self.test.assertThat(args[0:2], Equals(["colcon", "build"]))
                self.test.assertThat(command, Contains("--merge-install"))
                self.test.assertThat(
                    command,
                    Contains("--build-base {}".format(plugin.builddir)))
                self.test.assertThat(
                    command,
                    Contains("--base-paths {}".format(
                        plugin._ros_package_path)),
                )
                self.test.assertThat(
                    command,
                    Contains("--install-base {}".format(plugin._ros_overlay)))

                return True
Example #6
0
    def test_without_snap_must_raise_exception(self):
        result = self.run_command(["push-metadata"])

        self.assertThat(result.exit_code, Equals(2))
        self.assertThat(result.output, Contains("Usage:"))
Example #7
0
    def test_release_without_snap_name_must_raise_exception(self):
        result = self.run_command(["release"])

        self.assertThat(result.exit_code, Equals(2))
        self.assertThat(result.output, Contains("Usage:"))
Example #8
0
    def test_status_without_snap_raises_exception(self):
        result = self.run_command(["status"])

        self.assertThat(result.exit_code, Equals(2))
        self.assertThat(result.output, Contains("Usage:"))
Example #9
0
 def test_prime_invalid_part_no_traceback_without_debug(self):
     self.assertThat(
         self._prime_invalid_part(False), Not(Contains("Traceback")))
Example #10
0
 def test__dumps_json_to_stdout(self):
     stdio = call_get(**{self.option: True, "dump": config.dump_json})
     settings = json.loads(stdio.getOutput())
     self.assertThat(settings, Contains(self.option))
Example #11
0
 def test__dumps_yaml_to_stdout(self):
     stdio = call_get(**{self.option: True, "dump": config.dump_yaml})
     settings = yaml.safe_load(stdio.getOutput())
     self.assertThat(settings, Contains(self.option))
Example #12
0
 def test__dumps_yaml_to_stdout_by_default(self):
     stdio = call_get(**{self.option: True})
     settings = yaml.safe_load(stdio.getOutput())
     self.assertThat(settings, Contains(self.option))
Example #13
0
 def test_gen_configuration_options_for_setting(self):
     self.assertThat(
         config.gen_configuration_options_for_setting(),
         AllMatch(MatchesListwise([Not(Contains("_")),
                                   IsInstance(dict)]), ))
Example #14
0
    def test_release_snap_with_branch(self):
        self.fake_store_release.mock.return_value = {
            "opened_channels": ["stable/hotfix1"],
            "channel_map_tree": {
                "2.1": {
                    "16": {
                        "amd64": [
                            {
                                "channel": "stable",
                                "info": "none"
                            },
                            {
                                "channel": "candidate",
                                "info": "none"
                            },
                            {
                                "revision": 19,
                                "channel": "beta",
                                "version": "0",
                                "info": "specific",
                            },
                            {
                                "channel": "edge",
                                "info": "tracking"
                            },
                            {
                                "channel": "stable/hotfix1",
                                "info": "branch",
                                "revision": 20,
                                "version": "1",
                                "expires_at": "2017-05-21T18:52:14.578435",
                            },
                        ]
                    }
                }
            },
        }

        result = self.run_command(
            ["release", "nil-snap", "20", "stable/hotfix1"])

        self.assertThat(result.exit_code, Equals(0))
        self.assertThat(
            result.output,
            Contains(
                dedent("""\
            Track    Arch    Channel         Version    Revision    Notes    Expires at
            2.1      amd64   stable          -          -           -
                             candidate       -          -           -
                             beta            0          19          -
                             edge            ^          ^           -
                             stable/hotfix1  1          20          -        2017-05-21T18:52:14.578435
            \x1b[0;32mThe 'stable/hotfix1' channel is now open.\x1b[0m""")),
        )
        self.fake_store_release.mock.assert_called_once_with(
            snap_name="nil-snap",
            revision="20",
            channels=["stable/hotfix1"],
            progressive_key=None,
            progressive_percentage=None,
        )
Example #15
0
 def test_debugging_logger_does_not_log_request_if_info_level(self):
     logger = self.useFixture(FakeLogger('maasserver', logging.INFO))
     request = factory.make_fake_request("/MAAS/api/2.0/nodes/")
     self.process_request(request)
     debug_output = DebuggingLoggerMiddleware._build_request_repr(request)
     self.assertThat(logger.output, Not(Contains(debug_output)))
Example #16
0
 def test_assertSequenceEqual_forwards_message(self):
     message = factory.make_name("message")
     error = self.assertRaises(AssertionError, self.assertSequenceEqual,
                               [1], [2], message)
     self.assertThat(str(error), Contains(message))
Example #17
0
    def test_create_volume(self, mock_api_req):

        # prepare the dependencies
        fake_volume_id = self._get_fake_volume_id()

        volume = {'id': fake_volume_id, 'size': 22}

        # Test - I

        # configure the mocks with respective side-effects
        mock_api_req.side_effect = self._side_effect_api_req

        # now run the test
        provider_details = self.driver.create_volume(volume)

        # assert equality checks for certain configuration attributes
        self.assertEqual('openstack', self.driver.configuration.cb_tsm_name)
        self.assertEqual('CustomerA',
                         self.driver.configuration.cb_account_name)
        self.assertThat(provider_details['provider_location'],
                        Contains('172.16.50.35:3260'))

        # assert that 9 api calls were invoked
        self.assertEqual(9, mock_api_req.call_count)

        # Test - II

        # reconfigure the dependencies
        volume['id'] = 'NotExists'
        del volume['size']

        # reset & reconfigure the mock
        mock_api_req.reset_mock()
        mock_api_req.side_effect = self._side_effect_api_req

        # now run the test & assert the exception
        with ExpectedException(
                exception.VolumeBackendAPIException,
                "Bad or unexpected response from the storage volume "
                "backend API: Volume \[NotExists\] not found in "
                "CloudByte storage."):
            self.driver.create_volume(volume)

        # Test - III

        # reconfigure the dependencies
        volume['id'] = 'abc'

        # reset the mocks
        mock_api_req.reset_mock()

        # configure or re-configure the mocks
        mock_api_req.side_effect = self._side_effect_api_req_to_create_vol

        # now run the test & assert the exception
        with ExpectedException(
                exception.VolumeBackendAPIException,
                'Bad or unexpected response from the storage volume '
                'backend API: Null response received while '
                'creating volume'):
            self.driver.create_volume(volume)

        # Test - IV

        # reconfigure the dependencies
        # reset the mocks
        mock_api_req.reset_mock()

        # configure or re-configure the mocks
        mock_api_req.side_effect = self._side_effect_api_req_to_list_filesystem

        # now run the test
        with ExpectedException(
                exception.VolumeBackendAPIException,
                "Bad or unexpected response from the storage volume "
                "backend API: Null response received from CloudByte's "
                "list filesystem."):
            self.driver.create_volume(volume)

        # Test - VI

        volume['id'] = fake_volume_id
        # reconfigure the dependencies
        # reset the mocks
        mock_api_req.reset_mock()

        # configure or re-configure the mocks
        mock_api_req.side_effect = (
            self._side_effect_api_req_to_list_vol_iscsi_service)

        # now run the test
        with ExpectedException(
                exception.VolumeBackendAPIException,
                "Bad or unexpected response from the storage volume "
                "backend API: Null response received from CloudByte's "
                "list volume iscsi service."):
            self.driver.create_volume(volume)

        # Test - VII

        # reconfigure the dependencies
        # reset the mocks
        mock_api_req.reset_mock()

        # configure or re-configure the mocks
        mock_api_req.side_effect = (
            self._side_effect_api_req_to_list_iscsi_initiator)

        # now run the test
        with ExpectedException(
                exception.VolumeBackendAPIException,
                "Bad or unexpected response from the storage volume "
                "backend API: Null response received from CloudByte's "
                "list iscsi initiators."):
            self.driver.create_volume(volume)
Example #18
0
    def test_close_multiple_architectures(self, mock_close_channels,
                                          mock_get_account_info):
        mock_get_account_info.return_value = {
            'snaps': {
                '16': {
                    'basic': {
                        'snap-id': 'snap-id'
                    }
                }
            }
        }
        closed_channels = ['beta']
        channel_map_tree = {
            'latest': {
                '16': {
                    'amd64': [{
                        'channel': 'stable',
                        'info': 'none'
                    }, {
                        'channel': 'candidate',
                        'info': 'none'
                    }, {
                        'channel': 'beta',
                        'info': 'specific',
                        'version': '1.1',
                        'revision': 42
                    }, {
                        'channel': 'edge',
                        'info': 'tracking'
                    }],
                    'armhf': [{
                        'channel': 'stable',
                        'info': 'none'
                    }, {
                        'channel': 'beta',
                        'info': 'specific',
                        'version': '1.2',
                        'revision': 24
                    }, {
                        'channel': 'beta',
                        'info': 'tracking'
                    }, {
                        'channel': 'edge',
                        'info': 'tracking'
                    }],
                }
            }
        }
        mock_close_channels.side_effect = [
            (closed_channels, channel_map_tree),
        ]

        result = self.run_command(['close', 'basic', 'beta'])

        self.assertThat(result.exit_code, Equals(0))
        self.assertThat(
            result.output,
            Contains(
                dedent("""\
            Track    Arch    Channel    Version    Revision
            latest   amd64   stable     -          -
                             candidate  -          -
                             beta       1.1        42
                             edge       ^          ^
                     armhf   stable     -          -
                             beta       1.2        24
                             beta       ^          ^
                             edge       ^          ^

            \x1b[0;32mThe beta channel is now closed.\x1b[0m""")))
Example #19
0
 def test_prime_invalid_part_does_traceback_with_debug(self):
     self.assertThat(
         self._prime_invalid_part(True), Contains("Traceback"))
Example #20
0
    def test_close_branches(self, mock_close_channels, mock_get_account_info):
        mock_get_account_info.return_value = {
            'snaps': {
                '16': {
                    'basic': {
                        'snap-id': 'snap-id'
                    }
                }
            }
        }
        closed_channels = ['stable/hotfix-1']
        channel_map_tree = {
            'latest': {
                '16': {
                    'amd64': [
                        {
                            'channel': 'stable',
                            'info': 'none'
                        },
                        {
                            'channel': 'candidate',
                            'info': 'none'
                        },
                        {
                            'channel': 'beta',
                            'info': 'specific',
                            'version': '1.1',
                            'revision': 42
                        },
                        {
                            'channel': 'edge',
                            'info': 'tracking'
                        },
                        {
                            'channel': 'stable/hotfix-2',
                            'info': 'branch',
                            'version': '1.3',
                            'revision': 49,
                            'expires_at': '2017-05-21T18:52:14.578435'
                        },
                    ],
                }
            }
        }
        mock_close_channels.side_effect = [
            (closed_channels, channel_map_tree),
        ]

        result = self.run_command(['close', 'basic', 'stable/hotfix-1'])

        self.assertThat(result.exit_code, Equals(0))
        self.assertThat(result.output,
                        Contains(
                            dedent("""\
            Track    Arch    Channel          Version    Revision    Expires at
            latest   amd64   stable           -          -
                             candidate        -          -
                             beta             1.1        42
                             edge             ^          ^
                             stable/hotfix-2  1.3        49          2017-05-21T18:52:14.578435

            \x1b[0;32mThe stable/hotfix-1 channel is now closed.\x1b[0m"""))
                        )  # noqa
Example #21
0
 def logout(self):
     output = self.run_snapcraft('logout')
     expected = ('Clearing credentials for Ubuntu One SSO.\n'
                 'Credentials cleared.\n')
     self.assertThat(output, Contains(expected))
Example #22
0
    def test_print_generic_help_by_default(self):
        result = self.run_command(["help"])

        self.assertThat(result.output,
                        Contains("Snapcraft is a delightful packaging tool."))
        self.assertThat(result.output, Contains("For more help"))
Example #23
0
 def test_invalid_workspace(self, robot):
     robot.cli('status')
     self.assertThat(robot.stderr, Contains('WARNING'))
Example #24
0
 def test_get_maas_user_agent_without_uuid(self):
     user_agent = get_maas_user_agent()
     uuid = Config.objects.get_config("uuid")
     self.assertEqual(uuid, None)
     self.assertThat(user_agent, IsNonEmptyString)
     self.assertThat(user_agent, Not(Contains(uuid)))
Example #25
0
 def _then(servermap):
     dumped = servermap.dump(StringIO())
     self.assertThat(dumped.getvalue(), Contains("3-of-10"))
Example #26
0
    def test_no_defined_build_env(self):
        """
        Test that the build-environment defined by the gnome-3-34 extension is
        applied to all parts. In this test case, there is no user-defined
        build-environment section in any part.
        """
        self.make_snapcraft_yaml(
            textwrap.dedent("""\
                name: test
                version: '1'
                summary: test
                description: test
                base: core18
                grade: stable
                confinement: strict

                apps:
                    test-app:
                        command: echo "hello"
                        extensions: [gnome-3-34]

                parts:
                    test-part-1:
                        plugin: nil
                    test-part-2:
                        plugin: nil
                """))

        result = self.run_command(["expand-extensions"])

        self.assertThat(
            result.output,
            Contains(
                textwrap.dedent("""\
                        parts:
                          test-part-1:
                            plugin: nil
                            build-environment: &id001
                            - PATH: /snap/gnome-3-34-1804-sdk/current/usr/bin:$PATH
                            - XDG_DATA_DIRS: /snap/gnome-3-34-1804-sdk/current/usr/share:/usr/share:$XDG_DATA_DIRS
                            - LD_LIBRARY_PATH: /snap/gnome-3-34-1804-sdk/current/lib/$SNAPCRAFT_ARCH_TRIPLET:/snap/gnome-3-34-1804-sdk/current/usr/lib/$SNAPCRAFT_ARCH_TRIPLET:/snap/gnome-3-34-1804-sdk/current/usr/lib:/snap/gnome-3-34-1804-sdk/current/usr/lib/vala-current:$LD_LIBRARY_PATH
                            - PKG_CONFIG_PATH: /snap/gnome-3-34-1804-sdk/current/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig:/snap/gnome-3-34-1804-sdk/current/usr/lib/pkgconfig:/snap/gnome-3-34-1804-sdk/current/usr/share/pkgconfig:$PKG_CONFIG_PATH
                            - GETTEXTDATADIRS: /snap/gnome-3-34-1804-sdk/current/usr/share/gettext-current:$GETTEXTDATADIRS
                            - GDK_PIXBUF_MODULE_FILE: /snap/gnome-3-34-1804-sdk/current/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gdk-pixbuf-current/loaders.cache
                          test-part-2:
                            plugin: nil
                            build-environment: *id001
                          gnome-3-34-extension:
                            build-packages:
                            - gcc
                            build-snaps:
                            - gnome-3-34-1804-sdk/latest/stable
                            plugin: make
                            source: $SNAPCRAFT_EXTENSIONS_DIR/desktop
                            source-subdir: gnome
                    """)),
        )

        # Test that the layouts are as set in the extension
        self.assertThat(
            result.output,
            Contains(
                textwrap.dedent("""\
                        layout:
                          /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0:
                            bind: $SNAP/gnome-platform/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0
                          /usr/share/xml/iso-codes:
                            bind: $SNAP/gnome-platform/usr/share/xml/iso-codes
                    """)),
        )

        # test that the environment is as set in the extension
        self.assertThat(
            result.output,
            Contains(
                textwrap.dedent("""\
                        environment:
                          GTK_USE_PORTALS: \'1\'
                          SNAP_DESKTOP_RUNTIME: $SNAP/gnome-platform
                    """)),
        )

        # test that the interface plugs are as set in the extension
        self.assertThat(
            result.output,
            Contains(
                textwrap.dedent("""\
                        plugs:
                          gnome-3-34-1804:
                            default-provider: gnome-3-34-1804
                            interface: content
                            target: $SNAP/gnome-platform
                          gtk-3-themes:
                            default-provider: gtk-common-themes
                            interface: content
                            target: $SNAP/data-dir/themes
                          icon-themes:
                            default-provider: gtk-common-themes
                            interface: content
                            target: $SNAP/data-dir/icons
                          sound-themes:
                            default-provider: gtk-common-themes
                            interface: content
                            target: $SNAP/data-dir/sounds
                    """)),
        )
Example #27
0
    def test_push_and_release_a_snap_to_N_channels(self):
        mock_tracker = mock.Mock(storeapi._status_tracker.StatusTracker)
        mock_tracker.track.return_value = {
            'code': 'ready_to_release',
            'processed': True,
            'can_release': True,
            'url': '/fake/url',
            'revision': 9,
        }
        patcher = mock.patch.object(storeapi.StoreClient, 'upload')
        mock_upload = patcher.start()
        self.addCleanup(patcher.stop)
        mock_upload.return_value = mock_tracker

        patcher = mock.patch.object(storeapi.StoreClient, 'release')
        mock_release = patcher.start()
        self.addCleanup(patcher.stop)
        mock_release.return_value = {
            'opened_channels': ['beta,edge,candidate'],
            'channel_map_tree': {
                'latest': {
                    '16': {
                        'amd64': [
                            {
                                'channel': 'stable',
                                'info': 'none'
                            },
                            {
                                'revision': 9,
                                'channel': 'candidate',
                                'version': '0',
                                'info': 'specific'
                            },
                            {
                                'revision': 9,
                                'channel': 'beta',
                                'version': '0',
                                'info': 'specific'
                            },
                            {
                                'revision': 9,
                                'channel': 'edge',
                                'version': '0',
                                'info': 'specific'
                            },
                        ]
                    }
                }
            }
        }

        # Upload
        with mock.patch('snapcraft.storeapi._status_tracker.'
                        'StatusTracker') as mock_tracker:
            result = self.run_command(
                ['push', self.snap_file, '--release', 'edge,beta,candidate'])

        self.assertThat(result.exit_code, Equals(0))
        self.assertThat(result.output,
                        Contains("Revision 9 of 'basic' created"))
        self.assertThat(
            result.output,
            Contains("The 'beta,edge,candidate' channel is now open"))

        mock_upload.assert_called_once_with('basic', self.snap_file)
        mock_release.assert_called_once_with('basic', 9,
                                             ['edge', 'beta', 'candidate'])
Example #28
0
    def test_no_redundant_build_env(self):
        """
        Test that the build-environment defined by the gnome-3-34 extension is
        added to any build-environment variables defined by the user. In this
        test case, there are some user-defined build-environment variables that
        are not defined by the extension. The final build-environment should be
        the total set of variables defined by the user and the extension.
        """
        self.make_snapcraft_yaml(
            textwrap.dedent("""\
                name: test
                version: '1'
                summary: test
                description: test
                base: core18
                grade: stable
                confinement: strict

                apps:
                    test-app:
                        command: echo "hello"
                        extensions: [gnome-3-34]

                parts:
                    test-part-1:
                        plugin: nil
                        build-environment:
                            - TEST_VAR1: dir1
                            - TEST_VAR2: dir2
                    test-part-2:
                        plugin: nil
                        build-environment:
                            - TEST_VAR3: dir3
                            - TEST_VAR4: dir4
                """))

        result = self.run_command(["expand-extensions"])

        self.assertThat(
            result.output,
            Contains(
                textwrap.dedent("""\
                        parts:
                          test-part-1:
                            plugin: nil
                            build-environment:
                            - &id001
                              PATH: /snap/gnome-3-34-1804-sdk/current/usr/bin:$PATH
                            - &id002
                              XDG_DATA_DIRS: /snap/gnome-3-34-1804-sdk/current/usr/share:/usr/share:$XDG_DATA_DIRS
                            - &id003
                              LD_LIBRARY_PATH: /snap/gnome-3-34-1804-sdk/current/lib/$SNAPCRAFT_ARCH_TRIPLET:/snap/gnome-3-34-1804-sdk/current/usr/lib/$SNAPCRAFT_ARCH_TRIPLET:/snap/gnome-3-34-1804-sdk/current/usr/lib:/snap/gnome-3-34-1804-sdk/current/usr/lib/vala-current:$LD_LIBRARY_PATH
                            - &id004
                              PKG_CONFIG_PATH: /snap/gnome-3-34-1804-sdk/current/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig:/snap/gnome-3-34-1804-sdk/current/usr/lib/pkgconfig:/snap/gnome-3-34-1804-sdk/current/usr/share/pkgconfig:$PKG_CONFIG_PATH
                            - &id005
                              GETTEXTDATADIRS: /snap/gnome-3-34-1804-sdk/current/usr/share/gettext-current:$GETTEXTDATADIRS
                            - &id006
                              GDK_PIXBUF_MODULE_FILE: /snap/gnome-3-34-1804-sdk/current/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gdk-pixbuf-current/loaders.cache
                            - TEST_VAR1: dir1
                            - TEST_VAR2: dir2
                          test-part-2:
                            plugin: nil
                            build-environment:
                            - *id001
                            - *id002
                            - *id003
                            - *id004
                            - *id005
                            - *id006
                            - TEST_VAR3: dir3
                            - TEST_VAR4: dir4
                    """)),
        )
Example #29
0
    def test_push_without_login_must_raise_exception(self):
        raised = self.assertRaises(storeapi.errors.InvalidCredentialsError,
                                   self.run_command, ['push', self.snap_file])

        self.assertThat(str(raised), Contains('Invalid credentials'))
Example #30
0
    def test_some_redundant_build_env(self):
        """
        Test that the user-defined build-environment variables are used in
        replacement of the extension-defined variables, when the variables are
        defined in both places.
        """
        self.make_snapcraft_yaml(
            textwrap.dedent("""\
                name: test
                version: '1'
                summary: test
                description: test
                base: core18
                grade: stable
                confinement: strict

                apps:
                    test-app:
                        command: echo "hello"
                        extensions: [gnome-3-34]

                parts:
                    test-part-1:
                        plugin: nil
                        build-environment:
                            - TEST_VAR1: dir1
                            - TEST_VAR2: dir2
                            - PATH: path1
                            - PATH: path2
                            - PKG_CONFIG_PATH: $PKG_CONFIG_PATH
                    test-part-2:
                        plugin: nil
                        build-environment:
                            - TEST_VAR3: dir3
                            - TEST_VAR4: dir4
                            - GDK_PIXBUF_MODULE_FILE: $GDK_PIXBUF_MODULE_FILE
                            - LD_LIBRARY_PATH: $LD_LIBRARY_PATH
                """))

        result = self.run_command(["expand-extensions"])

        self.assertThat(
            result.output,
            Contains(
                textwrap.dedent("""\
                        parts:
                          test-part-1:
                            plugin: nil
                            build-environment:
                            - &id001
                              PATH: /snap/gnome-3-34-1804-sdk/current/usr/bin:$PATH
                            - &id002
                              XDG_DATA_DIRS: /snap/gnome-3-34-1804-sdk/current/usr/share:/usr/share:$XDG_DATA_DIRS
                            - &id003
                              LD_LIBRARY_PATH: /snap/gnome-3-34-1804-sdk/current/lib/$SNAPCRAFT_ARCH_TRIPLET:/snap/gnome-3-34-1804-sdk/current/usr/lib/$SNAPCRAFT_ARCH_TRIPLET:/snap/gnome-3-34-1804-sdk/current/usr/lib:/snap/gnome-3-34-1804-sdk/current/usr/lib/vala-current:$LD_LIBRARY_PATH
                            - &id004
                              PKG_CONFIG_PATH: /snap/gnome-3-34-1804-sdk/current/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig:/snap/gnome-3-34-1804-sdk/current/usr/lib/pkgconfig:/snap/gnome-3-34-1804-sdk/current/usr/share/pkgconfig:$PKG_CONFIG_PATH
                            - &id005
                              GETTEXTDATADIRS: /snap/gnome-3-34-1804-sdk/current/usr/share/gettext-current:$GETTEXTDATADIRS
                            - &id006
                              GDK_PIXBUF_MODULE_FILE: /snap/gnome-3-34-1804-sdk/current/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gdk-pixbuf-current/loaders.cache
                            - TEST_VAR1: dir1
                            - TEST_VAR2: dir2
                            - PATH: path1
                            - PATH: path2
                            - PKG_CONFIG_PATH: $PKG_CONFIG_PATH
                          test-part-2:
                            plugin: nil
                            build-environment:
                            - *id001
                            - *id002
                            - *id003
                            - *id004
                            - *id005
                            - *id006
                            - TEST_VAR3: dir3
                            - TEST_VAR4: dir4
                            - GDK_PIXBUF_MODULE_FILE: $GDK_PIXBUF_MODULE_FILE
                            - LD_LIBRARY_PATH: $LD_LIBRARY_PATH
                    """)),
        )