Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLeitwolf2026-11-16 14:48:52 +0300
committerGitHub2026-11-16 14:48:52 +0300
commit57dc4f2fee6881884b10085e85927a0c1710ea61 (patch)
treef04d44d03b84c93b0383dfbce492b32b1c23dc76
parent48a52e544ae90d6767240a8b5f030350795fbd7b (diff)
parent5a63d9c746daa1748db7622a5e3effb9ca5c4b40 (diff)
downloadcatch3-57dc4f2fee6881884b10085e85927a0c1710ea61.tar.gz
Merge pull request #48 from Progmasoft/build/bcrHEADdevel
Prepare the Bazel Central Registry entry as progmasoft_catch3
-rw-r--r--.bazelignore5
-rw-r--r--.bcr/metadata.template.json14
-rw-r--r--.bcr/presubmit.yml17
-rw-r--r--.bcr/source.template.json5
-rw-r--r--.github/workflows/bazel-builds.yml29
-rw-r--r--.github/workflows/publish-to-bcr.yml35
-rw-r--r--.gitignore1
-rw-r--r--MODULE.bazel2
-rw-r--r--docs/progmasoft-catch3.md18
-rw-r--r--tests/Progmasoft/BazelModule/.bazelrc12
-rw-r--r--tests/Progmasoft/BazelModule/BUILD.bazel16
-rw-r--r--tests/Progmasoft/BazelModule/MODULE.bazel14
-rw-r--r--tests/Progmasoft/BazelModule/OwnMain.tests.cpp31
-rw-r--r--tests/Progmasoft/BazelModule/WithMain.tests.cpp29
-rw-r--r--tools/Versions.cpp4
15 files changed, 228 insertions, 4 deletions
diff --git a/.bazelignore b/.bazelignore
new file mode 100644
index 00000000..ec2c63a6
--- /dev/null
+++ b/.bazelignore
@@ -0,0 +1,5 @@
+# Copyright (c) 2026 Progmasoft.
+# SPDX-License-Identifier: LGPL-3.0-or-later
+
+# A module of its own, built by CI and by the Bazel Central Registry.
+tests/Progmasoft/BazelModule
diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json
new file mode 100644
index 00000000..3f80ce9a
--- /dev/null
+++ b/.bcr/metadata.template.json
@@ -0,0 +1,14 @@
+{
+ "homepage": "https://github.com/Progmasoft/catch3",
+ "maintainers": [
+ {
+ "name": "Leitwolf11",
+ "email": "[email protected]",
+ "github": "Leitwolf11",
+ "github_user_id": 238872178
+ }
+ ],
+ "repository": ["github:Progmasoft/catch3"],
+ "versions": [],
+ "yanked_versions": {}
+}
diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml
new file mode 100644
index 00000000..a29cc665
--- /dev/null
+++ b/.bcr/presubmit.yml
@@ -0,0 +1,17 @@
+# SPDX-FileCopyrightText: 2026 Progmasoft <[email protected]>
+# SPDX-License-Identifier: LGPL-3.0-or-later
+
+# The Bazel Central Registry builds and runs the test module, which depends on
+# progmasoft_catch3 as a user's module does, on each platform and Bazel line.
+bcr_test_module:
+ module_path: tests/Progmasoft/BazelModule
+ matrix:
+ platform: [debian11, ubuntu2204, macos, macos_arm64, windows]
+ bazel: [8.x, 9.x]
+ tasks:
+ run_test_module:
+ name: Run the test module
+ platform: ${{ platform }}
+ bazel: ${{ bazel }}
+ test_targets:
+ - //...
diff --git a/.bcr/source.template.json b/.bcr/source.template.json
new file mode 100644
index 00000000..e68c53b4
--- /dev/null
+++ b/.bcr/source.template.json
@@ -0,0 +1,5 @@
+{
+ "integrity": "",
+ "strip_prefix": "{REPO}-{TAG}",
+ "url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz"
+}
diff --git a/.github/workflows/bazel-builds.yml b/.github/workflows/bazel-builds.yml
index 8033e3d7..f0672a7a 100644
--- a/.github/workflows/bazel-builds.yml
+++ b/.github/workflows/bazel-builds.yml
@@ -42,3 +42,32 @@ jobs:
run: bazel test tests/Progmasoft:property_tests
env:
CC: clang
+
+ module:
+ name: Bazel ${{ matrix.bazel }} module on ${{ matrix.os }}
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [windows-2025-vs2026, ubuntu-26.04]
+ # bazel_compatibility in MODULE.bazel is >=8.0.0; the Bazel Central
+ # Registry runs the same test module on both lines.
+ bazel: [8.x, 9.x]
+
+ steps:
+ - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
+ with:
+ persist-credentials: false
+
+ - uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0
+ with:
+ bazelisk-cache: true
+ repository-cache: true
+
+ - name: Test the module as a user's module depends on it
+ working-directory: tests/Progmasoft/BazelModule
+ run: bazel test //...
+ shell: bash
+ env:
+ USE_BAZEL_VERSION: ${{ matrix.bazel }}
+ BAZEL_SH: ${{ runner.os == 'Windows' && 'C:\Program Files\Git\bin\bash.exe' || '' }}
diff --git a/.github/workflows/publish-to-bcr.yml b/.github/workflows/publish-to-bcr.yml
new file mode 100644
index 00000000..beac20a0
--- /dev/null
+++ b/.github/workflows/publish-to-bcr.yml
@@ -0,0 +1,35 @@
+# SPDX-FileCopyrightText: 2026 Progmasoft <[email protected]>
+# SPDX-License-Identifier: LGPL-3.0-or-later
+
+# Opens the pull request that adds a release to the Bazel Central Registry as
+# progmasoft_catch3, from the templates in .bcr/. The registry builds the test
+# module of .bcr/presubmit.yml before it accepts the version.
+name: Publish to BCR
+
+on:
+ release:
+ types: [published]
+ workflow_dispatch:
+ inputs:
+ tag_name:
+ description: The release tag, such as catch3-0.5.0
+ required: true
+ type: string
+
+permissions: {}
+
+jobs:
+ publish:
+ if: startsWith(github.event.release.tag_name || inputs.tag_name, 'catch3-')
+ uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@3b1b972e41764b9a7498cf9128ed4ed2258a3687 # v1.6.0
+ with:
+ tag_name: ${{ github.event.release.tag_name || inputs.tag_name }}
+ tag_prefix: catch3-
+ registry_fork: Leitwolf11/bazel-central-registry
+ # BCR accepts source attestations only from bazel-contrib's release
+ # workflow; Catch3's releases are made without it.
+ attest: false
+ permissions:
+ contents: write # the reusable workflow may add files to the release
+ secrets:
+ publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 0c36403a..1f6b523f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,7 @@ cmake-build-*
benchmark-dir
**/CMakeUserPresets.json
/bazel-*
+/tests/Progmasoft/BazelModule/bazel-*
build-fuzzers
debug-build
.vscode
diff --git a/MODULE.bazel b/MODULE.bazel
index 6e0fb394..d64c1bb0 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,4 +1,4 @@
-module(name = "catch3", version = "0.4.0")
+module(name = "progmasoft_catch3", version = "0.4.0", bazel_compatibility = [">=8.0.0"])
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "rules_cc", version = "0.2.17")
diff --git a/docs/progmasoft-catch3.md b/docs/progmasoft-catch3.md
index ee222e6d..05948fd4 100644
--- a/docs/progmasoft-catch3.md
+++ b/docs/progmasoft-catch3.md
@@ -179,8 +179,22 @@ find_package(Catch3 0.3 CONFIG REQUIRED)
target_link_libraries(MyTests PRIVATE Catch3::Catch3WithMain)
```
-The Bazel target is `//:catch3`; its tests are
-`//tests/Progmasoft:property_tests`. Bazel is the primary
+In the Bazel Central Registry, from 0.5.0 on, the module is
+`progmasoft_catch3`, for Bazel 8 and later:
+
+```starlark
+bazel_dep(name = "progmasoft_catch3", version = "0.5.0")
+```
+
+Its targets are `@progmasoft_catch3//:catch3` and
+`@progmasoft_catch3//:catch3_main`, which brings `main`. Code that includes
+the headers is C++17 or later, so a module that is not already set to it
+passes `--cxxopt=-std=c++17` (`--cxxopt=/std:c++17` with MSVC, which defaults
+to C++14).
+
+In this repository the Bazel target is `//:catch3`; its tests are
+`//tests/Progmasoft:property_tests`, and `tests/Progmasoft/BazelModule` is a
+module that depends on Catch3 as a user's does. Bazel is the primary
build path; CMake, Meson, Xmake, and Premake are also maintained as alternate
ways to build the same engine and property tests. Their root files are
`CMakeLists.txt`, `meson.build`, `xmake.lua`, and `premake5.lua`. Xmake and
diff --git a/tests/Progmasoft/BazelModule/.bazelrc b/tests/Progmasoft/BazelModule/.bazelrc
new file mode 100644
index 00000000..b99caaba
--- /dev/null
+++ b/tests/Progmasoft/BazelModule/.bazelrc
@@ -0,0 +1,12 @@
+# Copyright (c) 2026 Progmasoft.
+# SPDX-License-Identifier: LGPL-3.0-or-later
+
+# Code that includes the headers of Catch3 is C++17 or later, as it must be in
+# a user's module; MSVC defaults to C++14.
+common --enable_platform_specific_config
+build:linux --cxxopt=-std=c++17
+build:macos --cxxopt=-std=c++17
+build:windows --cxxopt=/std:c++17
+
+# The lockfile is the user's; this module keeps none.
+common --lockfile_mode=off
diff --git a/tests/Progmasoft/BazelModule/BUILD.bazel b/tests/Progmasoft/BazelModule/BUILD.bazel
new file mode 100644
index 00000000..c95b5ddf
--- /dev/null
+++ b/tests/Progmasoft/BazelModule/BUILD.bazel
@@ -0,0 +1,16 @@
+# Copyright (c) 2026 Progmasoft.
+# SPDX-License-Identifier: LGPL-3.0-or-later
+load("@rules_cc//cc:defs.bzl", "cc_test")
+
+# Each public name of the module, as a user links it.
+cc_test(
+ name = "with_main",
+ srcs = ["WithMain.tests.cpp"],
+ deps = ["@progmasoft_catch3//:catch3_main"],
+)
+
+cc_test(
+ name = "own_main",
+ srcs = ["OwnMain.tests.cpp"],
+ deps = ["@progmasoft_catch3//:catch3"],
+)
diff --git a/tests/Progmasoft/BazelModule/MODULE.bazel b/tests/Progmasoft/BazelModule/MODULE.bazel
new file mode 100644
index 00000000..fa0d4bdb
--- /dev/null
+++ b/tests/Progmasoft/BazelModule/MODULE.bazel
@@ -0,0 +1,14 @@
+# Copyright (c) 2026 Progmasoft.
+# SPDX-License-Identifier: LGPL-3.0-or-later
+
+# A module that uses progmasoft_catch3 as a user's does. CI builds it from this
+# checkout; the Bazel Central Registry builds it from the published version.
+module(name = "progmasoft_catch3_test_module")
+
+bazel_dep(name = "progmasoft_catch3")
+local_path_override(
+ module_name = "progmasoft_catch3",
+ path = "../../..",
+)
+
+bazel_dep(name = "rules_cc", version = "0.2.17")
diff --git a/tests/Progmasoft/BazelModule/OwnMain.tests.cpp b/tests/Progmasoft/BazelModule/OwnMain.tests.cpp
new file mode 100644
index 00000000..92c4d711
--- /dev/null
+++ b/tests/Progmasoft/BazelModule/OwnMain.tests.cpp
@@ -0,0 +1,31 @@
+// Copyright (c) 2026 Progmasoft.
+// SPDX-License-Identifier: LGPL-3.0-or-later
+
+// Tests linked with @progmasoft_catch3//:catch3, with a main of their own.
+#include <Progmasoft/Catch3/Session.hpp>
+#include <Progmasoft/Catch3/TestMacros.hpp>
+#include <algorithm>
+#include <vector>
+
+TEST_CASE("Sections run against a fresh fixture", "[module]")
+{
+ std::vector<int> values{ 3, 1, 2 };
+
+ SECTION("sorting orders the values")
+ {
+ std::sort(values.begin(), values.end());
+ REQUIRE(std::is_sorted(values.begin(), values.end()));
+ CHECK(values.front() < values.back());
+ }
+ SECTION("each section starts from the same values")
+ {
+ CHECK_FALSE(std::is_sorted(values.begin(), values.end()));
+ }
+}
+
+int
+main(int argc, char **argv)
+{
+ Catch::Session session;
+ return session.run(argc, argv);
+}
diff --git a/tests/Progmasoft/BazelModule/WithMain.tests.cpp b/tests/Progmasoft/BazelModule/WithMain.tests.cpp
new file mode 100644
index 00000000..60f67ed1
--- /dev/null
+++ b/tests/Progmasoft/BazelModule/WithMain.tests.cpp
@@ -0,0 +1,29 @@
+// Copyright (c) 2026 Progmasoft.
+// SPDX-License-Identifier: LGPL-3.0-or-later
+
+// Tests linked with @progmasoft_catch3//:catch3_main, which brings main.
+#include <Progmasoft/Catch3/Generators/Generators.hpp>
+#include <Progmasoft/Catch3/TestMacros.hpp>
+#include <string>
+
+namespace
+{
+ std::string
+ Repeat(const std::string &text, int count)
+ {
+ std::string result;
+ for (int i = 0; i < count; ++i)
+ {
+ result += text;
+ }
+ return result;
+ }
+} // namespace
+
+TEST_CASE("Generated values reach the test", "[module]")
+{
+ const int count = GENERATE(0, 1, 3);
+ const std::string repeated = Repeat("ab", count);
+ REQUIRE(repeated.size() == static_cast<std::size_t>(2 * count));
+ CHECK(repeated.find("ba") == (count > 1 ? 1U : std::string::npos));
+}
diff --git a/tools/Versions.cpp b/tools/Versions.cpp
index 217702cf..0d4c6682 100644
--- a/tools/Versions.cpp
+++ b/tools/Versions.cpp
@@ -89,7 +89,9 @@ namespace Progmasoft::Catch3::Tools
{
static constexpr std::array<VersionSite, 5> kSites{ {
{ "CMakeLists.txt", "\n VERSION ", "\n" },
- { "MODULE.bazel", "module(name = \"catch3\", version = \"", "\"" },
+ { "MODULE.bazel",
+ "module(name = \"progmasoft_catch3\", version = \"",
+ "\"" },
{ "meson.build", "\n version: '", "'" },
{ "xmake.lua", "\nset_version(\"", "\"" },
{ kVersionHeader, "kVersion = \"", "\"" },