From 945359dfc216013a941c83ffb9a04d9bb5bfae7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darius=20Nea=C8=9Bu?= Date: Wed, 15 Jul 2026 21:04:59 +0300 Subject: [PATCH 1/3] [beman-tidy] Implement cmake.use_find_package check (#80) --- beman_tidy/lib/checks/beman_standard/cmake.py | 95 ++++++++++++++++++- .../data/invalid/repo-exemplar-v1/.gitmodules | 3 + .../invalid/repo-exemplar-v1/CMakeLists.txt | 7 ++ .../invalid/repo-exemplar-v2/CMakeLists.txt | 15 +++ .../invalid/repo-exemplar-v3/CMakeLists.txt | 8 ++ .../tests/beman/exemplar/CMakeLists.txt | 10 ++ .../invalid/repo-exemplar-v4/CMakeLists.txt | 8 ++ .../repo-exemplar-v4/examples/CMakeLists.txt | 10 ++ .../valid/repo-exemplar-v1/CMakeLists.txt | 24 +++++ .../repo-exemplar-v1/examples/CMakeLists.txt | 3 + .../tests/beman/exemplar/CMakeLists.txt | 9 ++ .../valid/repo-exemplar-v2/CMakeLists.txt | 7 ++ .../repo-exemplar-v2/infra/cmake/deps.cmake | 8 ++ .../checks/beman_standard/cmake/test_cmake.py | 55 +++++++++++ 14 files changed, 259 insertions(+), 3 deletions(-) create mode 100644 tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v1/.gitmodules create mode 100644 tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v1/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v2/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v3/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v3/tests/beman/exemplar/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v4/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v4/examples/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/examples/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/tests/beman/exemplar/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v2/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v2/infra/cmake/deps.cmake diff --git a/beman_tidy/lib/checks/beman_standard/cmake.py b/beman_tidy/lib/checks/beman_standard/cmake.py index e8823c68..1fbe41e2 100644 --- a/beman_tidy/lib/checks/beman_standard/cmake.py +++ b/beman_tidy/lib/checks/beman_standard/cmake.py @@ -4,6 +4,9 @@ from abc import ABC from collections.abc import Iterable +from ..base.base_check import BaseCheck +from ...utils.string import normalize_path_for_display + import cmake_parser from cmake_parser.ast import AstNode, Command @@ -125,9 +128,6 @@ def get_cmake_target_names(self): # TODO cmake.default -# TODO cmake.use_find_package - - @register_beman_standard_check("cmake.project_name") class CMakeProjectNameCheck(CMakeBaseCheck): def __init__(self, repo_info, beman_standard_check_config): @@ -282,6 +282,95 @@ def fix(self): return False +_USE_FIND_PACKAGE_DOC = ( + "https://github.com/bemanproject/beman/blob/main/docs/beman_standard.md" + "#cmakeuse_find_package" +) + + +def _has_fetch_content_declare(content): + ast = cmake_parser.parser.parse_raw(content, skip_comments=True) + return any( + hasattr(item, "identifier") + and item.identifier.lower() == "fetchcontent_declare" + for item in ast + ) + +@register_beman_standard_check("cmake.use_find_package") +class CMakeUseFindPackageCheck(BaseCheck): + def __init__(self, repo_info, beman_standard_check_config): + super().__init__(repo_info, beman_standard_check_config) + + def _gitmodules_has_content(self): + gitmodules_path = self.repo_path / ".gitmodules" + if not gitmodules_path.is_file(): + return False + try: + return len(gitmodules_path.read_text(encoding="utf-8", errors="ignore").strip()) > 0 + except OSError: + self.log( + "Unable to read .gitmodules. " + f"See {_USE_FIND_PACKAGE_DOC} for more information." + ) + return True + + def _cmake_files_to_check(self): + cmake_files = [] + + root_cmake = self.repo_path / "CMakeLists.txt" + if root_cmake.is_file(): + cmake_files.append(root_cmake) + + for cmake_file in self.repo_path.glob("*.cmake"): + cmake_files.append(cmake_file) + + for subdir in ("tests", "examples"): + subdir_path = self.repo_path / subdir + if not subdir_path.is_dir(): + continue + for cmake_file in subdir_path.rglob("*"): + if not cmake_file.is_file(): + continue + if "infra" in cmake_file.relative_to(self.repo_path).parts: + continue + if cmake_file.name == "CMakeLists.txt" or cmake_file.suffix == ".cmake": + cmake_files.append(cmake_file) + + return sorted(set(cmake_files)) + + def check(self): + if self._gitmodules_has_content(): + self.log( + "The repository should fetch dependencies via find_package, not git submodules. " + "Please remove .gitmodules and use find_package instead. " + f"See {_USE_FIND_PACKAGE_DOC} for more information." + ) + return False + + for cmake_file in self._cmake_files_to_check(): + try: + content = cmake_file.read_text() + except OSError: + continue + + if _has_fetch_content_declare(content): + display_path = normalize_path_for_display(cmake_file, self.repo_path) + self.log( + f"The file '{display_path}' uses FetchContent_Declare to fetch dependencies. " + "Dependencies should be fetched via find_package instead. " + f"See {_USE_FIND_PACKAGE_DOC} for more information." + ) + return False + + return True + + def fix(self): + self.log( + "Please fetch dependencies via find_package instead of git submodules or FetchContent. " + f"See {_USE_FIND_PACKAGE_DOC} for more information." + ) + return False + # TODO cmake.passive_targets diff --git a/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v1/.gitmodules b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v1/.gitmodules new file mode 100644 index 00000000..443d3e4e --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v1/.gitmodules @@ -0,0 +1,3 @@ +[submodule "dependency"] + path = deps/dependency + url = https://github.com/example/dependency.git diff --git a/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v1/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v1/CMakeLists.txt new file mode 100644 index 00000000..be211cc7 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v1/CMakeLists.txt @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.30...4.3) + +project(beman.exemplar LANGUAGES CXX) + +add_library(beman.exemplar INTERFACE) diff --git a/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v2/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v2/CMakeLists.txt new file mode 100644 index 00000000..0d90fead --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v2/CMakeLists.txt @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.30...4.3) + +project(beman.exemplar LANGUAGES CXX) + +include(FetchContent) + +FetchContent_Declare( + task + GIT_REPOSITORY https://github.com/bemanproject/task + GIT_TAG main +) + +add_library(beman.exemplar INTERFACE) diff --git a/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v3/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v3/CMakeLists.txt new file mode 100644 index 00000000..3961210a --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v3/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.30...4.3) + +project(beman.exemplar LANGUAGES CXX) + +add_library(beman.exemplar INTERFACE) +add_subdirectory(tests/beman/exemplar) diff --git a/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v3/tests/beman/exemplar/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v3/tests/beman/exemplar/CMakeLists.txt new file mode 100644 index 00000000..edf90339 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v3/tests/beman/exemplar/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +include(FetchContent) + +FetchContent_Declare( + GTest + GIT_REPOSITORY https://github.com/google/googletest.git +) + +add_executable(beman.exemplar.tests.identity) diff --git a/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v4/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v4/CMakeLists.txt new file mode 100644 index 00000000..4b7e97a7 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v4/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.30...4.3) + +project(beman.exemplar LANGUAGES CXX) + +add_library(beman.exemplar INTERFACE) +add_subdirectory(examples) diff --git a/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v4/examples/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v4/examples/CMakeLists.txt new file mode 100644 index 00000000..4c3846b0 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v4/examples/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +include(FetchContent) + +FetchContent_Declare( + catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git +) + +add_executable(beman.exemplar.examples.identity_direct_usage) diff --git a/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/CMakeLists.txt new file mode 100644 index 00000000..f8622937 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.30...4.3) + +project( + beman.exemplar + DESCRIPTION "A Beman Library Exemplar" + LANGUAGES CXX + VERSION 0.1.0 +) + +include(infra/cmake/beman-install-library.cmake) + +add_library(beman.exemplar INTERFACE) +add_library(beman::exemplar ALIAS beman.exemplar) + +if(BEMAN_EXEMPLAR_BUILD_TESTS) + enable_testing() + add_subdirectory(tests/beman/exemplar) +endif() + +if(BEMAN_EXEMPLAR_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() diff --git a/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/examples/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/examples/CMakeLists.txt new file mode 100644 index 00000000..947efb2b --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/examples/CMakeLists.txt @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_executable(beman.exemplar.examples.identity_direct_usage) diff --git a/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/tests/beman/exemplar/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/tests/beman/exemplar/CMakeLists.txt new file mode 100644 index 00000000..828301cb --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v1/tests/beman/exemplar/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +find_package(GTest REQUIRED) + +add_executable(beman.exemplar.tests.identity) +target_link_libraries( + beman.exemplar.tests.identity + PRIVATE beman::exemplar GTest::gtest_main +) diff --git a/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v2/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v2/CMakeLists.txt new file mode 100644 index 00000000..be211cc7 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v2/CMakeLists.txt @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.30...4.3) + +project(beman.exemplar LANGUAGES CXX) + +add_library(beman.exemplar INTERFACE) diff --git a/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v2/infra/cmake/deps.cmake b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v2/infra/cmake/deps.cmake new file mode 100644 index 00000000..f6263672 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v2/infra/cmake/deps.cmake @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +include(FetchContent) + +FetchContent_Declare( + catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git +) diff --git a/tests/lib/checks/beman_standard/cmake/test_cmake.py b/tests/lib/checks/beman_standard/cmake/test_cmake.py index 2af61d81..1ad05e98 100644 --- a/tests/lib/checks/beman_standard/cmake/test_cmake.py +++ b/tests/lib/checks/beman_standard/cmake/test_cmake.py @@ -14,6 +14,7 @@ CMakeLibraryNameCheck, CMakeLibraryAliasCheck, CMakeTargetNamesCheck, + CMakeUseFindPackageCheck, ) test_data_prefix = "tests/lib/checks/beman_standard/cmake/data" @@ -215,3 +216,57 @@ def test__cmake_target_names__fix_inplace(repo_info, beman_standard_check_config Note: Skipping this test as it is not implemented. """ pass + + +def test__cmake_use_find_package__valid(repo_info, beman_standard_check_config): + """ + Test that repositories without .gitmodules or FetchContent pass the check. + FetchContent under infra/ is excluded from this check. + """ + valid_repo_paths = [ + # Repo with find_package dependencies and no .gitmodules + Path(f"{valid_prefix}/repo-exemplar-v1/"), + # Repo with FetchContent only under infra/ (excluded from the check) + Path(f"{valid_prefix}/repo-exemplar-v2/"), + ] + + run_check_for_each_path( + True, + valid_repo_paths, + CMakeUseFindPackageCheck, + repo_info, + beman_standard_check_config, + ) + + +def test__cmake_use_find_package__invalid(repo_info, beman_standard_check_config): + """ + Test that repositories with .gitmodules or FetchContent fail the check. + """ + invalid_repo_paths = [ + # Repo with a non-empty .gitmodules file + Path(f"{invalid_prefix}/repo-exemplar-v1/"), + # Root CMakeLists.txt uses FetchContent_Declare + Path(f"{invalid_prefix}/repo-exemplar-v2/"), + # tests/ CMakeLists.txt uses FetchContent_Declare + Path(f"{invalid_prefix}/repo-exemplar-v3/"), + # examples/ CMakeLists.txt uses FetchContent_Declare + Path(f"{invalid_prefix}/repo-exemplar-v4/"), + ] + + run_check_for_each_path( + False, + invalid_repo_paths, + CMakeUseFindPackageCheck, + repo_info, + beman_standard_check_config, + ) + + +@pytest.mark.skip(reason="not implemented") +def test__cmake_use_find_package__fix_inplace(repo_info, beman_standard_check_config): + """ + Test that the fix method corrects invalid dependency fetching. + Note: Skipping this test as it is not implemented. + """ + pass From bd43d9210f7093f7b92af04dcf3f027089c7ac7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darius=20Nea=C8=9Bu?= Date: Thu, 19 Nov 2026 00:38:25 +0200 Subject: [PATCH 2/3] [beman-tidy] Allow the wg21 submodule in cmake.use_find_package --- beman_tidy/lib/checks/beman_standard/cmake.py | 33 ++++++++++++++++--- .../data/invalid/repo-exemplar-v5/.gitmodules | 6 ++++ .../invalid/repo-exemplar-v5/CMakeLists.txt | 24 ++++++++++++++ .../data/valid/repo-exemplar-v3/.gitmodules | 3 ++ .../valid/repo-exemplar-v3/CMakeLists.txt | 24 ++++++++++++++ .../checks/beman_standard/cmake/test_cmake.py | 8 +++-- 6 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v5/.gitmodules create mode 100644 tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v5/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v3/.gitmodules create mode 100644 tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v3/CMakeLists.txt diff --git a/beman_tidy/lib/checks/beman_standard/cmake.py b/beman_tidy/lib/checks/beman_standard/cmake.py index 123878f0..8dcc34c0 100644 --- a/beman_tidy/lib/checks/beman_standard/cmake.py +++ b/beman_tidy/lib/checks/beman_standard/cmake.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +import re from abc import ABC from collections.abc import Iterable @@ -375,6 +376,12 @@ def fix(self): ) +# Known exception from repository.disallow_git_submodules: the mpark/wg21 +# paper framework is not a C++ dependency, so it is not fetched via CMake. +_ALLOWED_SUBMODULE_URL = re.compile(r"^https://github\.com/mpark/wg21(?:\.git)?/?$") +_SUBMODULE_URL = re.compile(r"^\s*url\s*=\s*(\S+)\s*$", re.MULTILINE) + + def _has_fetch_content_declare(content): ast = cmake_parser.parser.parse_raw(content, skip_comments=True) return any( @@ -383,23 +390,29 @@ def _has_fetch_content_declare(content): for item in ast ) + @register_beman_standard_check("cmake.use_find_package") class CMakeUseFindPackageCheck(BaseCheck): def __init__(self, repo_info, beman_standard_check_config): super().__init__(repo_info, beman_standard_check_config) - def _gitmodules_has_content(self): + def _has_disallowed_submodules(self): gitmodules_path = self.repo_path / ".gitmodules" if not gitmodules_path.is_file(): return False try: - return len(gitmodules_path.read_text(encoding="utf-8", errors="ignore").strip()) > 0 + content = gitmodules_path.read_text(encoding="utf-8", errors="ignore") except OSError: self.log( "Unable to read .gitmodules. " f"See {_USE_FIND_PACKAGE_DOC} for more information." ) return True + urls = _SUBMODULE_URL.findall(content) + if not urls: + # Non-empty .gitmodules without a parsable url: treat it as a submodule. + return len(content.strip()) > 0 + return any(not _ALLOWED_SUBMODULE_URL.match(url) for url in urls) def _cmake_files_to_check(self): cmake_files = [] @@ -426,7 +439,7 @@ def _cmake_files_to_check(self): return sorted(set(cmake_files)) def check(self): - if self._gitmodules_has_content(): + if self._has_disallowed_submodules(): self.log( "The repository should fetch dependencies via find_package, not git submodules. " "Please remove .gitmodules and use find_package instead. " @@ -440,8 +453,17 @@ def check(self): except OSError: continue - if _has_fetch_content_declare(content): - display_path = normalize_path_for_display(cmake_file, self.repo_path) + display_path = normalize_path_for_display(cmake_file, self.repo_path) + try: + uses_fetch_content = _has_fetch_content_declare(content) + except cmake_parser.error.CMakeParseError: + self.log( + f"Unable to parse '{display_path}'; skipping it. " + f"See {_USE_FIND_PACKAGE_DOC} for more information." + ) + continue + + if uses_fetch_content: self.log( f"The file '{display_path}' uses FetchContent_Declare to fetch dependencies. " "Dependencies should be fetched via find_package instead. " @@ -458,6 +480,7 @@ def fix(self): ) return False + # TODO cmake.passive_targets diff --git a/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v5/.gitmodules b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v5/.gitmodules new file mode 100644 index 00000000..42bc9da8 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v5/.gitmodules @@ -0,0 +1,6 @@ +[submodule "papers/wg21"] + path = papers/P0000/wg21 + url = https://github.com/mpark/wg21.git +[submodule "dependency"] + path = deps/dependency + url = https://github.com/example/dependency.git diff --git a/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v5/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v5/CMakeLists.txt new file mode 100644 index 00000000..f8622937 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v5/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.30...4.3) + +project( + beman.exemplar + DESCRIPTION "A Beman Library Exemplar" + LANGUAGES CXX + VERSION 0.1.0 +) + +include(infra/cmake/beman-install-library.cmake) + +add_library(beman.exemplar INTERFACE) +add_library(beman::exemplar ALIAS beman.exemplar) + +if(BEMAN_EXEMPLAR_BUILD_TESTS) + enable_testing() + add_subdirectory(tests/beman/exemplar) +endif() + +if(BEMAN_EXEMPLAR_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() diff --git a/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v3/.gitmodules b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v3/.gitmodules new file mode 100644 index 00000000..f6b0cacc --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v3/.gitmodules @@ -0,0 +1,3 @@ +[submodule "papers/wg21"] + path = papers/P0000/wg21 + url = https://github.com/mpark/wg21.git diff --git a/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v3/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v3/CMakeLists.txt new file mode 100644 index 00000000..f8622937 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v3/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.30...4.3) + +project( + beman.exemplar + DESCRIPTION "A Beman Library Exemplar" + LANGUAGES CXX + VERSION 0.1.0 +) + +include(infra/cmake/beman-install-library.cmake) + +add_library(beman.exemplar INTERFACE) +add_library(beman::exemplar ALIAS beman.exemplar) + +if(BEMAN_EXEMPLAR_BUILD_TESTS) + enable_testing() + add_subdirectory(tests/beman/exemplar) +endif() + +if(BEMAN_EXEMPLAR_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() diff --git a/tests/lib/checks/beman_standard/cmake/test_cmake.py b/tests/lib/checks/beman_standard/cmake/test_cmake.py index 221ee493..99837d87 100644 --- a/tests/lib/checks/beman_standard/cmake/test_cmake.py +++ b/tests/lib/checks/beman_standard/cmake/test_cmake.py @@ -367,14 +367,16 @@ def test__cmake_skip_examples__fix_inplace(repo_info, beman_standard_check_confi def test__cmake_use_find_package__valid(repo_info, beman_standard_check_config): """ - Test that repositories without .gitmodules or FetchContent pass the check. - FetchContent under infra/ is excluded from this check. + Test that repositories without git submodules (other than the wg21 exception) + and without FetchContent outside infra/ pass the check. """ valid_repo_paths = [ # Repo with find_package dependencies and no .gitmodules Path(f"{valid_prefix}/repo-exemplar-v1/"), # Repo with FetchContent only under infra/ (excluded from the check) Path(f"{valid_prefix}/repo-exemplar-v2/"), + # Repo whose .gitmodules only contains the allowed mpark/wg21 submodule + Path(f"{valid_prefix}/repo-exemplar-v3/"), ] run_check_for_each_path( @@ -399,6 +401,8 @@ def test__cmake_use_find_package__invalid(repo_info, beman_standard_check_config Path(f"{invalid_prefix}/repo-exemplar-v3/"), # examples/ CMakeLists.txt uses FetchContent_Declare Path(f"{invalid_prefix}/repo-exemplar-v4/"), + # .gitmodules contains wg21 plus another submodule + Path(f"{invalid_prefix}/repo-exemplar-v5/"), ] run_check_for_each_path( From d2c303f47abf724916b07bdf048e6365aebee3e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darius=20Nea=C8=9Bu?= Date: Thu, 3 Dec 2026 21:41:56 +0200 Subject: [PATCH 3/3] [beman-tidy] Harden cmake.use_find_package and order it like the standard --- beman_tidy/lib/checks/beman_standard/cmake.py | 227 +++++++++--------- .../invalid/repo-exemplar-v6/CMakeLists.txt | 24 ++ .../data/invalid/repo-exemplar-v6/deps.cmake | 9 + .../valid/repo-exemplar-v4/CMakeLists.txt | 24 ++ .../tests/beman/exemplar/CMakeLists.txt | 10 + .../valid/repo-exemplar-v5/CMakeLists.txt | 24 ++ .../tests/beman/exemplar/CMakeLists.txt | 5 + .../checks/beman_standard/cmake/test_cmake.py | 124 +++++----- 8 files changed, 274 insertions(+), 173 deletions(-) create mode 100644 tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v6/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v6/deps.cmake create mode 100644 tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v4/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v4/tests/beman/exemplar/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v5/CMakeLists.txt create mode 100644 tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v5/tests/beman/exemplar/CMakeLists.txt diff --git a/beman_tidy/lib/checks/beman_standard/cmake.py b/beman_tidy/lib/checks/beman_standard/cmake.py index 8dcc34c0..7780b5e3 100644 --- a/beman_tidy/lib/checks/beman_standard/cmake.py +++ b/beman_tidy/lib/checks/beman_standard/cmake.py @@ -5,9 +5,6 @@ from abc import ABC from collections.abc import Iterable -from ..base.base_check import BaseCheck -from ...utils.string import normalize_path_for_display - import cmake_parser from cmake_parser.ast import AstNode, Command, If, Option @@ -17,7 +14,9 @@ ) from ..system.registry import register_beman_standard_check +from ..base.base_check import BaseCheck from ..base.file_base_check import FileBaseCheck +from ...utils.string import normalize_path_for_display # [cmake.*] checks category. # All checks in this file extend the CMakeBaseCheck class. @@ -216,6 +215,117 @@ def fix(self): return False +_USE_FIND_PACKAGE_DOC = ( + "https://github.com/bemanproject/beman/blob/main/docs/beman_standard.md" + "#cmakeuse_find_package" +) + + +# Known exception from repository.disallow_git_submodules: the mpark/wg21 +# paper framework is not a C++ dependency, so it is not fetched via CMake. +_ALLOWED_SUBMODULE_URL = re.compile(r"^https://github\.com/mpark/wg21(?:\.git)?/?$") +_SUBMODULE_URL = re.compile(r"^\s*url\s*=\s*(\S+)\s*$", re.MULTILINE) + + +def _has_fetch_content_declare(content): + ast = cmake_parser.parser.parse_raw(content, skip_comments=True) + return any( + hasattr(item, "identifier") + and item.identifier.lower() == "fetchcontent_declare" + for item in ast + ) + + +@register_beman_standard_check("cmake.use_find_package") +class CMakeUseFindPackageCheck(BaseCheck): + def __init__(self, repo_info, beman_standard_check_config): + super().__init__(repo_info, beman_standard_check_config) + + def _has_disallowed_submodules(self): + gitmodules_path = self.repo_path / ".gitmodules" + if not gitmodules_path.is_file(): + return False + try: + content = gitmodules_path.read_text(encoding="utf-8", errors="ignore") + except OSError: + self.log( + "Unable to read .gitmodules. " + f"See {_USE_FIND_PACKAGE_DOC} for more information." + ) + return True + urls = _SUBMODULE_URL.findall(content) + if not urls: + # Non-empty .gitmodules without a parsable url: treat it as a submodule. + return len(content.strip()) > 0 + return any(not _ALLOWED_SUBMODULE_URL.match(url) for url in urls) + + def _cmake_files_to_check(self): + cmake_files = [] + + root_cmake = self.repo_path / "CMakeLists.txt" + if root_cmake.is_file(): + cmake_files.append(root_cmake) + + for cmake_file in self.repo_path.glob("*.cmake"): + cmake_files.append(cmake_file) + + for subdir in ("tests", "examples"): + subdir_path = self.repo_path / subdir + if not subdir_path.is_dir(): + continue + for cmake_file in subdir_path.rglob("*"): + if not cmake_file.is_file(): + continue + if "infra" in cmake_file.relative_to(self.repo_path).parts: + continue + if cmake_file.name == "CMakeLists.txt" or cmake_file.suffix == ".cmake": + cmake_files.append(cmake_file) + + return sorted(set(cmake_files)) + + def check(self): + if self._has_disallowed_submodules(): + self.log( + "The repository should fetch dependencies via find_package, not git submodules. " + "Please replace the git submodules (other than mpark/wg21) with find_package. " + f"See {_USE_FIND_PACKAGE_DOC} for more information." + ) + return False + + for cmake_file in self._cmake_files_to_check(): + try: + content = cmake_file.read_text(encoding="utf-8", errors="replace") + except OSError: + continue + + display_path = normalize_path_for_display(cmake_file, self.repo_path) + try: + uses_fetch_content = _has_fetch_content_declare(content) + except cmake_parser.error.CMakeParseError: + self.log( + f"Unable to parse '{display_path}'; skipping it. " + f"See {_USE_FIND_PACKAGE_DOC} for more information." + ) + continue + + if uses_fetch_content: + self.log( + f"The file '{display_path}' uses FetchContent_Declare to fetch dependencies. " + "Dependencies should be fetched via find_package instead. " + f"See {_USE_FIND_PACKAGE_DOC} for more information." + ) + return False + + return True + + def fix(self): + self.log( + "Please fetch dependencies via find_package instead of git submodules or FetchContent. " + f"See {_USE_FIND_PACKAGE_DOC} for more information." + ) + return False + + @register_beman_standard_check("cmake.project_name") class CMakeProjectNameCheck(CMakeBaseCheck): def __init__(self, repo_info, beman_standard_check_config): @@ -370,117 +480,6 @@ def fix(self): return False -_USE_FIND_PACKAGE_DOC = ( - "https://github.com/bemanproject/beman/blob/main/docs/beman_standard.md" - "#cmakeuse_find_package" -) - - -# Known exception from repository.disallow_git_submodules: the mpark/wg21 -# paper framework is not a C++ dependency, so it is not fetched via CMake. -_ALLOWED_SUBMODULE_URL = re.compile(r"^https://github\.com/mpark/wg21(?:\.git)?/?$") -_SUBMODULE_URL = re.compile(r"^\s*url\s*=\s*(\S+)\s*$", re.MULTILINE) - - -def _has_fetch_content_declare(content): - ast = cmake_parser.parser.parse_raw(content, skip_comments=True) - return any( - hasattr(item, "identifier") - and item.identifier.lower() == "fetchcontent_declare" - for item in ast - ) - - -@register_beman_standard_check("cmake.use_find_package") -class CMakeUseFindPackageCheck(BaseCheck): - def __init__(self, repo_info, beman_standard_check_config): - super().__init__(repo_info, beman_standard_check_config) - - def _has_disallowed_submodules(self): - gitmodules_path = self.repo_path / ".gitmodules" - if not gitmodules_path.is_file(): - return False - try: - content = gitmodules_path.read_text(encoding="utf-8", errors="ignore") - except OSError: - self.log( - "Unable to read .gitmodules. " - f"See {_USE_FIND_PACKAGE_DOC} for more information." - ) - return True - urls = _SUBMODULE_URL.findall(content) - if not urls: - # Non-empty .gitmodules without a parsable url: treat it as a submodule. - return len(content.strip()) > 0 - return any(not _ALLOWED_SUBMODULE_URL.match(url) for url in urls) - - def _cmake_files_to_check(self): - cmake_files = [] - - root_cmake = self.repo_path / "CMakeLists.txt" - if root_cmake.is_file(): - cmake_files.append(root_cmake) - - for cmake_file in self.repo_path.glob("*.cmake"): - cmake_files.append(cmake_file) - - for subdir in ("tests", "examples"): - subdir_path = self.repo_path / subdir - if not subdir_path.is_dir(): - continue - for cmake_file in subdir_path.rglob("*"): - if not cmake_file.is_file(): - continue - if "infra" in cmake_file.relative_to(self.repo_path).parts: - continue - if cmake_file.name == "CMakeLists.txt" or cmake_file.suffix == ".cmake": - cmake_files.append(cmake_file) - - return sorted(set(cmake_files)) - - def check(self): - if self._has_disallowed_submodules(): - self.log( - "The repository should fetch dependencies via find_package, not git submodules. " - "Please remove .gitmodules and use find_package instead. " - f"See {_USE_FIND_PACKAGE_DOC} for more information." - ) - return False - - for cmake_file in self._cmake_files_to_check(): - try: - content = cmake_file.read_text() - except OSError: - continue - - display_path = normalize_path_for_display(cmake_file, self.repo_path) - try: - uses_fetch_content = _has_fetch_content_declare(content) - except cmake_parser.error.CMakeParseError: - self.log( - f"Unable to parse '{display_path}'; skipping it. " - f"See {_USE_FIND_PACKAGE_DOC} for more information." - ) - continue - - if uses_fetch_content: - self.log( - f"The file '{display_path}' uses FetchContent_Declare to fetch dependencies. " - "Dependencies should be fetched via find_package instead. " - f"See {_USE_FIND_PACKAGE_DOC} for more information." - ) - return False - - return True - - def fix(self): - self.log( - "Please fetch dependencies via find_package instead of git submodules or FetchContent. " - f"See {_USE_FIND_PACKAGE_DOC} for more information." - ) - return False - - # TODO cmake.passive_targets diff --git a/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v6/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v6/CMakeLists.txt new file mode 100644 index 00000000..f8622937 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v6/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.30...4.3) + +project( + beman.exemplar + DESCRIPTION "A Beman Library Exemplar" + LANGUAGES CXX + VERSION 0.1.0 +) + +include(infra/cmake/beman-install-library.cmake) + +add_library(beman.exemplar INTERFACE) +add_library(beman::exemplar ALIAS beman.exemplar) + +if(BEMAN_EXEMPLAR_BUILD_TESTS) + enable_testing() + add_subdirectory(tests/beman/exemplar) +endif() + +if(BEMAN_EXEMPLAR_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() diff --git a/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v6/deps.cmake b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v6/deps.cmake new file mode 100644 index 00000000..1425363d --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/invalid/repo-exemplar-v6/deps.cmake @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +include(FetchContent) + +fetchcontent_declare( + task + GIT_REPOSITORY https://github.com/bemanproject/task + GIT_TAG main +) diff --git a/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v4/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v4/CMakeLists.txt new file mode 100644 index 00000000..f8622937 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v4/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.30...4.3) + +project( + beman.exemplar + DESCRIPTION "A Beman Library Exemplar" + LANGUAGES CXX + VERSION 0.1.0 +) + +include(infra/cmake/beman-install-library.cmake) + +add_library(beman.exemplar INTERFACE) +add_library(beman::exemplar ALIAS beman.exemplar) + +if(BEMAN_EXEMPLAR_BUILD_TESTS) + enable_testing() + add_subdirectory(tests/beman/exemplar) +endif() + +if(BEMAN_EXEMPLAR_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() diff --git a/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v4/tests/beman/exemplar/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v4/tests/beman/exemplar/CMakeLists.txt new file mode 100644 index 00000000..a477da6f --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v4/tests/beman/exemplar/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Previously fetched with: +# FetchContent_Declare( +# GTest +# GIT_REPOSITORY https://github.com/google/googletest.git +# ) +find_package(GTest REQUIRED) + +add_executable(beman.exemplar.tests.identity) diff --git a/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v5/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v5/CMakeLists.txt new file mode 100644 index 00000000..f8622937 --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v5/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.30...4.3) + +project( + beman.exemplar + DESCRIPTION "A Beman Library Exemplar" + LANGUAGES CXX + VERSION 0.1.0 +) + +include(infra/cmake/beman-install-library.cmake) + +add_library(beman.exemplar INTERFACE) +add_library(beman::exemplar ALIAS beman.exemplar) + +if(BEMAN_EXEMPLAR_BUILD_TESTS) + enable_testing() + add_subdirectory(tests/beman/exemplar) +endif() + +if(BEMAN_EXEMPLAR_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() diff --git a/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v5/tests/beman/exemplar/CMakeLists.txt b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v5/tests/beman/exemplar/CMakeLists.txt new file mode 100644 index 00000000..74cb362c --- /dev/null +++ b/tests/lib/checks/beman_standard/cmake/data/valid/repo-exemplar-v5/tests/beman/exemplar/CMakeLists.txt @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +find_package(GTest REQUIRED) + +add_executable(beman.exemplar.tests.identity diff --git a/tests/lib/checks/beman_standard/cmake/test_cmake.py b/tests/lib/checks/beman_standard/cmake/test_cmake.py index 99837d87..1d820b1a 100644 --- a/tests/lib/checks/beman_standard/cmake/test_cmake.py +++ b/tests/lib/checks/beman_standard/cmake/test_cmake.py @@ -11,13 +11,13 @@ # Actual tested checks. from beman_tidy.lib.checks.beman_standard.cmake import ( CMakeDefaultCheck, + CMakeUseFindPackageCheck, CMakeProjectNameCheck, CMakeLibraryNameCheck, CMakeLibraryAliasCheck, CMakeTargetNamesCheck, CMakeSkipTestsCheck, CMakeSkipExamplesCheck, - CMakeUseFindPackageCheck, ) test_data_prefix = "tests/lib/checks/beman_standard/cmake/data" @@ -72,6 +72,70 @@ def test__cmake_default__fix_inplace(repo_info, beman_standard_check_config): pass +def test__cmake_use_find_package__valid(repo_info, beman_standard_check_config): + """ + Test that repositories without git submodules (other than the wg21 exception) + and without FetchContent outside infra/ pass the check. + """ + valid_repo_paths = [ + # Repo with find_package dependencies and no .gitmodules + Path(f"{valid_prefix}/repo-exemplar-v1/"), + # Repo with FetchContent only under infra/ (excluded from the check) + Path(f"{valid_prefix}/repo-exemplar-v2/"), + # Repo whose .gitmodules only contains the allowed mpark/wg21 submodule + Path(f"{valid_prefix}/repo-exemplar-v3/"), + # tests/ CMakeLists.txt only mentions FetchContent_Declare in a comment + Path(f"{valid_prefix}/repo-exemplar-v4/"), + # tests/ CMakeLists.txt cannot be parsed; it is skipped, not reported + Path(f"{valid_prefix}/repo-exemplar-v5/"), + ] + + run_check_for_each_path( + True, + valid_repo_paths, + CMakeUseFindPackageCheck, + repo_info, + beman_standard_check_config, + ) + + +def test__cmake_use_find_package__invalid(repo_info, beman_standard_check_config): + """ + Test that repositories with .gitmodules or FetchContent fail the check. + """ + invalid_repo_paths = [ + # Repo with a non-empty .gitmodules file + Path(f"{invalid_prefix}/repo-exemplar-v1/"), + # Root CMakeLists.txt uses FetchContent_Declare + Path(f"{invalid_prefix}/repo-exemplar-v2/"), + # tests/ CMakeLists.txt uses FetchContent_Declare + Path(f"{invalid_prefix}/repo-exemplar-v3/"), + # examples/ CMakeLists.txt uses FetchContent_Declare + Path(f"{invalid_prefix}/repo-exemplar-v4/"), + # .gitmodules contains wg21 plus another submodule + Path(f"{invalid_prefix}/repo-exemplar-v5/"), + # Root deps.cmake uses lowercase fetchcontent_declare + Path(f"{invalid_prefix}/repo-exemplar-v6/"), + ] + + run_check_for_each_path( + False, + invalid_repo_paths, + CMakeUseFindPackageCheck, + repo_info, + beman_standard_check_config, + ) + + +@pytest.mark.skip(reason="not implemented") +def test__cmake_use_find_package__fix_inplace(repo_info, beman_standard_check_config): + """ + Test that the fix method corrects invalid dependency fetching. + Note: Skipping this test as it is not implemented. + """ + pass + + def test__cmake_project_name__valid(repo_info, beman_standard_check_config): """ Test that a valid CMakeLists.txt file passes the cmake.project_name check. @@ -363,61 +427,3 @@ def test__cmake_skip_examples__fix_inplace(repo_info, beman_standard_check_confi Note: Skipping this test as it is not implemented. """ pass - - -def test__cmake_use_find_package__valid(repo_info, beman_standard_check_config): - """ - Test that repositories without git submodules (other than the wg21 exception) - and without FetchContent outside infra/ pass the check. - """ - valid_repo_paths = [ - # Repo with find_package dependencies and no .gitmodules - Path(f"{valid_prefix}/repo-exemplar-v1/"), - # Repo with FetchContent only under infra/ (excluded from the check) - Path(f"{valid_prefix}/repo-exemplar-v2/"), - # Repo whose .gitmodules only contains the allowed mpark/wg21 submodule - Path(f"{valid_prefix}/repo-exemplar-v3/"), - ] - - run_check_for_each_path( - True, - valid_repo_paths, - CMakeUseFindPackageCheck, - repo_info, - beman_standard_check_config, - ) - - -def test__cmake_use_find_package__invalid(repo_info, beman_standard_check_config): - """ - Test that repositories with .gitmodules or FetchContent fail the check. - """ - invalid_repo_paths = [ - # Repo with a non-empty .gitmodules file - Path(f"{invalid_prefix}/repo-exemplar-v1/"), - # Root CMakeLists.txt uses FetchContent_Declare - Path(f"{invalid_prefix}/repo-exemplar-v2/"), - # tests/ CMakeLists.txt uses FetchContent_Declare - Path(f"{invalid_prefix}/repo-exemplar-v3/"), - # examples/ CMakeLists.txt uses FetchContent_Declare - Path(f"{invalid_prefix}/repo-exemplar-v4/"), - # .gitmodules contains wg21 plus another submodule - Path(f"{invalid_prefix}/repo-exemplar-v5/"), - ] - - run_check_for_each_path( - False, - invalid_repo_paths, - CMakeUseFindPackageCheck, - repo_info, - beman_standard_check_config, - ) - - -@pytest.mark.skip(reason="not implemented") -def test__cmake_use_find_package__fix_inplace(repo_info, beman_standard_check_config): - """ - Test that the fix method corrects invalid dependency fetching. - Note: Skipping this test as it is not implemented. - """ - pass