Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Finish the move to C++17 in POSIX code and the amalgamated files

A lambda in the POSIX half of Process.cpp captured a structured binding,
which needs C++20 and which a Windows build never compiles. The files in
extras still held the C++20 sources, so they are generated again, and the
generator no longer says the runner needs C++20.
Commit
afe91797e9d50cd4712d3694a2e5fedfc0b966b1
Author
Leitwolf11 ·
Parents
653dde1cc5a2

Files · Download .tar.gz

Changes

 extras/catch_amalgamated.cpp              | 48 +++++++++++++++++++------------
 extras/catch_amalgamated.hpp              |  4 +--
 extras/catch_amalgamated_third_party.hpp  |  2 +-
 src/Progmasoft/Runner/Process.cpp         |  8 ++++--
 tools/scripts/generateAmalgamatedFiles.py |  2 +-
 5 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/extras/catch_amalgamated.cpp b/extras/catch_amalgamated.cpp
index fc87bf40..3b15cc2d 100644
--- a/extras/catch_amalgamated.cpp
+++ b/extras/catch_amalgamated.cpp
@@ -7,14 +7,14 @@
 // SPDX-License-Identifier: BSL-1.0
 
 //  Catch3 v0.3.0, on the Catch2 v3.16.1 engine
-//  Generated: 2026-10-29 19:30:41.305371
+//  Generated: 2026-10-31 13:33:37.309963
 //  ----------------------------------------------------------
 //  This file is an amalgamation of multiple different files.
 //  You probably shouldn't edit it directly.
 //
 //  The parts that come from src/Progmasoft, the Catch3 runner, keep
 //  their own copyright and license lines (MPL-2.0 WITH
-//  AdditionRef-Progmasoft-Exception-1.1). The runner needs C++20.
+//  AdditionRef-Progmasoft-Exception-1.1). The runner needs C++17.
 //  ----------------------------------------------------------
 
 #include "catch_amalgamated.hpp"
@@ -14663,18 +14663,22 @@ namespace Progmasoft::Catch3::Runner
             for (const auto &[name, value] : additions)
             {
                 const std::wstring wideName = Widen(name);
-                std::erase_if(entries, [&](const std::wstring &entry) {
-                    // A leading '=' marks the hidden per-drive variables.
-                    const auto equals = entry.find(L'=', 1);
-                    return equals == wideName.size()
-                           && CompareStringOrdinal(
-                                  entry.data(),
-                                  static_cast<int>(equals),
-                                  wideName.data(),
-                                  static_cast<int>(wideName.size()),
-                                  TRUE)
-                                  == CSTR_EQUAL;
-                });
+                const auto removed = std::remove_if(
+                    entries.begin(),
+                    entries.end(),
+                    [&](const std::wstring &entry) {
+                        // A leading '=' marks the hidden per-drive variables.
+                        const auto equals = entry.find(L'=', 1);
+                        return equals == wideName.size()
+                               && CompareStringOrdinal(
+                                      entry.data(),
+                                      static_cast<int>(equals),
+                                      wideName.data(),
+                                      static_cast<int>(wideName.size()),
+                                      TRUE)
+                                      == CSTR_EQUAL;
+                    });
+                entries.erase(removed, entries.end());
                 entries.push_back(wideName + L"=" + Widen(value));
             }
             std::wstring block;
@@ -15429,11 +15433,17 @@ namespace Progmasoft::Catch3::Runner
         }
         for (const auto &[name, value] : options.environment)
         {
-            std::erase_if(environmentStorage, [&](const std::string &entry) {
-                return entry.size() > name.size()
-                       && entry.compare(0, name.size(), name) == 0
-                       && entry[name.size()] == '=';
-            });
+            // A lambda cannot capture a structured binding in C++17.
+            const std::string &variable = name;
+            const auto removed = std::remove_if(
+                environmentStorage.begin(),
+                environmentStorage.end(),
+                [&](const std::string &entry) {
+                    return entry.size() > variable.size()
+                           && entry.compare(0, variable.size(), variable) == 0
+                           && entry[variable.size()] == '=';
+                });
+            environmentStorage.erase(removed, environmentStorage.end());
             environmentStorage.push_back(name + "=" + value);
         }
         std::vector<char *> environment;
