Example #1
0
    def test_pull(self, check_call_mock):
        """Test pulling with the default settings."""
        plugin = meson.MesonPlugin("test-part", self.options, self.project)

        plugin.pull()

        check_call_mock.assert_called_once_with(
            ["python3", "-m", "pip", "install", "-U", "meson"])
Example #2
0
    def test_build(self, run_mock):
        """Test building via meson and check for known calls and destdir"""
        plugin = meson.MesonPlugin("test-part", self.options, self.project)

        plugin.build()

        env = os.environ.copy()
        env["DESTDIR"] = plugin.installdir

        self.assertThat(run_mock.call_count, Equals(3))
        run_mock.assert_has_calls([
            mock.call(["meson", plugin.snapbuildname]),
            mock.call(["ninja"], cwd=plugin.mesonbuilddir),
            mock.call(["ninja", "install"], env=env, cwd=plugin.mesonbuilddir),
        ])
Example #3
0
    def test_build(self, run_mock):
        """Test building via meson and check for known calls and destdir"""
        plugin = meson.MesonPlugin('test-part', self.options,
                                   self.project_options)

        plugin.build()

        env = os.environ.copy()
        env['DESTDIR'] = plugin.installdir

        self.assertEqual(3, run_mock.call_count)
        run_mock.assert_has_calls([
            mock.call(['meson', plugin.snapbuildname]),
            mock.call(['ninja'], cwd=plugin.mesonbuilddir),
            mock.call(['ninja', 'install'], env=env, cwd=plugin.mesonbuilddir)
        ])
Example #4
0
    def test_build_with_parameters(self, run_mock):
        """Test with parameters"""
        self.options.meson_parameters = ["--strip"]
        plugin = meson.MesonPlugin("test-part", self.options, self.project)

        plugin.build()

        env = os.environ.copy()
        env["DESTDIR"] = plugin.installdir

        self.assertThat(run_mock.call_count, Equals(3))
        run_mock.assert_has_calls([
            mock.call(["meson", "--strip", plugin.snapbuildname]),
            mock.call(["ninja"], cwd=plugin.mesonbuilddir),
            mock.call(["ninja", "install"], env=env, cwd=plugin.mesonbuilddir),
        ])
Example #5
0
    def test_build_with_parameters(self, run_mock):
        """Test with parameters"""
        self.options.meson_parameters = ['--strip']
        plugin = meson.MesonPlugin('test-part', self.options,
                                   self.project_options)

        plugin.build()

        env = os.environ.copy()
        env['DESTDIR'] = plugin.installdir

        self.assertEqual(3, run_mock.call_count)
        run_mock.assert_has_calls([
            mock.call(['meson', '--strip', plugin.snapbuildname]),
            mock.call(['ninja'], cwd=plugin.mesonbuilddir),
            mock.call(['ninja', 'install'], env=env, cwd=plugin.mesonbuilddir)
        ])
Example #6
0
    def test_pull_meson_installation_fails(self, check_call_mock):
        """Test pulling with the default settings."""
        self.options.meson_version = "1.0"
        plugin = meson.MesonPlugin("test-part", self.options, self.project)

        self.assertRaises(errors.SnapcraftPluginCommandError, plugin.pull)