Exemple #1
0
    def test_check_error_not_found(self, mocker):
        """CMake was not found."""
        mocked_run = mocker.patch("dependencmake.cmake.run", autospec=True)
        mocked_run.side_effect = FileNotFoundError("not found")

        with pytest.raises(CMakeNotFoundError,
                           match=r"CMake executable was not found"):
            check_cmake_exists()
Exemple #2
0
    def test_check(self, mocker):
        """CMake was found."""
        mocked_run = mocker.patch("dependencmake.cmake.run", autospec=True)

        check_cmake_exists()

        mocked_run.assert_called_with(["cmake", "--version"],
                                      stdout=DEVNULL,
                                      stderr=DEVNULL,
                                      check=True)
Exemple #3
0
    def test_check_error(self, mocker):
        """CMake cannot be run."""
        mocked_run = mocker.patch("dependencmake.cmake.run", autospec=True)
        mocked_run.side_effect = CalledProcessError(returncode=128,
                                                    cmd="cmd",
                                                    output=None,
                                                    stderr=None)

        with pytest.raises(CMakeNotUseableError,
                           match=r"CMake executable cannot be run"):
            check_cmake_exists()
Exemple #4
0
    def install(self, output=sys.stdout):
        """Install dependencies."""
        # create build cache
        self.install_path.makedirs_p()

        # check CMake works
        check_cmake_exists()

        # build
        output.write("Installing dependencies...\n")
        for dependency in tqdm(self.dependencies,
                               file=output,
                               leave=False,
                               unit="dependency"):
            dependency.install()
Exemple #5
0
    def build(self, extra_args: list = [], output=sys.stdout):
        """Configure and build dependencies."""
        # create build cache
        CACHE_BUILD.mkdir_p()

        # check CMake works
        check_cmake_exists()

        # build
        output.write("Building dependencies...\n")
        for dependency in tqdm(self.dependencies,
                               file=output,
                               leave=False,
                               unit="dependency"):
            dependency.build(self.get_install_path(), extra_args)