diff --git a/extras/catch_amalgamated.hpp b/extras/catch_amalgamated.hpp
index 09e99fb2..18d52356 100644
--- a/extras/catch_amalgamated.hpp
+++ b/extras/catch_amalgamated.hpp
@@ -7,14 +7,14 @@
 // SPDX-License-Identifier: BSL-1.0
 
 //  Catch3 v0.3.0, on the Catch2 v3.16.1 engine
-//  Generated: 2026-10-29 19:30:41.164140
+//  Generated: 2026-10-31 13:33:37.220554
 //  ----------------------------------------------------------
 //  This file is an amalgamation of multiple different files.
 //  You probably shouldn't edit it directly.
 //
 //  The parts that come from src/Progmasoft, the Catch3 runner, keep
 //  their own copyright and license lines (MPL-2.0 WITH
-//  AdditionRef-Progmasoft-Exception-1.1). The runner needs C++20.
+//  AdditionRef-Progmasoft-Exception-1.1). The runner needs C++17.
 //  ----------------------------------------------------------
 #ifndef CATCH_AMALGAMATED_HPP_INCLUDED
 #define CATCH_AMALGAMATED_HPP_INCLUDED
diff --git a/extras/catch_amalgamated_third_party.hpp b/extras/catch_amalgamated_third_party.hpp
index f5961365..3462ff20 100644
--- a/extras/catch_amalgamated_third_party.hpp
+++ b/extras/catch_amalgamated_third_party.hpp
@@ -1,5 +1,5 @@
 // Catch3 v0.3.0: yyjson and pugixml for catch_amalgamated.cpp
-// Generated: 2026-10-29 19:10:35.543593
+// Generated: 2026-10-31 13:33:37.396913
 // ----------------------------------------------------------
 // This file is an amalgamation of src/Progmasoft/Runner/Yyjson.inl,
 // src/Progmasoft/PugiXml.inl and the libraries they include from
diff --git a/src/Progmasoft/Runner/Process.cpp b/src/Progmasoft/Runner/Process.cpp
index d0b5b512..585822f3 100644
--- a/src/Progmasoft/Runner/Process.cpp
+++ b/src/Progmasoft/Runner/Process.cpp
@@ -961,13 +961,15 @@ namespace Progmasoft::Catch3::Runner
         }
         for (const auto &[name, value] : options.environment)
         {
+            // A lambda cannot capture a structured binding in C++17.
+            const std::string &variable = name;
             const auto removed = std::remove_if(
                 environmentStorage.begin(),
                 environmentStorage.end(),
                 [&](const std::string &entry) {
-                    return entry.size() > name.size()
-                           && entry.compare(0, name.size(), name) == 0
-                           && entry[name.size()] == '=';
+                    return entry.size() > variable.size()
+                           && entry.compare(0, variable.size(), variable) == 0
+                           && entry[variable.size()] == '=';
                 });
             environmentStorage.erase(removed, environmentStorage.end());
             environmentStorage.push_back(name + "=" + value);
diff --git a/tools/scripts/generateAmalgamatedFiles.py b/tools/scripts/generateAmalgamatedFiles.py
index 7567a1c8..de47e11d 100755
--- a/tools/scripts/generateAmalgamatedFiles.py
+++ b/tools/scripts/generateAmalgamatedFiles.py
@@ -49,7 +49,7 @@ file_header = '''\
 //
 //  The parts that come from src/Progmasoft, the Catch3 runner, keep
 //  their own copyright and license lines (MPL-2.0 WITH
-//  AdditionRef-Progmasoft-Exception-1.1). The runner needs C++20.
+//  AdditionRef-Progmasoft-Exception-1.1). The runner needs C++17.
 //  ----------------------------------------------------------
 '''