Esempio n. 1
0
    def test_build(
        self,
        finish_build_mock,
        prepare_build_mock,
        run_output_mock,
        bashrun_mock,
        run_mock,
        compilers_mock,
    ):
        plugin = catkin_tools.CatkinToolsPlugin("test-part", self.properties,
                                                self.project)
        os.makedirs(os.path.join(plugin.sourcedir, "src"))

        plugin.build()

        prepare_build_mock.assert_called_once_with()

        class check_build_command:
            def __eq__(self, args):
                command = " ".join(args)
                return (args[0] == "catkin" and "build" in command
                        and "my_package" in command)

        bashrun_mock.assert_called_with(check_build_command(), env=mock.ANY)

        finish_build_mock.assert_called_once_with()
Esempio n. 2
0
    def test_build_multiple(
        self,
        finish_build_mock,
        prepare_build_mock,
        run_output_mock,
        bashrun_mock,
        run_mock,
        compilers_mock,
    ):
        self.properties.catkin_packages.append("package_2")

        plugin = catkin_tools.CatkinToolsPlugin("test-part", self.properties,
                                                self.project)
        os.makedirs(os.path.join(plugin.sourcedir, "src"))

        plugin.build()

        class check_pkg_arguments:
            def __init__(self, test):
                self.test = test

            def __eq__(self, args):
                index = args.index("build")
                packages = args[index + 1:]
                self.test.assertIn("my_package", packages)
                self.test.assertIn("package_2", packages)
                return True

        bashrun_mock.assert_called_with(check_pkg_arguments(self),
                                        env=mock.ANY)

        finish_build_mock.assert_called_once_with()
Esempio n. 3
0
    def test_build_runs_in_bash(self, run_output_mock, run_mock):
        plugin = catkin_tools.CatkinToolsPlugin("test-part", self.properties,
                                                self.project)
        os.makedirs(os.path.join(plugin.sourcedir, "src"))

        plugin.build()

        run_mock.assert_has_calls(
            [mock.call(["/bin/bash", mock.ANY], cwd=mock.ANY, env=mock.ANY)])
Esempio n. 4
0
    def test_build_runs_in_bash(self, run_output_mock, run_mock,
                                compilers_mock):
        plugin = catkin_tools.CatkinToolsPlugin('test-part', self.properties,
                                                self.project_options)
        os.makedirs(os.path.join(plugin.sourcedir, 'src'))

        plugin.build()

        run_mock.assert_has_calls(
            [mock.call(['/bin/bash', mock.ANY], cwd=mock.ANY, env=mock.ANY)])
Esempio n. 5
0
    def test_prepare_build(self, use_python_mock, bashrun_mock,
                           compilers_mock):
        plugin = catkin_tools.CatkinToolsPlugin('test-part', self.properties,
                                                self.project_options)
        os.makedirs(os.path.join(plugin.rosdir, 'test'))

        plugin._prepare_build()

        build_attributes = self.build_attributes
        catkin_cmake_args = self.catkin_cmake_args

        self.assertTrue(use_python_mock.called)

        confArgs = bashrun_mock.mock_calls[0][1][0]
        command = ' '.join(confArgs)
        self.assertThat(command, Contains('catkin init'))

        confArgs = bashrun_mock.mock_calls[1][1][0]
        command = ' '.join(confArgs)
        self.assertThat(command, Contains('catkin clean -y'))

        confArgs = bashrun_mock.mock_calls[2][1][0]
        command = ' '.join(confArgs)
        self.assertThat(command, Contains('catkin profile add -f default'))

        confArgs = bashrun_mock.mock_calls[3][1][0]
        self.assertThat(confArgs[0], Equals('catkin'))
        self.assertThat(confArgs[1], Equals('config'))

        command = ' '.join(confArgs)
        self.assertThat(command, Contains('--profile default'))
        self.assertThat(command, Contains('--install'))
        self.assertThat(command,
                        Contains('--build-space {}'.format(plugin.builddir)))
        self.assertThat(command,
                        Contains('--source-space {}'
                                 .format(os.path.join(plugin.builddir,
                                         plugin.options.source_space))))
        self.assertThat(command, Contains('--install-space {}'
                                          .format(plugin.rosdir)))

        expected_args = ' '.join(self.catkin_cmake_args)

        if catkin_cmake_args:
            self.assertRegexpMatches(command, '.*--cmake-args.*{}'
                                     .format(re.escape(expected_args)))

        if 'debug' in build_attributes:
            self.assertRegexpMatches(command,
                                     '.*--cmake-args.'
                                     '*-DCMAKE_BUILD_TYPE=Debug')
        else:
            self.assertRegexpMatches(command,
                                     '.*--cmake-args.'
                                     '*-DCMAKE_BUILD_TYPE=Release')
Esempio n. 6
0
    def test_prepare_build(self, use_python_mock, bashrun_mock):
        plugin = catkin_tools.CatkinToolsPlugin("test-part", self.properties,
                                                self.project)
        os.makedirs(os.path.join(plugin.rosdir, "test"))

        plugin._prepare_build()

        build_attributes = self.build_attributes
        catkin_cmake_args = self.catkin_cmake_args

        self.assertTrue(use_python_mock.called)

        confArgs = bashrun_mock.mock_calls[0][1][0]
        command = " ".join(confArgs)
        self.assertThat(command, Contains("catkin init"))

        confArgs = bashrun_mock.mock_calls[1][1][0]
        command = " ".join(confArgs)
        self.assertThat(command, Contains("catkin clean -y"))

        confArgs = bashrun_mock.mock_calls[2][1][0]
        command = " ".join(confArgs)
        self.assertThat(command, Contains("catkin profile add -f default"))

        confArgs = bashrun_mock.mock_calls[3][1][0]
        self.assertThat(confArgs[0], Equals("catkin"))
        self.assertThat(confArgs[1], Equals("config"))

        command = " ".join(confArgs)
        self.assertThat(command, Contains("--profile default"))
        self.assertThat(command, Contains("--install"))
        self.assertThat(command,
                        Contains("--build-space {}".format(plugin.builddir)))
        self.assertThat(
            command,
            Contains("--source-space {}".format(
                os.path.join(plugin.builddir, plugin.options.source_space))),
        )
        self.assertThat(command,
                        Contains("--install-space {}".format(plugin.rosdir)))

        expected_args = " ".join(self.catkin_cmake_args)

        if catkin_cmake_args:
            self.assertRegexpMatches(
                command, ".*--cmake-args.*{}".format(re.escape(expected_args)))

        if "debug" in build_attributes:
            self.assertRegexpMatches(
                command, ".*--cmake-args.*-DCMAKE_BUILD_TYPE=Debug")
        else:
            self.assertRegexpMatches(
                command, ".*--cmake-args.*-DCMAKE_BUILD_TYPE=Release")
Esempio n. 7
0
    def test_build(self, finish_build_mock, prepare_build_mock,
                   run_output_mock, bashrun_mock, run_mock, compilers_mock):
        plugin = catkin_tools.CatkinToolsPlugin('test-part', self.properties,
                                                self.project_options)
        os.makedirs(os.path.join(plugin.sourcedir, 'src'))

        plugin.build()

        prepare_build_mock.assert_called_once_with()

        class check_build_command():
            def __eq__(self, args):
                command = ' '.join(args)
                return (args[0] == 'catkin' and 'build' in command
                        and 'my_package' in command)

        bashrun_mock.assert_called_with(check_build_command(), env=mock.ANY)

        finish_build_mock.assert_called_once_with()