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

summaryrefslogtreecommitdiffhomepage
path: root/tools/Tools.tests.cpp
diff options
context:
space:
mode:
authorLeitwolf112026-11-01 22:58:30 +0300
committerLeitwolf112026-11-01 22:58:30 +0300
commite66db1cf17714be2ebfeab37670ef3d8965fc7cc (patch)
tree88a8b55a14e9bc6152608662d062c1624c2863cf /tools/Tools.tests.cpp
parente32c9d107274f42b9cca700475404c80e96533c5 (diff)
downloadcatch3-e66db1cf17714be2ebfeab37670ef3d8965fc7cc.tar.gz
Answer the review of the tools
repo_info starts Git in the checkout with fixed commands, so a shell never reads a path, reports an unknown state as null rather than clean, and counts only files it can start. third_party reads every archive before it changes a file and refuses two modes. version checks that the sources make a distribution, computes every place before writing any, and release_notes finds a three-number heading for a version with D = 0.
Diffstat (limited to 'tools/Tools.tests.cpp')
-rw-r--r--tools/Tools.tests.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/Tools.tests.cpp b/tools/Tools.tests.cpp
index 51dca951..90e9b129 100644
--- a/tools/Tools.tests.cpp
+++ b/tools/Tools.tests.cpp
@@ -1,6 +1,7 @@
// Copyright (c) 2026 Progmasoft.
// SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-2.0
+#include <Progmasoft/Catch3/Matchers/String.hpp>
#include <Progmasoft/Catch3/TestMacros.hpp>
#include <string>
@@ -10,6 +11,7 @@
#include "tools/Versions.hpp"
using namespace Progmasoft::Catch3::Tools;
+using Catch::Matchers::ContainsSubstring;
TEST_CASE("Versions have three or four numbers", "[tools]")
{
@@ -55,6 +57,25 @@ TEST_CASE("Release notes are found by their heading", "[tools]")
CHECK_FALSE(ReleaseNotesOf(notes, "0.3"));
}
+TEST_CASE("A release with D = 0 may be headed by three numbers", "[tools]")
+{
+ const std::string notes = "# Notes\n\n## 0.4.0\n\nThree.\n";
+ CHECK(ReleaseNotesOf(notes, "0.4.0") == "Three.\n");
+ CHECK(ReleaseNotesOf(notes, "0.4.0.0") == "Three.\n");
+ CHECK_FALSE(ReleaseNotesOf(notes, "0.4.0.1"));
+}
+
+TEST_CASE("Git that could not say is not a clean checkout", "[tools]")
+{
+ RepositoryReport report;
+ report.GitError = "unreadable";
+ CHECK_THAT(ReportToJson(report), ContainsSubstring("\"dirty\": null"));
+ CHECK_THAT(FormatReport(report),
+ ContainsSubstring("Tracked changes: unknown"));
+ report.Dirty = false;
+ CHECK_THAT(ReportToJson(report), ContainsSubstring("\"dirty\": false"));
+}
+
TEST_CASE("Includes are read as they are written", "[tools]")
{
const auto angled = ParseInclude(" #include <a/b.hpp> // why\n");