From 924ac2e45535552eb5604bae75d15988b10899db Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sun, 19 Jul 2026 19:03:38 +0000 Subject: [PATCH 01/56] adding skeleton workspace for cpp implementation --- .devcontainer/cpp/devcontainer-lock.json | 77 +++++++++ .devcontainer/cpp/devcontainer.json | 30 ++++ .devcontainer/devcontainer.json | 22 +++ cpp/.clang-format | 164 +++++++++++++++++++ cpp/.clang-tidy | 19 +++ cpp/.clangd | 13 ++ cpp/.gitignore | 2 + cpp/CMakeLists.txt | 106 ++++++++++++ cpp/CMakePresets.json | 80 +++++++++ cpp/VERSION | 1 + cpp/cmake/dependencies.cpm.cmake | 78 +++++++++ cpp/include/cucumber/query/Query.hpp | 26 +++ cpp/src/query/Query.cpp | 13 ++ cpp/test/CMakeLists.txt | 21 +++ cpp/test/TestQuery.cpp | 198 +++++++++++++++++++++++ 15 files changed, 850 insertions(+) create mode 100644 .devcontainer/cpp/devcontainer-lock.json create mode 100644 .devcontainer/cpp/devcontainer.json create mode 100644 .devcontainer/devcontainer.json create mode 100644 cpp/.clang-format create mode 100644 cpp/.clang-tidy create mode 100644 cpp/.clangd create mode 100644 cpp/.gitignore create mode 100644 cpp/CMakeLists.txt create mode 100644 cpp/CMakePresets.json create mode 100644 cpp/VERSION create mode 100644 cpp/cmake/dependencies.cpm.cmake create mode 100644 cpp/include/cucumber/query/Query.hpp create mode 100644 cpp/src/query/Query.cpp create mode 100644 cpp/test/CMakeLists.txt create mode 100644 cpp/test/TestQuery.cpp diff --git a/.devcontainer/cpp/devcontainer-lock.json b/.devcontainer/cpp/devcontainer-lock.json new file mode 100644 index 00000000..e1adc04b --- /dev/null +++ b/.devcontainer/cpp/devcontainer-lock.json @@ -0,0 +1,77 @@ +{ + "features": { + "ghcr.io/devcontainer-community/devcontainer-features/apt-build-essential:latest": { + "version": "1.0.2", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/apt-build-essential@sha256:e396b09fdd04aef5ca8d35b9957547142761575575513d12fd8dc3c98c1728f8", + "integrity": "sha256:e396b09fdd04aef5ca8d35b9957547142761575575513d12fd8dc3c98c1728f8" + }, + "ghcr.io/devcontainer-community/devcontainer-features/ccache.dev:latest": { + "version": "1.0.2", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/ccache.dev@sha256:7288d603484d8c40c7d1c3b2c09ef7599fe50a9fcd8d5cf5f6118311e328f061", + "integrity": "sha256:7288d603484d8c40c7d1c3b2c09ef7599fe50a9fcd8d5cf5f6118311e328f061" + }, + "ghcr.io/devcontainer-community/devcontainer-features/clang-format:latest": { + "version": "1.0.2", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/clang-format@sha256:fd4a701f3d067e74caa5e8e229eaf13e45e85385dcac5ad81401c4e7678b735e", + "integrity": "sha256:fd4a701f3d067e74caa5e8e229eaf13e45e85385dcac5ad81401c4e7678b735e" + }, + "ghcr.io/devcontainer-community/devcontainer-features/clang-tidy:latest": { + "version": "1.0.2", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/clang-tidy@sha256:e120a41ca26d1638ffd5407a1c27cd75ee1b79c9bce1b7f17ede2fa20bc6d5b5", + "integrity": "sha256:e120a41ca26d1638ffd5407a1c27cd75ee1b79c9bce1b7f17ede2fa20bc6d5b5" + }, + "ghcr.io/devcontainer-community/devcontainer-features/cmake.org:latest": { + "version": "1.0.2", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/cmake.org@sha256:3f498a612eb69d006535cbe49bc7344108a7106e116cc85123d5e7bfcbe79a6e", + "integrity": "sha256:3f498a612eb69d006535cbe49bc7344108a7106e116cc85123d5e7bfcbe79a6e" + }, + "ghcr.io/devcontainer-community/devcontainer-features/collection-c-cpp:1": { + "version": "1.0.3", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/collection-c-cpp@sha256:f9c47d6a760dd17d54a96ba35958c40afea09d7b9b9975b2f44803469045c325", + "integrity": "sha256:f9c47d6a760dd17d54a96ba35958c40afea09d7b9b9975b2f44803469045c325", + "dependsOn": [ + "ghcr.io/devcontainer-community/devcontainer-features/cmake.org:latest", + "ghcr.io/devcontainer-community/devcontainer-features/ninja-build.org:latest", + "ghcr.io/devcontainer-community/devcontainer-features/sourceware.org-gdb:latest", + "ghcr.io/devcontainer-community/devcontainer-features/valgrind.org:latest", + "ghcr.io/devcontainer-community/devcontainer-features/ccache.dev:latest", + "ghcr.io/devcontainer-community/devcontainer-features/danmar-cppcheck:latest", + "ghcr.io/devcontainer-community/devcontainer-features/clang-format:latest", + "ghcr.io/devcontainer-community/devcontainer-features/clang-tidy:latest", + "ghcr.io/devcontainer-community/devcontainer-features/distcc.org:latest", + "ghcr.io/devcontainer-community/devcontainer-features/vcpkg.io:latest", + "ghcr.io/devcontainer-community/devcontainer-features/apt-build-essential:latest" + ] + }, + "ghcr.io/devcontainer-community/devcontainer-features/danmar-cppcheck:latest": { + "version": "1.0.2", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/danmar-cppcheck@sha256:7b1fa136d884d4f90b3696b20713753e5d5d2507c7b589a9adc37f784d2bdc56", + "integrity": "sha256:7b1fa136d884d4f90b3696b20713753e5d5d2507c7b589a9adc37f784d2bdc56" + }, + "ghcr.io/devcontainer-community/devcontainer-features/distcc.org:latest": { + "version": "1.0.2", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/distcc.org@sha256:7a1c3a4c76cd4200ae2773268eee9372c620f05806faa3c7b8bb487c57ffe391", + "integrity": "sha256:7a1c3a4c76cd4200ae2773268eee9372c620f05806faa3c7b8bb487c57ffe391" + }, + "ghcr.io/devcontainer-community/devcontainer-features/ninja-build.org:latest": { + "version": "1.0.2", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/ninja-build.org@sha256:9df3174efc44643c61204fb1b1c0579a091f433246b581d88c7419f6cd4de3ac", + "integrity": "sha256:9df3174efc44643c61204fb1b1c0579a091f433246b581d88c7419f6cd4de3ac" + }, + "ghcr.io/devcontainer-community/devcontainer-features/sourceware.org-gdb:latest": { + "version": "1.0.2", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/sourceware.org-gdb@sha256:c6db6642afafecd431b655dad060e3b3998a46884473cb2a21bf867d4bd30528", + "integrity": "sha256:c6db6642afafecd431b655dad060e3b3998a46884473cb2a21bf867d4bd30528" + }, + "ghcr.io/devcontainer-community/devcontainer-features/valgrind.org:latest": { + "version": "1.0.2", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/valgrind.org@sha256:0422a1ed5cdd2e1b997be8c5f67f729d94f9f1b51ad6144b3e9c0346a7347bba", + "integrity": "sha256:0422a1ed5cdd2e1b997be8c5f67f729d94f9f1b51ad6144b3e9c0346a7347bba" + }, + "ghcr.io/devcontainer-community/devcontainer-features/vcpkg.io:latest": { + "version": "1.0.2", + "resolved": "ghcr.io/devcontainer-community/devcontainer-features/vcpkg.io@sha256:aa1c839509ab397336da9c187c89b16e5cb85666f1c8756a2919f401ed3b44ae", + "integrity": "sha256:aa1c839509ab397336da9c187c89b16e5cb85666f1c8756a2919f401ed3b44ae" + } + } +} diff --git a/.devcontainer/cpp/devcontainer.json b/.devcontainer/cpp/devcontainer.json new file mode 100644 index 00000000..faae09be --- /dev/null +++ b/.devcontainer/cpp/devcontainer.json @@ -0,0 +1,30 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu +{ + "name": "cpp", + "image": "mcr.microsoft.com/devcontainers/base:resolute", + "features": { + "ghcr.io/devcontainer-community/devcontainer-features/collection-c-cpp:1": {} + }, + "customizations": { + "vscode": { + "settings": { + "clangd.arguments": [ + "--compile-commands-dir=${userHome}/.cpp" + ], + "cmake.copyCompileCommands": "${userHome}/.cpp/compile_commands.json", + "cmake.sourceDirectory": "${workspaceFolder}/cpp", + "cmake.useCMakePresets": "auto" + }, + "extensions": [ + "llvm-vs-code-extensions.vscode-clangd", + "ms-vscode.cmake-tools", + "ms-vscode.cpptools" + ] + } + }, + "remoteEnv": { + "CPM_SOURCE_CACHE": "~/cache/.cpm", + "DEBUGINFOD_URLS": "" + } +} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..2657505e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/alpine +{ + "name": "Alpine", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/base:alpine-3.22" + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "uname -a", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/cpp/.clang-format b/cpp/.clang-format new file mode 100644 index 00000000..bf24a8b1 --- /dev/null +++ b/cpp/.clang-format @@ -0,0 +1,164 @@ +--- +Language: Cpp +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignArrayOfStructures: None +AlignConsecutiveMacros: None +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: false +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: true + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: true +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeComma +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 200 +CommentPragmas: "^ IWYU pragma:|^NOSONAR" +QualifierAlignment: Leave +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DeriveLineEnding: true +DerivePointerAlignment: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: Never +FixNamespaceComments: false +IncludeBlocks: Merge +IncludeCategories: + - Regex: ^(<|"(gtest|gmock)/) + Priority: 2 + - Regex: ^( + $ + PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/src/messages +) + +target_link_libraries( + cucumber_query_lib + PUBLIC + nlohmann_json::nlohmann_json + cucumber::messages +) + +set_target_properties( + cucumber_query_lib + PROPERTIES + VERSION ${VERSION} + SOVERSION ${VER_MAJOR} + EXPORT_NAME query + OUTPUT_NAME cucumber_query +) + +# Installation +# Installation +# Installation +# Installation +# Installation +# Installation +# Installation + +# Optional: tests +if(CUCUMBER_QUERY_BUILD_TESTS) + include(CTest) + enable_testing() + add_subdirectory(test) +endif() diff --git a/cpp/CMakePresets.json b/cpp/CMakePresets.json new file mode 100644 index 00000000..02dab8bb --- /dev/null +++ b/cpp/CMakePresets.json @@ -0,0 +1,80 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 21 + }, + "configurePresets": [ + { + "name": "host", + "binaryDir": "${sourceDir}/build/${presetName}", + "generator": "Ninja", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "On", + "CUCUMBER_QUERY_FETCH_DEPS": "On", + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "test", + "inherits": "host", + "cacheVariables": { + "CUCUMBER_QUERY_BUILD_TESTS": "On" + } + } + ], + "buildPresets": [ + { + "name": "host", + "configurePreset": "host" + }, + { + "name": "test", + "configurePreset": "test" + } + ], + "testPresets": [ + { + "name": "test", + "configurePreset": "test", + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error" + } + } + ], + "workflowPresets": [ + { + "name": "host", + "steps": [ + { + "name": "host", + "type": "configure" + }, + { + "name": "host", + "type": "build" + } + ] + }, + { + "name": "test", + "steps": [ + { + "name": "test", + "type": "configure" + }, + { + "name": "test", + "type": "build" + }, + { + "name": "test", + "type": "test" + } + ] + } + ] +} diff --git a/cpp/VERSION b/cpp/VERSION new file mode 100644 index 00000000..3eefcb9d --- /dev/null +++ b/cpp/VERSION @@ -0,0 +1 @@ +1.0.0 diff --git a/cpp/cmake/dependencies.cpm.cmake b/cpp/cmake/dependencies.cpm.cmake new file mode 100644 index 00000000..a54bf707 --- /dev/null +++ b/cpp/cmake/dependencies.cpm.cmake @@ -0,0 +1,78 @@ +# renovate: datasource=github-tags packageName=cpm-cmake/CPM.cmake versioning=semver +set(CPM_DOWNLOAD_TAG_DIGEST v0.43.1 456cb6754daaa010d57444d0c8ce6d95ecf006ab) +# renovate: datasource=github-tags packageName=cucumber/messages versioning=semver +set(CUCUMBER_MESSAGES_TAG_DIGEST v34.0.2 5158f5280a38f949fa444f2009c35d6e120063a2) +# renovate: datasource=github-tags packageName=google/googletest versioning=semver +set(GOOGLE_TEST_TAG_DIGEST v1.17.0 52eb8108c5bdec04579160ae17225d66034bd723) + +list(GET CPM_DOWNLOAD_TAG_DIGEST 0 CPM_DOWNLOAD_TAG) +list(GET CPM_DOWNLOAD_TAG_DIGEST 1 CPM_DOWNLOAD_DIGEST) +string(SUBSTRING "${CPM_DOWNLOAD_TAG}" 1 -1 CPM_DOWNLOAD_VERSION) + +list(GET CUCUMBER_MESSAGES_TAG_DIGEST 0 CUCUMBER_MESSAGES_TAG) +list(GET CUCUMBER_MESSAGES_TAG_DIGEST 1 CUCUMBER_MESSAGES_DIGEST) +string(SUBSTRING "${CUCUMBER_MESSAGES_TAG}" 1 -1 CUCUMBER_MESSAGES_VERSION) + +list(GET GOOGLE_TEST_TAG_DIGEST 0 GOOGLE_TEST_TAG) +list(GET GOOGLE_TEST_TAG_DIGEST 1 GOOGLE_TEST_DIGEST) +string(SUBSTRING "${GOOGLE_TEST_TAG}" 1 -1 GOOGLE_TEST_VERSION) + +if(CUCUMBER_QUERY_FETCH_DEPS) + if(NOT COMMAND CPMAddPackage) + # --------------------------------------------------------------------------- + # CPM – download on first configure if not already cached (standalone only) + # --------------------------------------------------------------------------- + set(CPM_USE_LOCAL_PACKAGES ON) + set(CPM_DOWNLOAD_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") + + if(NOT EXISTS "${CPM_DOWNLOAD_LOCATION}") + message(STATUS "Downloading CPM.cmake ${CPM_DOWNLOAD_VERSION}…") + file(DOWNLOAD + "https://github.com/cpm-cmake/CPM.cmake/releases/download/${CPM_DOWNLOAD_TAG}/CPM.cmake" + "${CPM_DOWNLOAD_LOCATION}" + TLS_VERIFY ON + ) + endif() + + include("${CPM_DOWNLOAD_LOCATION}") + endif() + + # --------------------------------------------------------------------------- + # Dependencies + # --------------------------------------------------------------------------- + CPMAddPackage( + URI "gh:cucumber/messages@${CUCUMBER_MESSAGES_VERSION}#${CUCUMBER_MESSAGES_DIGEST}" + NAME cucumber_messages + SOURCE_SUBDIR cpp + OPTIONS + "CUCUMBER_MESSAGES_FETCH_DEPS ON" + ) + + if(cucumber_messages_ADDED) + # Propagate cucumber_messages install rules so 'cmake --install' also installs it + install(SCRIPT "${cucumber_messages_BINARY_DIR}/cmake_install.cmake") + endif() + + + + if(CUCUMBER_QUERY_BUILD_TESTS) + CPMAddPackage( + URI "gh:google/googletest@${GOOGLE_TEST_VERSION}#${GOOGLE_TEST_DIGEST}" + NAME googletest + OPTIONS + "INSTALL_GTEST OFF" + "gtest_force_shared_crt ON" + ) + + set_target_properties(gtest gtest_main gmock gmock_main PROPERTIES + FOLDER External/GoogleTest + ) + endif() + +else() + find_package(cucumber_messages ${CUCUMBER_MESSAGES_VERSION} REQUIRED) + + if (CUCUMBER_QUERY_BUILD_TESTS) + find_package(GTest ${GOOGLE_TEST_VERSION} REQUIRED) + endif() +endif() diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp new file mode 100644 index 00000000..843abb7d --- /dev/null +++ b/cpp/include/cucumber/query/Query.hpp @@ -0,0 +1,26 @@ +#ifndef CUCUMBER_QUERY_QUERY_HPP +#define CUCUMBER_QUERY_QUERY_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace cucumber::query +{ + class Query + { + public: + void Update(const cucumber::messages::Envelope& envelope); + + [[nodiscard]] std::size_t CountTestCasesStarted() const; + + private: + std::unordered_map, std::less<>> testCaseStartedById; + }; +} + +#endif diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp new file mode 100644 index 00000000..c7cf0753 --- /dev/null +++ b/cpp/src/query/Query.cpp @@ -0,0 +1,13 @@ +#include "cucumber/query/Query.hpp" +#include "cucumber/messages/Envelope.hpp" + +namespace cucumber::query +{ + void Query::Update(const cucumber::messages::Envelope& envelope) + {} + + [[nodiscard]] std::size_t Query::CountTestCasesStarted() const + { + return testCaseStartedById.size(); + } +} diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt new file mode 100644 index 00000000..16a444c6 --- /dev/null +++ b/cpp/test/CMakeLists.txt @@ -0,0 +1,21 @@ +add_executable(cucumber_query_lib.test) +# add_test(NAME cucumber_query_lib.test COMMAND cucumber_query_lib.test) + +target_sources(cucumber_query_lib.test + PRIVATE + TestQuery.cpp +) + +target_link_libraries(cucumber_query_lib.test + PRIVATE + cucumber::query + GTest::gmock +) + +target_compile_definitions(cucumber_query_lib.test + PRIVATE + TESTDATA_SRC="${CMAKE_SOURCE_DIR}/../testdata/src" +) + +include(GoogleTest) +gtest_discover_tests(cucumber_query_lib.test) diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp new file mode 100644 index 00000000..cb4adc38 --- /dev/null +++ b/cpp/test/TestQuery.cpp @@ -0,0 +1,198 @@ +#include "cucumber/query/Query.hpp" +#include "nlohmann/json.hpp" +#include "nlohmann/json_fwd.hpp" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +TEST(first, second) +{} + +namespace +{ + std::set> CollectFiles(const std::filesystem::path& folder) + { + std::set> foundFiles; + + for (const auto& entry : std::filesystem::directory_iterator{ folder }) + { + foundFiles.emplace(entry.path()); + } + + return foundFiles; + } + + struct TestData + { + std::list ndjson; + std::list json; + std::set> txt; + }; + + struct TestSet + { + std::filesystem::path ndjson; + std::set> json; + }; + + TestData GetTestFiles() + { + auto foundFiles = CollectFiles(TESTDATA_SRC); + + TestData testData{}; + + while (!foundFiles.empty()) + { + const auto begin = foundFiles.begin(); + if (begin->extension() == ".ndjson") + { + testData.ndjson.emplace_back(std::move(foundFiles.extract(begin).value())); + } + else if (begin->extension() == ".json") + { + testData.json.emplace_back(std::move(foundFiles.extract(begin).value())); + } + else if (begin->extension() == ".txt") + { + testData.txt.emplace(std::move(foundFiles.extract(begin).value())); + } + else + { + throw "unknown extension:" + begin->extension().string(); + } + } + + return testData; + } + + std::string FilterName(std::string str) + { + for (auto iter = str.find('-'); iter != std::string::npos; iter = str.find('-')) + { + str.replace(iter, 1, "_"); + } + + return str; + } + + void CountTestCasesStarted(const cucumber::query::Query& query, const nlohmann::json& expected) + { + FAIL(); + } + + const std::unordered_map functionMap{ + { "countTestCasesStarted", &CountTestCasesStarted }, + }; + + struct AcceptanceTest : testing::Test + { + AcceptanceTest(std::filesystem::path input, std::filesystem::path expected) + : input{ std::move(input) } + , expected{ std::move(expected) } + {} + + private: + void TestBody() override + { + const auto* testInfo = testing::UnitTest::GetInstance()->current_test_info(); + const auto* testCaseName = testInfo->name(); + + if (functionMap.find(testCaseName) == functionMap.end()) + { + GTEST_SKIP() << "No function registered for test case: " << testCaseName; + } + + // loadQuery + { + std::ifstream ifstream{ input }; + std::string line; + while (std::getline(ifstream, line)) + { + cucumber::messages::Envelope envelope; + envelope.from_json(nlohmann::json::parse(line)); + + query.Update(envelope); + } + } + + { + std::ifstream ifstream{ expected }; + functionMap.at(testCaseName)(query, nlohmann::json::parse(ifstream)); + } + } + + cucumber::query::Query query; + + std::filesystem::path input; + std::filesystem::path expected; + }; +} + +GTEST_API_ int main(int argc, char** argv) +{ + auto testData = GetTestFiles(); + + std::vector testSets{}; + + for (auto ndjsonIter = testData.ndjson.begin(); ndjsonIter != testData.ndjson.end();) + { + TestSet testSet{}; + const auto& testSetName = ndjsonIter->stem().string(); + + for (auto iter = testData.json.begin(); iter != testData.json.end();) + { + if (iter->filename().string().find(testSetName) == 0) + { + testSet.json.emplace(std::move(*iter)); + testData.json.erase(std::exchange(iter, std::next(iter))); + } + else + { + iter = std::next(iter); + } + } + + if (!testSet.json.empty()) + { + testSet.ndjson = std::move(*ndjsonIter); + testSets.push_back(std::move(testSet)); + + testData.ndjson.erase(std::exchange(ndjsonIter, std::next(ndjsonIter))); + } + else + { + ndjsonIter = std::next(ndjsonIter); + } + } + + for (const auto& suite : testSets) + { + for (const auto& test : suite.json) + { + const auto suiteName = suite.ndjson.stem().string(); + const auto testNameResult = test.stem().string().substr(suiteName.size() + 1); + const auto testName = testNameResult.substr(0, testNameResult.size() - std::strlen(".results")); + + ::testing::RegisterTest(FilterName(suiteName).c_str(), FilterName(testName).c_str(), nullptr, nullptr, test.c_str(), 1, + [ndjson = suite.ndjson, json = test]() -> AcceptanceTest* + { + return new AcceptanceTest(ndjson, json); // NOLINT(cppcoreguidelines-owning-memory) + }); + } + } + + testing::InitGoogleMock(&argc, argv); + return RUN_ALL_TESTS(); +} From 08841740aafdd5d0314a747fabdf883c682c3d08 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sun, 19 Jul 2026 22:26:33 +0000 Subject: [PATCH 02/56] first two test passing --- cpp/include/cucumber/query/Query.hpp | 187 ++++++++++++++++++- cpp/src/query/Query.cpp | 268 ++++++++++++++++++++++++++- cpp/test/TestQuery.cpp | 10 +- 3 files changed, 457 insertions(+), 8 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 843abb7d..8647f999 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -1,25 +1,206 @@ #ifndef CUCUMBER_QUERY_QUERY_HPP #define CUCUMBER_QUERY_QUERY_HPP +#include "cucumber/messages/All.hpp" +#include "cucumber/messages/Envelope.hpp" +#include "cucumber/messages/TestCaseStarted.hpp" +#include "cucumber/messages/TestStepResultStatus.hpp" #include -#include -#include +#include +#include +#include +#include #include #include #include #include +#include namespace cucumber::query { + struct Lineage + { + std::shared_ptr gherkinDocument; + std::shared_ptr feature; + std::shared_ptr background; + std::shared_ptr rule; + std::shared_ptr ruleBackground; + std::shared_ptr scenario; + std::shared_ptr examples; + std::size_t examplesIndex; + std::shared_ptr example; + std::size_t exampleIndex; + + Lineage operator+(const Lineage& other) const; + }; + class Query { public: void Update(const cucumber::messages::Envelope& envelope); + [[nodiscard]] std::unordered_map CountMostSevereTestStepResultStatus() const; + [[nodiscard]] std::size_t CountTestCasesStarted() const; + [[nodiscard]] std::vector> FindAllPickles() const; + + [[nodiscard]] std::vector> FindAllPickleSteps() const; + + [[nodiscard]] std::vector> FindAllStepDefinitions() const; + + [[nodiscard]] std::vector> FindAllTestCaseStarted() const; + + [[nodiscard]] std::vector> FindAllTestCaseFinished() const; + + template + [[nodiscard]] std::vector> FindAllTestCaseStartedOrderBy(TFind findOrderBy, Cmp order) const; + + template + [[nodiscard]] std::vector> FindAllTestCaseFinishedOrderBy(TFind findOrderBy, Cmp order) const; + + // FindAllTestSteps() + // : ReadonlyArray const; + + // FindAllTestStepStarted() + // : ReadonlyArray const; + + // FindAllTestStepFinished() + // : ReadonlyArray const; + + // FindAllTestRunHookStarted() + // : ReadonlyArray const; + + // FindAllTestRunHookFinished() + // : ReadonlyArray const; + + // FindAllUndefinedParameterTypes() + // : ReadonlyArray const; + + // FindAttachmentsBy(element : TestStepFinished | TestRunHookFinished) + // : ReadonlyArray const; + + // FindHookBy(item : TestStep | TestRunHookStarted | TestRunHookFinished) + // : Hook | undefined const; + + // FindMeta() + // : Meta | undefined const; + + // FindMostSevereTestStepResultBy(element : TestCaseStarted | TestCaseFinished) + // : TestStepResult | undefined const; + + // FindLocationOf(pickle : Pickle) + // : Location | undefined const; + + // FindPickleBy(element : TestCaseStarted | TestCaseFinished | TestStepStarted) + // : Pickle | undefined const; + + // FindPickleStepBy(testStep : TestStep) + // : PickleStep | undefined const; + + // FindStepBy(pickleStep : PickleStep) + // : Step | undefined const; + + // FindStepDefinitionsBy(testStep : TestStep) + // : ReadonlyArray const; + + // findSuggestionsBy(element : PickleStep | Pickle) + // : ReadonlyArray const; + + // FindUnambiguousStepDefinitionBy(testStep : TestStep) + // : StepDefinition | undefined const; + + // FindTestCaseBy(element : TestCaseStarted | TestCaseFinished | TestStepStarted | TestStepFinished) + // : TestCase | undefined const; + + // FindTestCaseDurationBy(element : TestCaseStarted | TestCaseFinished) + // : Duration | undefined const; + + // FindTestCaseStartedBy(element : TestCaseFinished | TestStepStarted | TestStepFinished) + // : TestCaseStarted | undefined const; + + // FindTestCaseFinishedBy(testCaseStarted : TestCaseStarted) + // : TestCaseFinished | undefined const; + + // FindTestRunHookStartedBy(testRunHookFinished : TestRunHookFinished) + // : TestRunHookStarted | undefined const; + + // FindTestRunHookFinishedBy(testRunHookStarted : TestRunHookStarted) + // : TestRunHookFinished | undefined const; + + // FindTestRunDuration() + // : Duration | undefined const; + + // FindTestRunFinished() + // : TestRunFinished | undefined const; + + // FindTestRunStarted() + // : TestRunStarted | undefined const; + + // FindTestStepBy(element : TestStepStarted | TestStepFinished) + // : TestStep | undefined + // {} + + // FindTestStepsStartedBy(element : TestCaseStarted | TestCaseFinished) + // : ReadonlyArray const; + + // FindTestStepsFinishedBy(element : TestCaseStarted | TestCaseFinished) + // : ReadonlyArray const; + + // FindTestStepFinishedAndTestStepBy(testCaseStarted : TestCaseStarted) + // : ReadonlyArray<[ TestStepFinished, TestStep ]> const; + + // FindLineageBy(element : Pickle | TestCaseStarted | TestCaseFinished) + // : Lineage | undefined const; + + // [[nodiscard]] std::size_t CountTestCasesStarted() const; + private: - std::unordered_map, std::less<>> testCaseStartedById; + void UpdateGherkinDocument(const std::shared_ptr& gherkinDocument); + void UpdateFeature(const std::shared_ptr& feature, std::unique_ptr lineage); + void UpdateRule(const std::shared_ptr& rule, std::unique_ptr lineage); + void UpdateScenario(const std::shared_ptr& scenario, std::unique_ptr lineage); + void UpdateSteps(const std::vector>& steps); + void UpdatePickle(std::shared_ptr pickle); + + ///////////// + ///////////// + ///////////// + + void UpdateTestCaseStarted(std::shared_ptr testCaseStarted); + + ///////////// + ///////////// + ///////////// + + std::shared_ptr meta; + + // private testRunStarted: TestRunStarted + // private testRunFinished: TestRunFinished + std::unordered_map> testCaseStartedById; + std::unordered_map> lineageById; + std::unordered_map> stepById; + std::unordered_map> pickleById; + // private readonly pickleStepById: Map = new Map() + // private readonly hookById: Map = new Map() + // private readonly stepDefinitionById: Map = new Map() + // private readonly testCaseById: Map = new Map() + // private readonly testStepById: Map = new Map() + std::unordered_map> testCaseFinishedByTestCaseStartedId; + // private readonly testRunHookStartedById: Map = new Map() + // private readonly testRunHookFinishedByTestRunHookStartedId: Map = + // new Map() + // private readonly testStepStartedByTestCaseStartedId: ArrayMultimap = + // new ArrayMultimap() + // private readonly testStepFinishedByTestCaseStartedId: ArrayMultimap = + // new ArrayMultimap() + // private readonly attachmentsByTestCaseStartedId: ArrayMultimap = + // new ArrayMultimap() + // private readonly attachmentsByTestRunHookStartedId: ArrayMultimap = + // new ArrayMultimap() + // private readonly suggestionsByPickleStepId: ArrayMultimap = + // new ArrayMultimap() + // private readonly undefinedParameterTypes: UndefinedParameterType[] = [] }; } diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index c7cf0753..b83dc9fb 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -1,13 +1,273 @@ #include "cucumber/query/Query.hpp" -#include "cucumber/messages/Envelope.hpp" +#include "cucumber/messages/All.hpp" +#include +#include +#include +#include +#include +#include namespace cucumber::query { + + Lineage Lineage::operator+(const Lineage& other) const + { + Lineage combined; + combined.gherkinDocument = other.gherkinDocument ? other.gherkinDocument : gherkinDocument; + combined.feature = other.feature ? other.feature : feature; + combined.background = other.background ? other.background : background; + combined.rule = other.rule ? other.rule : rule; + combined.ruleBackground = other.ruleBackground ? other.ruleBackground : ruleBackground; + combined.scenario = other.scenario ? other.scenario : scenario; + combined.examples = other.examples ? other.examples : examples; + combined.examplesIndex = (other.examplesIndex != 0) ? other.examplesIndex : examplesIndex; + combined.example = other.example ? other.example : example; + combined.exampleIndex = (other.exampleIndex != 0) ? other.exampleIndex : exampleIndex; + return combined; + } + void Query::Update(const cucumber::messages::Envelope& envelope) - {} + { + if (envelope.meta.has_value()) + { + meta = envelope.meta.value(); + } + if (envelope.gherkinDocument.has_value()) + { + UpdateGherkinDocument(envelope.gherkinDocument.value()); + } + if (envelope.pickle.has_value()) + { + UpdatePickle(envelope.pickle.value()); + } + // if (envelope.hook) + // { + // this.hookById.set(envelope.hook.id, envelope.hook) + // } + // if (envelope.stepDefinition) + // { + // this.stepDefinitionById.set(envelope.stepDefinition.id, envelope.stepDefinition) + // } + // if (envelope.testRunStarted) + // { + // this.testRunStarted = envelope.testRunStarted + // } + // if (envelope.testRunHookStarted) + // { + // this.updateTestRunHookStarted(envelope.testRunHookStarted) + // } + // if (envelope.testRunHookFinished) + // { + // this.updateTestRunHookFinished(envelope.testRunHookFinished) + // } + // if (envelope.testCase) + // { + // this.updateTestCase(envelope.testCase) + // } + if (envelope.testCaseStarted.has_value()) + { + UpdateTestCaseStarted(envelope.testCaseStarted.value()); + } + // if (envelope.testStepStarted) + // { + // this.updateTestStepStarted(envelope.testStepStarted) + // } + // if (envelope.attachment) + // { + // this.updateAttachment(envelope.attachment) + // } + // if (envelope.testStepFinished) + // { + // this.updateTestStepFinished(envelope.testStepFinished) + // } + // if (envelope.testCaseFinished) + // { + // this.updateTestCaseFinished(envelope.testCaseFinished) + // } + // if (envelope.testRunFinished) + // { + // this.testRunFinished = envelope.testRunFinished + // } + // if (envelope.suggestion) + // { + // this.updateSuggestion(envelope.suggestion) + // } + // if (envelope.undefinedParameterType) + // { + // this.updateUndefinedParameterType(envelope.undefinedParameterType) + // } + } + + std::unordered_map Query::CountMostSevereTestStepResultStatus() const + { + return {}; + } + + std::size_t Query::CountTestCasesStarted() const + { + return FindAllTestCaseStarted().size(); + } + + std::vector> Query::FindAllPickles() const + { + std::vector> result; + result.reserve(pickleById.size()); + + for (const auto& [pickleId, pickle] : pickleById) + { + result.push_back(pickle); + } + + return result; + } + + std::vector> Query::FindAllPickleSteps() const + { + return {}; + } + + std::vector> Query::FindAllStepDefinitions() const + { + return {}; + } + + std::vector> Query::FindAllTestCaseStarted() const + { + std::vector> result; + + for (const auto& [testCaseStartedId, testCaseStarted] : testCaseStartedById) + { + auto iter = testCaseFinishedByTestCaseStartedId.find(testCaseStarted->id); + + if (iter == testCaseFinishedByTestCaseStartedId.end() || !iter->second->willBeRetried) + { + result.push_back(testCaseStarted); + } + } + + return result; + } + + std::vector> Query::FindAllTestCaseFinished() const + { + std::vector> result; - [[nodiscard]] std::size_t Query::CountTestCasesStarted() const + for (const auto& [testCaseStartedId, testCaseFinished] : testCaseFinishedByTestCaseStartedId) + { + if (testCaseFinished->willBeRetried) + { + result.push_back(testCaseFinished); + } + } + + return result; + } + + // [[nodiscard]] std::size_t Query::CountTestCasesStarted() const + // { + // return testCaseStartedById.size(); + // } + + ///////////////////////////// + ///////////////////////////// + ///////////////////////////// + ///////////////////////////// + ///////////////////////////// + ///////////////////////////// + + void Query::UpdateGherkinDocument(const std::shared_ptr& gherkinDocument) + { + if (gherkinDocument->feature.has_value()) + { + UpdateFeature(gherkinDocument->feature.value(), std::make_unique(Lineage{ gherkinDocument })); + } + } + + void Query::UpdateFeature(const std::shared_ptr& feature, std::unique_ptr lineage) { - return testCaseStartedById.size(); + for (const auto& featureChild : feature->children) + { + if (featureChild->background.has_value()) + { + lineage->background = featureChild->background.value(); + UpdateSteps(featureChild->background.value()->steps); + } + + if (featureChild->scenario.has_value()) + { + UpdateScenario(featureChild->scenario.value(), std::make_unique(*lineage + Lineage{ {}, feature })); + } + + if (featureChild->rule.has_value()) + { + UpdateRule(featureChild->rule.value(), std::make_unique(*lineage + Lineage{ {}, feature })); + } + } + } + + void Query::UpdateRule(const std::shared_ptr& rule, std::unique_ptr lineage) + { + for (const auto& ruleChild : rule->children) + { + if (ruleChild->background.has_value()) + { + lineage->ruleBackground = ruleChild->background.value(); + UpdateSteps(ruleChild->background.value()->steps); + } + + if (ruleChild->scenario.has_value()) + { + UpdateScenario(ruleChild->scenario.value(), std::make_unique(*lineage + Lineage{ {}, {}, {}, rule })); + } + } } + + void Query::UpdateScenario(const std::shared_ptr& scenario, std::unique_ptr lineage) + { + lineageById[scenario->id] = std::make_unique(*lineage + Lineage{ {}, {}, {}, {}, {}, scenario }); + + std::size_t examplesIndex = 0; + for (const auto& examples : scenario->examples) + { + lineageById[examples->id] = std::make_unique(*lineage + Lineage{ {}, {}, {}, {}, {}, scenario, examples, examplesIndex }); + + std::size_t exampleIndex = 0; + for (const auto& example : examples->tableBody) + { + lineageById[example->id] = std::make_unique(*lineage + Lineage{ {}, {}, {}, {}, {}, scenario, examples, examplesIndex, example, exampleIndex }); + ++exampleIndex; + } + ++examplesIndex; + } + + UpdateSteps(scenario->steps); + } + + void Query::UpdateSteps(const std::vector>& steps) + { + for (const auto& step : steps) + { + stepById[step->id] = step; + } + } + + void Query::UpdatePickle(std::shared_ptr pickle) + { + pickleById[pickle->id] = std::move(pickle); + // for (const pickleStep of pickle.steps) { + // this.pickleStepById.set(pickleStep.id, pickleStep) + } + + ///////////////////////////// + ///////////////////////////// + ///////////////////////////// + + void Query::UpdateTestCaseStarted(std::shared_ptr testCaseStarted) + { + testCaseStartedById[testCaseStarted->id] = std::move(testCaseStarted); + } + + ///////////////////////////// + ///////////////////////////// + ///////////////////////////// } diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index cb4adc38..8b3f9755 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -89,11 +89,19 @@ namespace void CountTestCasesStarted(const cucumber::query::Query& query, const nlohmann::json& expected) { - FAIL(); + const auto actual = query.CountTestCasesStarted(); + EXPECT_THAT(actual, testing::Eq(expected.get())); + } + + void FindAllPickles(const cucumber::query::Query& query, const nlohmann::json& expected) + { + const auto actual = query.FindAllPickles(); + EXPECT_THAT(actual.size(), testing::Eq(expected.get())); } const std::unordered_map functionMap{ { "countTestCasesStarted", &CountTestCasesStarted }, + { "findAllPickles", &FindAllPickles }, }; struct AcceptanceTest : testing::Test From e42c7836f9e3f6be93ea40bd6146f1606340181f Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Mon, 20 Jul 2026 23:38:46 +0000 Subject: [PATCH 03/56] Enable CountMostSevereTestStepResultStatus and FindAllPickleSteps methods --- cpp/include/cucumber/query/Query.hpp | 49 +++++----- cpp/src/query/Query.cpp | 139 ++++++++++++++++++++++----- cpp/test/TestQuery.cpp | 21 ++++ 3 files changed, 164 insertions(+), 45 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 8647f999..bd04e7a8 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -10,10 +10,14 @@ #include #include #include -#include +#include +#include #include +#include #include #include +#include +#include #include namespace cucumber::query @@ -53,11 +57,11 @@ namespace cucumber::query [[nodiscard]] std::vector> FindAllTestCaseFinished() const; - template - [[nodiscard]] std::vector> FindAllTestCaseStartedOrderBy(TFind findOrderBy, Cmp order) const; + // template + // [[nodiscard]] std::vector> FindAllTestCaseStartedOrderBy(TFind findOrderBy, Cmp order) const; - template - [[nodiscard]] std::vector> FindAllTestCaseFinishedOrderBy(TFind findOrderBy, Cmp order) const; + // template + // [[nodiscard]] std::vector> FindAllTestCaseFinishedOrderBy(TFind findOrderBy, Cmp order) const; // FindAllTestSteps() // : ReadonlyArray const; @@ -137,9 +141,8 @@ namespace cucumber::query // FindTestRunStarted() // : TestRunStarted | undefined const; - // FindTestStepBy(element : TestStepStarted | TestStepFinished) - // : TestStep | undefined - // {} + std::optional> FindTestStepBy( + std::variant, std::shared_ptr> element) const; // FindTestStepsStartedBy(element : TestCaseStarted | TestCaseFinished) // : ReadonlyArray const; @@ -147,8 +150,8 @@ namespace cucumber::query // FindTestStepsFinishedBy(element : TestCaseStarted | TestCaseFinished) // : ReadonlyArray const; - // FindTestStepFinishedAndTestStepBy(testCaseStarted : TestCaseStarted) - // : ReadonlyArray<[ TestStepFinished, TestStep ]> const; + std::vector, std::shared_ptr>> FindTestStepFinishedAndTestStepBy( + const std::shared_ptr& testCaseStarted) const; // FindLineageBy(element : Pickle | TestCaseStarted | TestCaseFinished) // : Lineage | undefined const; @@ -167,9 +170,11 @@ namespace cucumber::query ///////////// ///////////// + void UpdateTestCase(std::shared_ptr testCase); void UpdateTestCaseStarted(std::shared_ptr testCaseStarted); - ///////////// + + void UpdateTestStepFinished(std::shared_ptr testStepFinished); ///////////// ///////////// @@ -181,24 +186,24 @@ namespace cucumber::query std::unordered_map> lineageById; std::unordered_map> stepById; std::unordered_map> pickleById; - // private readonly pickleStepById: Map = new Map() + std::unordered_map> pickleStepById; // private readonly hookById: Map = new Map() - // private readonly stepDefinitionById: Map = new Map() - // private readonly testCaseById: Map = new Map() - // private readonly testStepById: Map = new Map() + std::unordered_map> stepDefinitionById; + std::unordered_map> testCaseById; + std::unordered_map> testStepById; std::unordered_map> testCaseFinishedByTestCaseStartedId; - // private readonly testRunHookStartedById: Map = new Map() - // private readonly testRunHookFinishedByTestRunHookStartedId: Map = + // private readonly testRunHookStartedById: std::unordered_map = new Map() + // private readonly testRunHookFinishedByTestRunHookStartedId: std::unordered_map = // new Map() - // private readonly testStepStartedByTestCaseStartedId: ArrayMultimap = + // private readonly testStepStartedByTestCaseStartedId: ArrayMultistd::unordered_map = // new ArrayMultimap() - // private readonly testStepFinishedByTestCaseStartedId: ArrayMultimap = + std::unordered_map>> testStepFinishedByTestCaseStartedId; // new ArrayMultimap() - // private readonly attachmentsByTestCaseStartedId: ArrayMultimap = + // private readonly attachmentsByTestCaseStartedId: ArrayMultistd::unordered_map = // new ArrayMultimap() - // private readonly attachmentsByTestRunHookStartedId: ArrayMultimap = + // private readonly attachmentsByTestRunHookStartedId: ArrayMultistd::unordered_map = // new ArrayMultimap() - // private readonly suggestionsByPickleStepId: ArrayMultimap = + // private readonly suggestionsByPickleStepId: ArrayMultistd::unordered_map = // new ArrayMultimap() // private readonly undefinedParameterTypes: UndefinedParameterType[] = [] }; diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index b83dc9fb..0ec842c0 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -1,14 +1,36 @@ #include "cucumber/query/Query.hpp" #include "cucumber/messages/All.hpp" +#include #include +#include #include #include +#include +#include +#include #include #include +#include #include namespace cucumber::query { + namespace + { + template + auto MapValuesToVector(const C& container) + { + std::vector result; + result.reserve(container.size()); + + for (const auto& [key, value] : container) + { + result.push_back(value); + } + + return result; + } + } Lineage Lineage::operator+(const Lineage& other) const { @@ -60,10 +82,10 @@ namespace cucumber::query // { // this.updateTestRunHookFinished(envelope.testRunHookFinished) // } - // if (envelope.testCase) - // { - // this.updateTestCase(envelope.testCase) - // } + if (envelope.testCase.has_value()) + { + UpdateTestCase(envelope.testCase.value()); + } if (envelope.testCaseStarted.has_value()) { UpdateTestCaseStarted(envelope.testCaseStarted.value()); @@ -76,10 +98,10 @@ namespace cucumber::query // { // this.updateAttachment(envelope.attachment) // } - // if (envelope.testStepFinished) - // { - // this.updateTestStepFinished(envelope.testStepFinished) - // } + if (envelope.testStepFinished.has_value()) + { + UpdateTestStepFinished(envelope.testStepFinished.value()); + } // if (envelope.testCaseFinished) // { // this.updateTestCaseFinished(envelope.testCaseFinished) @@ -100,7 +122,29 @@ namespace cucumber::query std::unordered_map Query::CountMostSevereTestStepResultStatus() const { - return {}; + std::unordered_map result{ + { messages::TestStepResultStatus::AMBIGUOUS, 0 }, + { messages::TestStepResultStatus::FAILED, 0 }, + { messages::TestStepResultStatus::PASSED, 0 }, + { messages::TestStepResultStatus::PENDING, 0 }, + { messages::TestStepResultStatus::SKIPPED, 0 }, + { messages::TestStepResultStatus::UNDEFINED, 0 }, + { messages::TestStepResultStatus::UNKNOWN, 0 }, + }; + + for (const auto& testCaseStarted : FindAllTestCaseStarted()) + { + auto allFinishedSteps = FindTestStepFinishedAndTestStepBy(testCaseStarted); + std::sort(allFinishedSteps.begin(), allFinishedSteps.end(), + [](const auto& lhs, const auto& rhs) + { + using underlying_type = std::underlying_type_t; + return static_cast(lhs.first->testStepResult->status) > static_cast(rhs.first->testStepResult->status); + }); + ++result[allFinishedSteps.front().first->testStepResult->status]; + } + + return result; } std::size_t Query::CountTestCasesStarted() const @@ -110,25 +154,17 @@ namespace cucumber::query std::vector> Query::FindAllPickles() const { - std::vector> result; - result.reserve(pickleById.size()); - - for (const auto& [pickleId, pickle] : pickleById) - { - result.push_back(pickle); - } - - return result; + return MapValuesToVector(pickleById); } std::vector> Query::FindAllPickleSteps() const { - return {}; + return MapValuesToVector(pickleStepById); } std::vector> Query::FindAllStepDefinitions() const { - return {}; + return MapValuesToVector(stepDefinitionById); } std::vector> Query::FindAllTestCaseStarted() const @@ -168,6 +204,44 @@ namespace cucumber::query // return testCaseStartedById.size(); // } + std::optional> Query::FindTestStepBy( + std::variant, std::shared_ptr> element) const + { + try + { + return std::visit( + [this](const auto& item) + { + return testStepById.at(item->testStepId); + }, + element); + } + catch (const std::out_of_range&) + { + return std::nullopt; + } + } + + std::vector, std::shared_ptr>> Query::FindTestStepFinishedAndTestStepBy( + const std::shared_ptr& testCaseStarted) const + { + std::vector, std::shared_ptr>> result; + + const auto& testStepsFinished = testStepFinishedByTestCaseStartedId.at(testCaseStarted->id); + + for (const auto& testStepFinished : testStepsFinished) + { + const auto& testStep = FindTestStepBy(testStepFinished); + if (!testStep) + { + throw std::out_of_range{ "Expected to find TestStep by TestStepFinished" }; + } + result.emplace_back(testStepFinished, *testStep); + } + + return result; + } + ///////////////////////////// ///////////////////////////// ///////////////////////////// @@ -253,20 +327,39 @@ namespace cucumber::query void Query::UpdatePickle(std::shared_ptr pickle) { - pickleById[pickle->id] = std::move(pickle); - // for (const pickleStep of pickle.steps) { - // this.pickleStepById.set(pickleStep.id, pickleStep) + auto&& entry = pickleById[pickle->id] = std::move(pickle); + for (const auto& pickleStep : entry->steps) + { + pickleStepById[pickleStep->id] = pickleStep; + } } ///////////////////////////// ///////////////////////////// ///////////////////////////// + void Query::UpdateTestCase(std::shared_ptr testCase) + { + for (const auto& testStep : testCase->testSteps) + { + testStepById[testStep->id] = testStep; + } + testCaseById[testCase->id] = std::move(testCase); + } + void Query::UpdateTestCaseStarted(std::shared_ptr testCaseStarted) { testCaseStartedById[testCaseStarted->id] = std::move(testCaseStarted); } + ///////////////////////////// + + void Query::UpdateTestStepFinished(std::shared_ptr testStepFinished) + { + testStepFinishedByTestCaseStartedId[testStepFinished->testCaseStartedId].push_back(std::move(testStepFinished)); + } + + ///////////////////////////// ///////////////////////////// ///////////////////////////// ///////////////////////////// diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index 8b3f9755..9fdd419c 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -5,6 +5,7 @@ #include "gtest/gtest.h" #include #include +#include #include #include #include @@ -87,6 +88,18 @@ namespace return str; } + void CountMostSevereTestStepResultStatus(const cucumber::query::Query& query, const nlohmann::json& expected) + { + const auto allResults = query.CountMostSevereTestStepResultStatus(); + nlohmann::json actual; + for (const auto& [status, count] : allResults) + { + actual[to_string(status)] = count; + } + + EXPECT_THAT(actual, testing::Eq(expected)); + } + void CountTestCasesStarted(const cucumber::query::Query& query, const nlohmann::json& expected) { const auto actual = query.CountTestCasesStarted(); @@ -99,9 +112,17 @@ namespace EXPECT_THAT(actual.size(), testing::Eq(expected.get())); } + void FindAllPickleSteps(const cucumber::query::Query& query, const nlohmann::json& expected) + { + const auto actual = query.FindAllPickleSteps(); + EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + } + const std::unordered_map functionMap{ + { "countMostSevereTestStepResultStatus", &CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", &CountTestCasesStarted }, { "findAllPickles", &FindAllPickles }, + { "findAllPickleSteps", &FindAllPickleSteps }, }; struct AcceptanceTest : testing::Test From 4970dcb14b22991be8ef550a42b57d68c57175f8 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Tue, 21 Jul 2026 22:54:35 +0000 Subject: [PATCH 04/56] Enabled FindAllStepDefinitions, FindAllTestCaseFinished, FindAllTestCaseStartedOrderBy --- cpp/include/cucumber/query/Query.hpp | 67 ++++++++++++-- cpp/src/query/Query.cpp | 134 +++++++++++++++++++++------ cpp/test/TestQuery.cpp | 52 +++++++++++ 3 files changed, 217 insertions(+), 36 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index bd04e7a8..0b90decd 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -5,6 +5,7 @@ #include "cucumber/messages/Envelope.hpp" #include "cucumber/messages/TestCaseStarted.hpp" #include "cucumber/messages/TestStepResultStatus.hpp" +#include #include #include #include @@ -12,6 +13,8 @@ #include #include #include +#include +#include #include #include #include @@ -57,8 +60,8 @@ namespace cucumber::query [[nodiscard]] std::vector> FindAllTestCaseFinished() const; - // template - // [[nodiscard]] std::vector> FindAllTestCaseStartedOrderBy(TFind findOrderBy, Cmp order) const; + template + [[nodiscard]] std::vector> FindAllTestCaseStartedOrderBy(TFind findOrderBy, Cmp order) const; // template // [[nodiscard]] std::vector> FindAllTestCaseFinishedOrderBy(TFind findOrderBy, Cmp order) const; @@ -96,8 +99,8 @@ namespace cucumber::query // FindLocationOf(pickle : Pickle) // : Location | undefined const; - // FindPickleBy(element : TestCaseStarted | TestCaseFinished | TestStepStarted) - // : Pickle | undefined const; + std::optional> FindPickleBy( + std::variant, std::shared_ptr, std::shared_ptr> element) const; // FindPickleStepBy(testStep : TestStep) // : PickleStep | undefined const; @@ -114,14 +117,15 @@ namespace cucumber::query // FindUnambiguousStepDefinitionBy(testStep : TestStep) // : StepDefinition | undefined const; - // FindTestCaseBy(element : TestCaseStarted | TestCaseFinished | TestStepStarted | TestStepFinished) - // : TestCase | undefined const; + std::optional> FindTestCaseBy(std::variant, std::shared_ptr, + std::shared_ptr, std::shared_ptr> + element) const; // FindTestCaseDurationBy(element : TestCaseStarted | TestCaseFinished) // : Duration | undefined const; - // FindTestCaseStartedBy(element : TestCaseFinished | TestStepStarted | TestStepFinished) - // : TestCaseStarted | undefined const; + std::optional> FindTestCaseStartedBy( + std::variant, std::shared_ptr, std::shared_ptr> element) const; // FindTestCaseFinishedBy(testCaseStarted : TestCaseStarted) // : TestCaseFinished | undefined const; @@ -175,6 +179,7 @@ namespace cucumber::query ///////////// void UpdateTestStepFinished(std::shared_ptr testStepFinished); + void UpdateTestCaseFinished(std::shared_ptr testCaseFinished); ///////////// ///////////// @@ -207,6 +212,52 @@ namespace cucumber::query // new ArrayMultimap() // private readonly undefinedParameterTypes: UndefinedParameterType[] = [] }; + + template + [[nodiscard]] std::vector> Query::FindAllTestCaseStartedOrderBy(Transform findOrderBy, Cmp order) const + { + using TransformResult = decltype(findOrderBy(std::declval(), std::declval>())); + + const auto allTestCaseStarted = FindAllTestCaseStarted(); + + std::vector, TransformResult>> transformed; + transformed.reserve(allTestCaseStarted.size()); + + auto withOrderBy = std::transform(allTestCaseStarted.begin(), allTestCaseStarted.end(), std::back_inserter(transformed), + [&](const auto& testCaseStarted) -> std::pair, TransformResult> + { + return { testCaseStarted, findOrderBy(*this, testCaseStarted) }; + }); + + std::sort(transformed.begin(), transformed.end(), + [&](const auto& lhs, const auto& rhs) + { + if (!lhs.second.has_value() && !rhs.second.has_value()) + { + return false; + } + if (!lhs.second.has_value()) + { + return true; + } + if (!rhs.second.has_value()) + { + return false; + } + + return order(lhs.second.value(), rhs.second.value()) < 0; + }); + + std::vector> result; + result.reserve(allTestCaseStarted.size()); + std::transform(transformed.begin(), transformed.end(), std::back_inserter(result), + [](const auto& pair) + { + return pair.first; + }); + + return result; + } } #endif diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 0ec842c0..75ef54fc 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -30,6 +30,16 @@ namespace cucumber::query return result; } + + // helper type for the visitor #4 + template + struct overloaded : Ts... + { + using Ts::operator()...; + }; + // explicit deduction guide (not needed as of C++20) + template + overloaded(Ts...) -> overloaded; } Lineage Lineage::operator+(const Lineage& other) const @@ -66,10 +76,10 @@ namespace cucumber::query // { // this.hookById.set(envelope.hook.id, envelope.hook) // } - // if (envelope.stepDefinition) - // { - // this.stepDefinitionById.set(envelope.stepDefinition.id, envelope.stepDefinition) - // } + if (envelope.stepDefinition.has_value()) + { + stepDefinitionById[envelope.stepDefinition.value()->id] = envelope.stepDefinition.value(); + } // if (envelope.testRunStarted) // { // this.testRunStarted = envelope.testRunStarted @@ -102,10 +112,10 @@ namespace cucumber::query { UpdateTestStepFinished(envelope.testStepFinished.value()); } - // if (envelope.testCaseFinished) - // { - // this.updateTestCaseFinished(envelope.testCaseFinished) - // } + if (envelope.testCaseFinished.has_value()) + { + UpdateTestCaseFinished(envelope.testCaseFinished.value()); + } // if (envelope.testRunFinished) // { // this.testRunFinished = envelope.testRunFinished @@ -135,13 +145,17 @@ namespace cucumber::query for (const auto& testCaseStarted : FindAllTestCaseStarted()) { auto allFinishedSteps = FindTestStepFinishedAndTestStepBy(testCaseStarted); - std::sort(allFinishedSteps.begin(), allFinishedSteps.end(), - [](const auto& lhs, const auto& rhs) - { - using underlying_type = std::underlying_type_t; - return static_cast(lhs.first->testStepResult->status) > static_cast(rhs.first->testStepResult->status); - }); - ++result[allFinishedSteps.front().first->testStepResult->status]; + if (!allFinishedSteps.empty()) + { + std::sort(allFinishedSteps.begin(), allFinishedSteps.end(), + [](const auto& lhs, const auto& rhs) + { + using underlying_type = std::underlying_type_t; + return static_cast(lhs.first->testStepResult->status) > static_cast(rhs.first->testStepResult->status); + }); + + ++result[allFinishedSteps.front().first->testStepResult->status]; + } } return result; @@ -190,7 +204,7 @@ namespace cucumber::query for (const auto& [testCaseStartedId, testCaseFinished] : testCaseFinishedByTestCaseStartedId) { - if (testCaseFinished->willBeRetried) + if (!testCaseFinished->willBeRetried) { result.push_back(testCaseFinished); } @@ -199,10 +213,68 @@ namespace cucumber::query return result; } - // [[nodiscard]] std::size_t Query::CountTestCasesStarted() const - // { - // return testCaseStartedById.size(); - // } + std::optional> Query::FindPickleBy( + std::variant, std::shared_ptr, std::shared_ptr> element) const + { + const auto testCase = std::visit( + [this](const auto& element) + { + return FindTestCaseBy(element); + }, + element); + + try + { + return pickleById.at(testCase.value()->pickleId); + } + catch (const std::out_of_range&) + { + return std::nullopt; + } + } + + std::optional> Query::FindTestCaseBy(std::variant, std::shared_ptr, + std::shared_ptr, std::shared_ptr> + element) const + { + const auto testCaseStarted = std::visit( + overloaded{ + [](std::shared_ptr element) -> std::optional> + { + return element; + }, + [this](auto element) -> std::optional> + { + return FindTestCaseStartedBy(element); + }, + }, + element); + + try + { + return testCaseById.at(testCaseStarted.value()->testCaseId); + } + catch (const std::out_of_range&) + { + return std::nullopt; + } + } + + std::optional> Query::FindTestCaseStartedBy( + std::variant, std::shared_ptr, std::shared_ptr> element) const + { + return std::visit( + [this](const auto& item) -> std::optional> + { + const auto iter = testCaseStartedById.find(item->testCaseStartedId); + if (iter != testCaseStartedById.end()) + { + return iter->second; + } + return std::nullopt; + }, + element); + } std::optional> Query::FindTestStepBy( std::variant, std::shared_ptr> element) const @@ -226,19 +298,20 @@ namespace cucumber::query const std::shared_ptr& testCaseStarted) const { std::vector, std::shared_ptr>> result; + const auto testStepsFinishedIter = testStepFinishedByTestCaseStartedId.find(testCaseStarted->id); - const auto& testStepsFinished = testStepFinishedByTestCaseStartedId.at(testCaseStarted->id); - - for (const auto& testStepFinished : testStepsFinished) + if (testStepsFinishedIter != testStepFinishedByTestCaseStartedId.end()) { - const auto& testStep = FindTestStepBy(testStepFinished); - if (!testStep) + for (const auto& testStepFinished : testStepsFinishedIter->second) { - throw std::out_of_range{ "Expected to find TestStep by TestStepFinished" }; + const auto& testStep = FindTestStepBy(testStepFinished); + if (!testStep) + { + throw std::out_of_range{ "Expected to find TestStep by TestStepFinished" }; + } + result.emplace_back(testStepFinished, *testStep); } - result.emplace_back(testStepFinished, *testStep); } - return result; } @@ -359,6 +432,11 @@ namespace cucumber::query testStepFinishedByTestCaseStartedId[testStepFinished->testCaseStartedId].push_back(std::move(testStepFinished)); } + void Query::UpdateTestCaseFinished(std::shared_ptr testCaseFinished) + { + testCaseFinishedByTestCaseStartedId[testCaseFinished->testCaseStartedId] = std::move(testCaseFinished); + } + ///////////////////////////// ///////////////////////////// ///////////////////////////// diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index 9fdd419c..f77e4572 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -3,14 +3,18 @@ #include "nlohmann/json_fwd.hpp" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include #include #include +#include +#include #include #include #include #include #include #include +#include #include #include #include @@ -118,11 +122,59 @@ namespace EXPECT_THAT(actual.size(), testing::Eq(expected.get())); } + void FindAllStepDefinitions(const cucumber::query::Query& query, const nlohmann::json& expected) + { + const auto actual = query.FindAllStepDefinitions(); + EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + } + + void FindAllTestCaseFinished(const cucumber::query::Query& query, const nlohmann::json& expected) + { + const auto actual = query.FindAllTestCaseFinished(); + EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + } + + void FindAllTestCaseStartedOrderBy(const cucumber::query::Query& query, const nlohmann::json& expected) + { + auto findOrderBy = [](const cucumber::query::Query& query, std::shared_ptr testCaseStarted) + { + return query.FindPickleBy(testCaseStarted); + }; + auto reversePickleComparator = [](const std::shared_ptr& lhs, const std::shared_ptr& rhs) + { + if (lhs->uri != rhs->uri) + { + return static_cast(lhs->uri.compare(rhs->uri)); + } + if (lhs->location.has_value() && rhs->location.has_value() && lhs->location.value()->line != rhs->location.value()->line) + { + return static_cast(rhs->location.value()->line) - static_cast(lhs->location.value()->line); + } + return static_cast(rhs->location.value()->column.value()) - static_cast(lhs->location.value()->column.value()); + }; + + const auto allResults = query.FindAllTestCaseStartedOrderBy(findOrderBy, reversePickleComparator); + nlohmann::json actual; + for (const auto& testCaseStarted : allResults) + { + actual.push_back(testCaseStarted->id); + } + + EXPECT_THAT(actual, testing::Eq(expected)); + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", &CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", &CountTestCasesStarted }, { "findAllPickles", &FindAllPickles }, { "findAllPickleSteps", &FindAllPickleSteps }, + { "findAllStepDefinitions", &FindAllStepDefinitions }, + { "findAllTestCaseFinished", &FindAllTestCaseFinished }, + // { "findAllTestCaseFinishedOrderBy", &FindAllTestCaseFinishedOrderBy }, + // { "findAllTestCases", &findAllTestCases }, + // { "findAllTestCaseStarted", &findAllTestCaseStarted }, + { "findAllTestCaseStartedOrderBy", &FindAllTestCaseStartedOrderBy }, + }; struct AcceptanceTest : testing::Test From 9bef1d841f33bf763cba8242bb15460311626ab6 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Wed, 22 Jul 2026 22:33:00 +0000 Subject: [PATCH 05/56] Enabled FindAllTestCaseFinishedOrderBy. FindAllTestCases, FindAllTestCaseStarted, FindAllTestRunHookFinished --- cpp/include/cucumber/query/Query.hpp | 154 +++++++++++++++------------ cpp/src/query/Query.cpp | 38 +++++-- cpp/test/TestQuery.cpp | 78 ++++++++++---- 3 files changed, 171 insertions(+), 99 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 0b90decd..5b7c8107 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -3,18 +3,17 @@ #include "cucumber/messages/All.hpp" #include "cucumber/messages/Envelope.hpp" +#include "cucumber/messages/Feature.hpp" +#include "cucumber/messages/GherkinDocument.hpp" +#include "cucumber/messages/Pickle.hpp" +#include "cucumber/messages/Rule.hpp" +#include "cucumber/messages/TestCase.hpp" #include "cucumber/messages/TestCaseStarted.hpp" +#include "cucumber/messages/TestStepFinished.hpp" #include "cucumber/messages/TestStepResultStatus.hpp" #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include @@ -63,29 +62,30 @@ namespace cucumber::query template [[nodiscard]] std::vector> FindAllTestCaseStartedOrderBy(TFind findOrderBy, Cmp order) const; - // template - // [[nodiscard]] std::vector> FindAllTestCaseFinishedOrderBy(TFind findOrderBy, Cmp order) const; + template + [[nodiscard]] std::vector> FindAllTestCaseFinishedOrderBy(TFind findOrderBy, Cmp order) const; + + // std::vector> FindAllTestSteps() + // ; - // FindAllTestSteps() - // : ReadonlyArray const; + [[nodiscard]] std::vector> FindAllTestCases() const; - // FindAllTestStepStarted() - // : ReadonlyArray const; + // std::vector> FindAllTestStepStarted() + // ; - // FindAllTestStepFinished() - // : ReadonlyArray const; + // std::vector> FindAllTestStepFinished() + // ; - // FindAllTestRunHookStarted() - // : ReadonlyArray const; + // std::vector> FindAllTestRunHookStarted() + // ; - // FindAllTestRunHookFinished() - // : ReadonlyArray const; + [[nodiscard]] std::vector> FindAllTestRunHookFinished() const; - // FindAllUndefinedParameterTypes() - // : ReadonlyArray const; + // std::vector> FindAllUndefinedParameterTypes() + // ; - // FindAttachmentsBy(element : TestStepFinished | TestRunHookFinished) - // : ReadonlyArray const; + // std::vector> FindAttachmentsBy(element : TestStepFinished | TestRunHookFinished) + // ; // FindHookBy(item : TestStep | TestRunHookStarted | TestRunHookFinished) // : Hook | undefined const; @@ -108,11 +108,11 @@ namespace cucumber::query // FindStepBy(pickleStep : PickleStep) // : Step | undefined const; - // FindStepDefinitionsBy(testStep : TestStep) - // : ReadonlyArray const; + // std::vector> FindStepDefinitionsBy(testStep : TestStep) + // ; - // findSuggestionsBy(element : PickleStep | Pickle) - // : ReadonlyArray const; + // std::vector> findSuggestionsBy(element : PickleStep | Pickle) + // ; // FindUnambiguousStepDefinitionBy(testStep : TestStep) // : StepDefinition | undefined const; @@ -148,11 +148,11 @@ namespace cucumber::query std::optional> FindTestStepBy( std::variant, std::shared_ptr> element) const; - // FindTestStepsStartedBy(element : TestCaseStarted | TestCaseFinished) - // : ReadonlyArray const; + // std::vector> FindTestStepsStartedBy(element : TestCaseStarted | TestCaseFinished) + // ; - // FindTestStepsFinishedBy(element : TestCaseStarted | TestCaseFinished) - // : ReadonlyArray const; + // std::vector> FindTestStepsFinishedBy(element : TestCaseStarted | TestCaseFinished) + // ; std::vector, std::shared_ptr>> FindTestStepFinishedAndTestStepBy( const std::shared_ptr& testCaseStarted) const; @@ -169,6 +169,8 @@ namespace cucumber::query void UpdateScenario(const std::shared_ptr& scenario, std::unique_ptr lineage); void UpdateSteps(const std::vector>& steps); void UpdatePickle(std::shared_ptr pickle); + void UpdateTestRunHookStarted(const std::shared_ptr& testRunHookStarted); + void UpdateTestRunHookFinished(const std::shared_ptr& testRunHookFinished); ///////////// ///////////// @@ -197,9 +199,8 @@ namespace cucumber::query std::unordered_map> testCaseById; std::unordered_map> testStepById; std::unordered_map> testCaseFinishedByTestCaseStartedId; - // private readonly testRunHookStartedById: std::unordered_map = new Map() - // private readonly testRunHookFinishedByTestRunHookStartedId: std::unordered_map = - // new Map() + std::unordered_map> testRunHookStartedById; + std::unordered_map> testRunHookFinishedByTestRunHookStartedId; // private readonly testStepStartedByTestCaseStartedId: ArrayMultistd::unordered_map = // new ArrayMultimap() std::unordered_map>> testStepFinishedByTestCaseStartedId; @@ -213,50 +214,63 @@ namespace cucumber::query // private readonly undefinedParameterTypes: UndefinedParameterType[] = [] }; - template - [[nodiscard]] std::vector> Query::FindAllTestCaseStartedOrderBy(Transform findOrderBy, Cmp order) const + namespace detail { - using TransformResult = decltype(findOrderBy(std::declval(), std::declval>())); - - const auto allTestCaseStarted = FindAllTestCaseStarted(); + template + [[nodiscard]] std::vector> FindAllOrderBy(const Query& query, const std::vector>& allElements, Transform findOrderBy, Cmp order) + { + using TransformResult = decltype(std::invoke(findOrderBy, query, std::declval>())); - std::vector, TransformResult>> transformed; - transformed.reserve(allTestCaseStarted.size()); + std::vector, TransformResult>> transformed; + transformed.reserve(allElements.size()); - auto withOrderBy = std::transform(allTestCaseStarted.begin(), allTestCaseStarted.end(), std::back_inserter(transformed), - [&](const auto& testCaseStarted) -> std::pair, TransformResult> + for (const auto& element : allElements) { - return { testCaseStarted, findOrderBy(*this, testCaseStarted) }; - }); + transformed.emplace_back(element, std::invoke(findOrderBy, query, element)); + } - std::sort(transformed.begin(), transformed.end(), - [&](const auto& lhs, const auto& rhs) - { - if (!lhs.second.has_value() && !rhs.second.has_value()) - { - return false; - } - if (!lhs.second.has_value()) + std::sort(transformed.begin(), transformed.end(), + [&](const auto& lhs, const auto& rhs) { - return true; - } - if (!rhs.second.has_value()) - { - return false; - } + const auto lhsHasValue = lhs.second.has_value(); + const auto rhsHasValue = rhs.second.has_value(); + if (!lhsHasValue && !rhsHasValue) + { + return false; + } + if (!lhsHasValue) + { + return true; + } + if (!rhsHasValue) + { + return false; + } + + return std::invoke(order, lhs.second.value(), rhs.second.value()) < 0; + }); + + std::vector> result; + result.reserve(allElements.size()); + for (const auto& pair : transformed) + { + result.push_back(pair.first); + } - return order(lhs.second.value(), rhs.second.value()) < 0; - }); + return result; + } + } - std::vector> result; - result.reserve(allTestCaseStarted.size()); - std::transform(transformed.begin(), transformed.end(), std::back_inserter(result), - [](const auto& pair) - { - return pair.first; - }); + template + [[nodiscard]] std::vector> Query::FindAllTestCaseStartedOrderBy(Transform findOrderBy, Cmp order) const + { + return detail::FindAllOrderBy(*this, FindAllTestCaseStarted(), std::move(findOrderBy), std::move(order)); + } - return result; + template + [[nodiscard]] std::vector> Query::FindAllTestCaseFinishedOrderBy(Transform findOrderBy, Cmp order) const + { + return detail::FindAllOrderBy(*this, FindAllTestCaseFinished(), std::move(findOrderBy), std::move(order)); } } diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 75ef54fc..1f03184d 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -1,9 +1,9 @@ #include "cucumber/query/Query.hpp" #include "cucumber/messages/All.hpp" +#include "cucumber/messages/TestStepResultStatus.hpp" #include #include #include -#include #include #include #include @@ -84,14 +84,14 @@ namespace cucumber::query // { // this.testRunStarted = envelope.testRunStarted // } - // if (envelope.testRunHookStarted) - // { - // this.updateTestRunHookStarted(envelope.testRunHookStarted) - // } - // if (envelope.testRunHookFinished) - // { - // this.updateTestRunHookFinished(envelope.testRunHookFinished) - // } + if (envelope.testRunHookStarted.has_value()) + { + UpdateTestRunHookStarted(envelope.testRunHookStarted.value()); + } + if (envelope.testRunHookFinished.has_value()) + { + UpdateTestRunHookFinished(envelope.testRunHookFinished.value()); + } if (envelope.testCase.has_value()) { UpdateTestCase(envelope.testCase.value()); @@ -213,6 +213,16 @@ namespace cucumber::query return result; } + std::vector> Query::FindAllTestCases() const + { + return MapValuesToVector(testCaseById); + } + + [[nodiscard]] std::vector> Query::FindAllTestRunHookFinished() const + { + return MapValuesToVector(testRunHookFinishedByTestRunHookStartedId); + } + std::optional> Query::FindPickleBy( std::variant, std::shared_ptr, std::shared_ptr> element) const { @@ -407,6 +417,16 @@ namespace cucumber::query } } + void Query::UpdateTestRunHookStarted(const std::shared_ptr& testRunHookStarted) + { + testRunHookStartedById[testRunHookStarted->id] = testRunHookStarted; + } + + void Query::UpdateTestRunHookFinished(const std::shared_ptr& testRunHookFinished) + { + testRunHookFinishedByTestRunHookStartedId[testRunHookFinished->testRunHookStartedId] = testRunHookFinished; + } + ///////////////////////////// ///////////////////////////// ///////////////////////////// diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index f77e4572..f505df38 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -1,3 +1,8 @@ +#include "cucumber/messages/Envelope.hpp" +#include "cucumber/messages/Pickle.hpp" +#include "cucumber/messages/TestCaseFinished.hpp" +#include "cucumber/messages/TestCaseStarted.hpp" +#include "cucumber/messages/TestStepResultStatus.hpp" #include "cucumber/query/Query.hpp" #include "nlohmann/json.hpp" #include "nlohmann/json_fwd.hpp" @@ -5,10 +10,6 @@ #include "gtest/gtest.h" #include #include -#include -#include -#include -#include #include #include #include @@ -52,6 +53,19 @@ namespace std::set> json; }; + std::int32_t ReversePickleComparator(const std::shared_ptr& lhs, const std::shared_ptr& rhs) + { + if (lhs->uri != rhs->uri) + { + return static_cast(lhs->uri.compare(rhs->uri)); + } + if (lhs->location.has_value() && rhs->location.has_value() && lhs->location.value()->line != rhs->location.value()->line) + { + return static_cast(rhs->location.value()->line) - static_cast(lhs->location.value()->line); + } + return static_cast(rhs->location.value()->column.value()) - static_cast(lhs->location.value()->column.value()); + }; + TestData GetTestFiles() { auto foundFiles = CollectFiles(TESTDATA_SRC); @@ -134,26 +148,43 @@ namespace EXPECT_THAT(actual.size(), testing::Eq(expected.get())); } + void FindAllTestCaseFinishedOrderBy(const cucumber::query::Query& query, const nlohmann::json& expected) + { + auto findOrderBy = [](const cucumber::query::Query& query, std::shared_ptr testCaseFinished) + { + return query.FindPickleBy(testCaseFinished); + }; + + const auto allResults = query.FindAllTestCaseFinishedOrderBy(findOrderBy, ReversePickleComparator); + nlohmann::json actual; + for (const auto& testCaseFinished : allResults) + { + actual.push_back(testCaseFinished->testCaseStartedId); + } + + EXPECT_THAT(actual, testing::Eq(expected)); + } + + void FindAllTestCases(const cucumber::query::Query& query, const nlohmann::json& expected) + { + const auto actual = query.FindAllTestCases(); + EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + } + + void FindAllTestCaseStarted(const cucumber::query::Query& query, const nlohmann::json& expected) + { + const auto actual = query.FindAllTestCaseStarted(); + EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + } + void FindAllTestCaseStartedOrderBy(const cucumber::query::Query& query, const nlohmann::json& expected) { auto findOrderBy = [](const cucumber::query::Query& query, std::shared_ptr testCaseStarted) { return query.FindPickleBy(testCaseStarted); }; - auto reversePickleComparator = [](const std::shared_ptr& lhs, const std::shared_ptr& rhs) - { - if (lhs->uri != rhs->uri) - { - return static_cast(lhs->uri.compare(rhs->uri)); - } - if (lhs->location.has_value() && rhs->location.has_value() && lhs->location.value()->line != rhs->location.value()->line) - { - return static_cast(rhs->location.value()->line) - static_cast(lhs->location.value()->line); - } - return static_cast(rhs->location.value()->column.value()) - static_cast(lhs->location.value()->column.value()); - }; - const auto allResults = query.FindAllTestCaseStartedOrderBy(findOrderBy, reversePickleComparator); + const auto allResults = query.FindAllTestCaseStartedOrderBy(findOrderBy, ReversePickleComparator); nlohmann::json actual; for (const auto& testCaseStarted : allResults) { @@ -163,6 +194,12 @@ namespace EXPECT_THAT(actual, testing::Eq(expected)); } + void FindAllTestRunHookFinished(const cucumber::query::Query& query, const nlohmann::json& expected) + { + const auto actual = query.FindAllTestRunHookFinished(); + EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", &CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", &CountTestCasesStarted }, @@ -170,10 +207,11 @@ namespace { "findAllPickleSteps", &FindAllPickleSteps }, { "findAllStepDefinitions", &FindAllStepDefinitions }, { "findAllTestCaseFinished", &FindAllTestCaseFinished }, - // { "findAllTestCaseFinishedOrderBy", &FindAllTestCaseFinishedOrderBy }, - // { "findAllTestCases", &findAllTestCases }, - // { "findAllTestCaseStarted", &findAllTestCaseStarted }, + { "findAllTestCaseFinishedOrderBy", &FindAllTestCaseFinishedOrderBy }, + { "findAllTestCases", &FindAllTestCases }, + { "findAllTestCaseStarted", &FindAllTestCaseStarted }, { "findAllTestCaseStartedOrderBy", &FindAllTestCaseStartedOrderBy }, + { "findAllTestRunHookFinished", &FindAllTestRunHookFinished }, }; From ca7a991bb1a3b0144f3da2d795470cbc905ddaa0 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Thu, 23 Jul 2026 15:42:22 +0000 Subject: [PATCH 06/56] let each test return a json object --- cpp/test/TestQuery.cpp | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index f505df38..24e52016 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -106,7 +106,7 @@ namespace return str; } - void CountMostSevereTestStepResultStatus(const cucumber::query::Query& query, const nlohmann::json& expected) + nlohmann::json CountMostSevereTestStepResultStatus(const cucumber::query::Query& query) { const auto allResults = query.CountMostSevereTestStepResultStatus(); nlohmann::json actual; @@ -115,40 +115,40 @@ namespace actual[to_string(status)] = count; } - EXPECT_THAT(actual, testing::Eq(expected)); + return actual; } - void CountTestCasesStarted(const cucumber::query::Query& query, const nlohmann::json& expected) + nlohmann::json CountTestCasesStarted(const cucumber::query::Query& query) { const auto actual = query.CountTestCasesStarted(); - EXPECT_THAT(actual, testing::Eq(expected.get())); + return actual; } - void FindAllPickles(const cucumber::query::Query& query, const nlohmann::json& expected) + nlohmann::json FindAllPickles(const cucumber::query::Query& query) { const auto actual = query.FindAllPickles(); - EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + return actual.size(); } - void FindAllPickleSteps(const cucumber::query::Query& query, const nlohmann::json& expected) + nlohmann::json FindAllPickleSteps(const cucumber::query::Query& query) { const auto actual = query.FindAllPickleSteps(); - EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + return actual.size(); } - void FindAllStepDefinitions(const cucumber::query::Query& query, const nlohmann::json& expected) + nlohmann::json FindAllStepDefinitions(const cucumber::query::Query& query) { const auto actual = query.FindAllStepDefinitions(); - EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + return actual.size(); } - void FindAllTestCaseFinished(const cucumber::query::Query& query, const nlohmann::json& expected) + nlohmann::json FindAllTestCaseFinished(const cucumber::query::Query& query) { const auto actual = query.FindAllTestCaseFinished(); - EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + return actual.size(); } - void FindAllTestCaseFinishedOrderBy(const cucumber::query::Query& query, const nlohmann::json& expected) + nlohmann::json FindAllTestCaseFinishedOrderBy(const cucumber::query::Query& query) { auto findOrderBy = [](const cucumber::query::Query& query, std::shared_ptr testCaseFinished) { @@ -162,22 +162,22 @@ namespace actual.push_back(testCaseFinished->testCaseStartedId); } - EXPECT_THAT(actual, testing::Eq(expected)); + return actual; } - void FindAllTestCases(const cucumber::query::Query& query, const nlohmann::json& expected) + nlohmann::json FindAllTestCases(const cucumber::query::Query& query) { const auto actual = query.FindAllTestCases(); - EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + return actual.size(); } - void FindAllTestCaseStarted(const cucumber::query::Query& query, const nlohmann::json& expected) + nlohmann::json FindAllTestCaseStarted(const cucumber::query::Query& query) { const auto actual = query.FindAllTestCaseStarted(); - EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + return actual.size(); } - void FindAllTestCaseStartedOrderBy(const cucumber::query::Query& query, const nlohmann::json& expected) + nlohmann::json FindAllTestCaseStartedOrderBy(const cucumber::query::Query& query) { auto findOrderBy = [](const cucumber::query::Query& query, std::shared_ptr testCaseStarted) { @@ -191,16 +191,16 @@ namespace actual.push_back(testCaseStarted->id); } - EXPECT_THAT(actual, testing::Eq(expected)); + return actual; } - void FindAllTestRunHookFinished(const cucumber::query::Query& query, const nlohmann::json& expected) + nlohmann::json FindAllTestRunHookFinished(const cucumber::query::Query& query) { const auto actual = query.FindAllTestRunHookFinished(); - EXPECT_THAT(actual.size(), testing::Eq(expected.get())); + return actual.size(); } - const std::unordered_map functionMap{ + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", &CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", &CountTestCasesStarted }, { "findAllPickles", &FindAllPickles }, @@ -233,7 +233,7 @@ namespace GTEST_SKIP() << "No function registered for test case: " << testCaseName; } - // loadQuery + // load Query with messages { std::ifstream ifstream{ input }; std::string line; @@ -248,7 +248,7 @@ namespace { std::ifstream ifstream{ expected }; - functionMap.at(testCaseName)(query, nlohmann::json::parse(ifstream)); + EXPECT_THAT(functionMap.at(testCaseName)(query), testing::Eq(nlohmann::json::parse(ifstream))); } } From fcb6d2bb0431abfbd951dce01b381bf63e9bc948 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Thu, 6 Aug 2026 21:39:57 +0000 Subject: [PATCH 07/56] Added findAllTestRunHookStarted, findAllTestStepFinished, findAllTestSteps, findAllTestStepStarted, findAllUndefinedParameterTypes, findAttachmentsBy --- cpp/include/cucumber/query/Query.hpp | 54 ++-- cpp/src/query/Query.cpp | 138 ++++++++-- cpp/test/TestQuery.cpp | 395 +++++++++++++++------------ 3 files changed, 356 insertions(+), 231 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 5b7c8107..d6dc8c7c 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -65,27 +65,22 @@ namespace cucumber::query template [[nodiscard]] std::vector> FindAllTestCaseFinishedOrderBy(TFind findOrderBy, Cmp order) const; - // std::vector> FindAllTestSteps() - // ; + [[nodiscard]] std::vector> FindAllTestSteps() const; [[nodiscard]] std::vector> FindAllTestCases() const; - // std::vector> FindAllTestStepStarted() - // ; + [[nodiscard]] std::vector> FindAllTestStepStarted() const; - // std::vector> FindAllTestStepFinished() - // ; + [[nodiscard]] std::vector> FindAllTestStepFinished() const; - // std::vector> FindAllTestRunHookStarted() - // ; + [[nodiscard]] std::vector> FindAllTestRunHookStarted() const; [[nodiscard]] std::vector> FindAllTestRunHookFinished() const; - // std::vector> FindAllUndefinedParameterTypes() - // ; + [[nodiscard]] std::vector> FindAllUndefinedParameterTypes() const; - // std::vector> FindAttachmentsBy(element : TestStepFinished | TestRunHookFinished) - // ; + [[nodiscard]] std::vector> FindAttachmentsBy( + std::variant, std::shared_ptr> element) const; // FindHookBy(item : TestStep | TestRunHookStarted | TestRunHookFinished) // : Hook | undefined const; @@ -108,11 +103,9 @@ namespace cucumber::query // FindStepBy(pickleStep : PickleStep) // : Step | undefined const; - // std::vector> FindStepDefinitionsBy(testStep : TestStep) - // ; + // [[nodiscard]] std::vector> FindStepDefinitionsBy(testStep : TestStep) const; - // std::vector> findSuggestionsBy(element : PickleStep | Pickle) - // ; + // [[nodiscard]] std::vector> findSuggestionsBy(element : PickleStep | Pickle) const; // FindUnambiguousStepDefinitionBy(testStep : TestStep) // : StepDefinition | undefined const; @@ -145,22 +138,21 @@ namespace cucumber::query // FindTestRunStarted() // : TestRunStarted | undefined const; - std::optional> FindTestStepBy( + [[nodiscard]] std::optional> FindTestStepBy( std::variant, std::shared_ptr> element) const; - // std::vector> FindTestStepsStartedBy(element : TestCaseStarted | TestCaseFinished) - // ; + // [[nodiscard]] std::vector> FindTestStepsStartedBy(element : TestCaseStarted | TestCaseFinished) const; - // std::vector> FindTestStepsFinishedBy(element : TestCaseStarted | TestCaseFinished) - // ; + [[nodiscard]] std::vector> FindTestStepsFinishedBy( + std::variant, std::shared_ptr> element) const; - std::vector, std::shared_ptr>> FindTestStepFinishedAndTestStepBy( + [[nodiscard]] std::vector, std::shared_ptr>> FindTestStepFinishedAndTestStepBy( const std::shared_ptr& testCaseStarted) const; // FindLineageBy(element : Pickle | TestCaseStarted | TestCaseFinished) // : Lineage | undefined const; - // [[nodiscard]] std::size_t CountTestCasesStarted() const; + // [[nodiscard]] std::size_t CountTestCasesStarted() const; const; private: void UpdateGherkinDocument(const std::shared_ptr& gherkinDocument); @@ -180,6 +172,7 @@ namespace cucumber::query void UpdateTestCaseStarted(std::shared_ptr testCaseStarted); ///////////// + void UpdateAttachment(const std::shared_ptr& attachment); void UpdateTestStepFinished(std::shared_ptr testStepFinished); void UpdateTestCaseFinished(std::shared_ptr testCaseFinished); ///////////// @@ -201,17 +194,12 @@ namespace cucumber::query std::unordered_map> testCaseFinishedByTestCaseStartedId; std::unordered_map> testRunHookStartedById; std::unordered_map> testRunHookFinishedByTestRunHookStartedId; - // private readonly testStepStartedByTestCaseStartedId: ArrayMultistd::unordered_map = - // new ArrayMultimap() + std::unordered_map>> testStepStartedByTestCaseStartedId; std::unordered_map>> testStepFinishedByTestCaseStartedId; - // new ArrayMultimap() - // private readonly attachmentsByTestCaseStartedId: ArrayMultistd::unordered_map = - // new ArrayMultimap() - // private readonly attachmentsByTestRunHookStartedId: ArrayMultistd::unordered_map = - // new ArrayMultimap() - // private readonly suggestionsByPickleStepId: ArrayMultistd::unordered_map = - // new ArrayMultimap() - // private readonly undefinedParameterTypes: UndefinedParameterType[] = [] + std::unordered_map>> attachmentsByTestCaseStartedId; + std::unordered_map>> attachmentsByTestRunHookStartedId; + // std::unordered_map> suggestionsByPickleStepId; + std::vector> undefinedParameterTypes; }; namespace detail diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 1f03184d..5927a302 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -17,10 +18,10 @@ namespace cucumber::query { namespace { - template - auto MapValuesToVector(const C& container) + template + auto MapValuesToVector(const std::unordered_map& container) { - std::vector result; + std::vector result; result.reserve(container.size()); for (const auto& [key, value] : container) @@ -31,7 +32,20 @@ namespace cucumber::query return result; } - // helper type for the visitor #4 + template + auto MapValuesToVector(const std::unordered_map>& container) + { + std::vector result; + result.reserve(container.size()); + + for (const auto& [key, value] : container) + { + result.insert(result.end(), value.begin(), value.end()); + } + + return result; + } + template struct overloaded : Ts... { @@ -100,14 +114,14 @@ namespace cucumber::query { UpdateTestCaseStarted(envelope.testCaseStarted.value()); } - // if (envelope.testStepStarted) - // { - // this.updateTestStepStarted(envelope.testStepStarted) - // } - // if (envelope.attachment) - // { - // this.updateAttachment(envelope.attachment) - // } + if (envelope.testStepStarted.has_value()) + { + testStepStartedByTestCaseStartedId[envelope.testStepStarted.value()->testCaseStartedId].push_back(envelope.testStepStarted.value()); + } + if (envelope.attachment.has_value()) + { + UpdateAttachment(envelope.attachment.value()); + } if (envelope.testStepFinished.has_value()) { UpdateTestStepFinished(envelope.testStepFinished.value()); @@ -124,10 +138,10 @@ namespace cucumber::query // { // this.updateSuggestion(envelope.suggestion) // } - // if (envelope.undefinedParameterType) - // { - // this.updateUndefinedParameterType(envelope.undefinedParameterType) - // } + if (envelope.undefinedParameterType.has_value()) + { + undefinedParameterTypes.push_back(envelope.undefinedParameterType.value()); + } } std::unordered_map Query::CountMostSevereTestStepResultStatus() const @@ -213,16 +227,73 @@ namespace cucumber::query return result; } + std::vector> Query::FindAllTestSteps() const + { + return MapValuesToVector(testStepById); + } + std::vector> Query::FindAllTestCases() const { return MapValuesToVector(testCaseById); } - [[nodiscard]] std::vector> Query::FindAllTestRunHookFinished() const + std::vector> Query::FindAllTestStepStarted() const + { + return MapValuesToVector(testStepStartedByTestCaseStartedId); + } + + std::vector> Query::FindAllTestStepFinished() const + { + return MapValuesToVector(testStepFinishedByTestCaseStartedId); + } + + std::vector> Query::FindAllTestRunHookStarted() const + { + return MapValuesToVector(testRunHookStartedById); + } + + std::vector> Query::FindAllTestRunHookFinished() const { return MapValuesToVector(testRunHookFinishedByTestRunHookStartedId); } + std::vector> Query::FindAllUndefinedParameterTypes() const + { + return undefinedParameterTypes; + } + + std::vector> Query::FindAttachmentsBy( + std::variant, std::shared_ptr> element) const + { + return std::visit( + overloaded{ + [this](const std::shared_ptr& element) + { + std::vector> result; + if (attachmentsByTestCaseStartedId.find(element->testCaseStartedId) != attachmentsByTestCaseStartedId.end()) + { + for (const auto& attachment : attachmentsByTestCaseStartedId.at(element->testCaseStartedId)) + { + if (attachment->testStepId == element->testStepId) + { + result.push_back(attachment); + } + } + } + return result; + }, + [this](const std::shared_ptr& element) + { + if (attachmentsByTestRunHookStartedId.find(element->testRunHookStartedId) != attachmentsByTestRunHookStartedId.end()) + { + return attachmentsByTestRunHookStartedId.at(element->testRunHookStartedId); + } + return std::vector>{}; + }, + }, + element); + } + std::optional> Query::FindPickleBy( std::variant, std::shared_ptr, std::shared_ptr> element) const { @@ -304,6 +375,27 @@ namespace cucumber::query } } + std::vector> Query::FindTestStepsFinishedBy( + std::variant, std::shared_ptr> element) const + { + const auto& optionalTestCaseStarted = std::visit(overloaded{ [this](const std::shared_ptr& element) + { + return FindTestCaseStartedBy(element); + }, + [](const auto& element) -> std::optional> + { + return element; + } }, + element); + + if (optionalTestCaseStarted.has_value() && testStepFinishedByTestCaseStartedId.find(optionalTestCaseStarted.value()->id) != testStepFinishedByTestCaseStartedId.end()) + { + return testStepFinishedByTestCaseStartedId.at(optionalTestCaseStarted.value()->id); + } + + return {}; + } + std::vector, std::shared_ptr>> Query::FindTestStepFinishedAndTestStepBy( const std::shared_ptr& testCaseStarted) const { @@ -447,6 +539,18 @@ namespace cucumber::query ///////////////////////////// + void Query::UpdateAttachment(const std::shared_ptr& attachment) + { + if (attachment->testCaseStartedId.has_value()) + { + attachmentsByTestCaseStartedId[attachment->testCaseStartedId.value()].push_back(attachment); + } + if (attachment->testRunHookStartedId.has_value()) + { + attachmentsByTestRunHookStartedId[attachment->testRunHookStartedId.value()].push_back(attachment); + } + } + void Query::UpdateTestStepFinished(std::shared_ptr testStepFinished) { testStepFinishedByTestCaseStartedId[testStepFinished->testCaseStartedId].push_back(std::move(testStepFinished)); diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index 24e52016..2dff90d1 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -1,13 +1,11 @@ -#include "cucumber/messages/Envelope.hpp" -#include "cucumber/messages/Pickle.hpp" -#include "cucumber/messages/TestCaseFinished.hpp" -#include "cucumber/messages/TestCaseStarted.hpp" +#include "cucumber/messages/All.hpp" #include "cucumber/messages/TestStepResultStatus.hpp" #include "cucumber/query/Query.hpp" #include "nlohmann/json.hpp" #include "nlohmann/json_fwd.hpp" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include #include #include #include @@ -16,251 +14,286 @@ #include #include #include +#include #include #include #include #include #include +#include #include TEST(first, second) {} -namespace +namespace cucumber::query { - std::set> CollectFiles(const std::filesystem::path& folder) + namespace { - std::set> foundFiles; - - for (const auto& entry : std::filesystem::directory_iterator{ folder }) + std::set> CollectFiles(const std::filesystem::path& folder) { - foundFiles.emplace(entry.path()); - } - - return foundFiles; - } + std::set> foundFiles; - struct TestData - { - std::list ndjson; - std::list json; - std::set> txt; - }; - - struct TestSet - { - std::filesystem::path ndjson; - std::set> json; - }; + for (const auto& entry : std::filesystem::directory_iterator{ folder }) + { + foundFiles.emplace(entry.path()); + } - std::int32_t ReversePickleComparator(const std::shared_ptr& lhs, const std::shared_ptr& rhs) - { - if (lhs->uri != rhs->uri) - { - return static_cast(lhs->uri.compare(rhs->uri)); + return foundFiles; } - if (lhs->location.has_value() && rhs->location.has_value() && lhs->location.value()->line != rhs->location.value()->line) - { - return static_cast(rhs->location.value()->line) - static_cast(lhs->location.value()->line); - } - return static_cast(rhs->location.value()->column.value()) - static_cast(lhs->location.value()->column.value()); - }; - TestData GetTestFiles() - { - auto foundFiles = CollectFiles(TESTDATA_SRC); + struct TestData + { + std::list ndjson; + std::list json; + std::set> txt; + }; - TestData testData{}; + struct TestSet + { + std::filesystem::path ndjson; + std::set> json; + }; - while (!foundFiles.empty()) + std::int32_t ReversePickleComparator(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - const auto begin = foundFiles.begin(); - if (begin->extension() == ".ndjson") - { - testData.ndjson.emplace_back(std::move(foundFiles.extract(begin).value())); - } - else if (begin->extension() == ".json") - { - testData.json.emplace_back(std::move(foundFiles.extract(begin).value())); - } - else if (begin->extension() == ".txt") + if (lhs->uri != rhs->uri) { - testData.txt.emplace(std::move(foundFiles.extract(begin).value())); + return static_cast(lhs->uri.compare(rhs->uri)); } - else + if (lhs->location.has_value() && rhs->location.has_value() && lhs->location.value()->line != rhs->location.value()->line) { - throw "unknown extension:" + begin->extension().string(); + return static_cast(rhs->location.value()->line) - static_cast(lhs->location.value()->line); } - } - - return testData; - } + return static_cast(rhs->location.value()->column.value()) - static_cast(lhs->location.value()->column.value()); + }; - std::string FilterName(std::string str) - { - for (auto iter = str.find('-'); iter != std::string::npos; iter = str.find('-')) + std::optional> FindPickleBy(const query::Query& query, + std::variant, std::shared_ptr, std::shared_ptr> element) { - str.replace(iter, 1, "_"); - } - - return str; - } + return query.FindPickleBy(std::move(element)); + }; - nlohmann::json CountMostSevereTestStepResultStatus(const cucumber::query::Query& query) - { - const auto allResults = query.CountMostSevereTestStepResultStatus(); - nlohmann::json actual; - for (const auto& [status, count] : allResults) + template + nlohmann::json GetSizeOf(const query::Query& query) { - actual[to_string(status)] = count; + const auto actual = (query.*F)(); + return actual.size(); } - return actual; - } + nlohmann::json CountMostSevereTestStepResultStatus(const query::Query& query) + { + nlohmann::json actual; - nlohmann::json CountTestCasesStarted(const cucumber::query::Query& query) - { - const auto actual = query.CountTestCasesStarted(); - return actual; - } + for (const auto& [status, count] : query.CountMostSevereTestStepResultStatus()) + { + actual[to_string(status)] = count; + } - nlohmann::json FindAllPickles(const cucumber::query::Query& query) - { - const auto actual = query.FindAllPickles(); - return actual.size(); - } + return actual; + } - nlohmann::json FindAllPickleSteps(const cucumber::query::Query& query) - { - const auto actual = query.FindAllPickleSteps(); - return actual.size(); - } + nlohmann::json CountTestCasesStarted(const query::Query& query) + { + const auto actual = query.CountTestCasesStarted(); + return actual; + } - nlohmann::json FindAllStepDefinitions(const cucumber::query::Query& query) - { - const auto actual = query.FindAllStepDefinitions(); - return actual.size(); - } + nlohmann::json FindAllTestCaseFinishedOrderBy(const query::Query& query) + { + const auto allResults = query.FindAllTestCaseFinishedOrderBy(FindPickleBy, ReversePickleComparator); + nlohmann::json actual; + for (const auto& testCaseFinished : allResults) + { + actual.push_back(testCaseFinished->testCaseStartedId); + } - nlohmann::json FindAllTestCaseFinished(const cucumber::query::Query& query) - { - const auto actual = query.FindAllTestCaseFinished(); - return actual.size(); - } + return actual; + } - nlohmann::json FindAllTestCaseFinishedOrderBy(const cucumber::query::Query& query) - { - auto findOrderBy = [](const cucumber::query::Query& query, std::shared_ptr testCaseFinished) + nlohmann::json FindAllTestCaseStartedOrderBy(const query::Query& query) { - return query.FindPickleBy(testCaseFinished); - }; + const auto allResults = query.FindAllTestCaseStartedOrderBy(&FindPickleBy, ReversePickleComparator); + nlohmann::json actual; + for (const auto& testCaseStarted : allResults) + { + actual.push_back(testCaseStarted->id); + } - const auto allResults = query.FindAllTestCaseFinishedOrderBy(findOrderBy, ReversePickleComparator); - nlohmann::json actual; - for (const auto& testCaseFinished : allResults) - { - actual.push_back(testCaseFinished->testCaseStartedId); + return actual; } - return actual; - } + nlohmann::json FindAllUndefinedParameterTypes(query::Query const& query) + { + nlohmann::json actual = nlohmann::json::array(); - nlohmann::json FindAllTestCases(const cucumber::query::Query& query) - { - const auto actual = query.FindAllTestCases(); - return actual.size(); - } + for (const auto& undefinedParameterType : query.FindAllUndefinedParameterTypes()) + { + actual.push_back({ undefinedParameterType->name, undefinedParameterType->expression }); + } - nlohmann::json FindAllTestCaseStarted(const cucumber::query::Query& query) - { - const auto actual = query.FindAllTestCaseStarted(); - return actual.size(); - } + return actual; + } - nlohmann::json FindAllTestCaseStartedOrderBy(const cucumber::query::Query& query) - { - auto findOrderBy = [](const cucumber::query::Query& query, std::shared_ptr testCaseStarted) + nlohmann::json FindAttachmentsBy(const query::Query& query) { - return query.FindPickleBy(testCaseStarted); - }; + nlohmann::json actual = { { "testStepFinished", nlohmann::json::array() }, { "testRunHookFinished", nlohmann::json::array() } }; - const auto allResults = query.FindAllTestCaseStartedOrderBy(findOrderBy, ReversePickleComparator); - nlohmann::json actual; - for (const auto& testCaseStarted : allResults) - { - actual.push_back(testCaseStarted->id); - } + const auto& allTestCaseStarted = query.FindAllTestCaseStarted(); + for (const auto& testCaseStarted : allTestCaseStarted) + { + const auto& allFinishedSteps = query.FindTestStepsFinishedBy(testCaseStarted); + for (const auto& testStepFinished : allFinishedSteps) + { + const auto& attachments = query.FindAttachmentsBy(testStepFinished); - return actual; - } + for (const auto& attachment : attachments) + { + actual["testStepFinished"].push_back({ attachment->testStepId, attachment->testCaseStartedId, attachment->mediaType, attachment->contentEncoding }); + } + } + } - nlohmann::json FindAllTestRunHookFinished(const cucumber::query::Query& query) - { - const auto actual = query.FindAllTestRunHookFinished(); - return actual.size(); - } + const auto& allTestRunHookFinished = query.FindAllTestRunHookFinished(); + for (const auto& testRunHookFinished : allTestRunHookFinished) + { + const auto& attachments = query.FindAttachmentsBy(testRunHookFinished); - const std::unordered_map functionMap{ - { "countMostSevereTestStepResultStatus", &CountMostSevereTestStepResultStatus }, - { "countTestCasesStarted", &CountTestCasesStarted }, - { "findAllPickles", &FindAllPickles }, - { "findAllPickleSteps", &FindAllPickleSteps }, - { "findAllStepDefinitions", &FindAllStepDefinitions }, - { "findAllTestCaseFinished", &FindAllTestCaseFinished }, - { "findAllTestCaseFinishedOrderBy", &FindAllTestCaseFinishedOrderBy }, - { "findAllTestCases", &FindAllTestCases }, - { "findAllTestCaseStarted", &FindAllTestCaseStarted }, - { "findAllTestCaseStartedOrderBy", &FindAllTestCaseStartedOrderBy }, - { "findAllTestRunHookFinished", &FindAllTestRunHookFinished }, - - }; - - struct AcceptanceTest : testing::Test - { - AcceptanceTest(std::filesystem::path input, std::filesystem::path expected) - : input{ std::move(input) } - , expected{ std::move(expected) } - {} + for (const auto& attachment : attachments) + { + actual["testRunHookFinished"].push_back({ attachment->testRunHookStartedId, attachment->mediaType, attachment->contentEncoding }); + } + } - private: - void TestBody() override - { - const auto* testInfo = testing::UnitTest::GetInstance()->current_test_info(); - const auto* testCaseName = testInfo->name(); + if (actual["testStepFinished"].is_array()) + { + std::sort(actual["testStepFinished"].begin(), actual["testStepFinished"].end(), + [](const nlohmann::json& lhs, const nlohmann::json& rhs) + { + return std::stoi(lhs[0].get()) < std::stoi(rhs[0].get()); + }); + } - if (functionMap.find(testCaseName) == functionMap.end()) + if (actual["testRunHookFinished"].is_array()) { - GTEST_SKIP() << "No function registered for test case: " << testCaseName; + std::sort(actual["testRunHookFinished"].begin(), actual["testRunHookFinished"].end(), + [](const nlohmann::json& lhs, const nlohmann::json& rhs) + { + return std::stoi(lhs[0].get()) < std::stoi(rhs[0].get()); + }); } - // load Query with messages + return actual; + } + + const std::unordered_map functionMap{ + { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, + { "countTestCasesStarted", CountTestCasesStarted }, + { "findAllPickles", GetSizeOf<&query::Query::FindAllPickles> }, + { "findAllPickleSteps", GetSizeOf<&query::Query::FindAllPickleSteps> }, + { "findAllStepDefinitions", GetSizeOf<&query::Query::FindAllStepDefinitions> }, + { "findAllTestCaseFinished", GetSizeOf<&query::Query::FindAllTestCaseFinished> }, + { "findAllTestCaseFinishedOrderBy", FindAllTestCaseFinishedOrderBy }, + { "findAllTestCases", GetSizeOf<&query::Query::FindAllTestCases> }, + { "findAllTestCaseStarted", GetSizeOf<&query::Query::FindAllTestCaseStarted> }, + { "findAllTestCaseStartedOrderBy", FindAllTestCaseStartedOrderBy }, + { "findAllTestRunHookFinished", GetSizeOf<&query::Query::FindAllTestRunHookFinished> }, + { "findAllTestRunHookStarted", GetSizeOf<&query::Query::FindAllTestRunHookStarted> }, + { "findAllTestStepFinished", GetSizeOf<&query::Query::FindAllTestStepFinished> }, + { "findAllTestSteps", GetSizeOf<&query::Query::FindAllTestSteps> }, + { "findAllTestStepStarted", GetSizeOf<&query::Query::FindAllTestStepStarted> }, + { "findAllUndefinedParameterTypes", FindAllUndefinedParameterTypes }, + { "findAttachmentsBy", FindAttachmentsBy }, + }; + + struct AcceptanceTest : testing::Test + { + AcceptanceTest(std::filesystem::path input, std::filesystem::path expected) + : input{ std::move(input) } + , expected{ std::move(expected) } + {} + + private: + void TestBody() override { - std::ifstream ifstream{ input }; - std::string line; - while (std::getline(ifstream, line)) + const auto* testInfo = testing::UnitTest::GetInstance()->current_test_info(); + const auto* testCaseName = testInfo->name(); + + if (functionMap.find(testCaseName) == functionMap.end()) { - cucumber::messages::Envelope envelope; - envelope.from_json(nlohmann::json::parse(line)); + GTEST_SKIP() << "No function registered for test case: " << testCaseName; + } - query.Update(envelope); + // load Query with messages + { + std::ifstream ifstream{ input }; + std::string line; + while (std::getline(ifstream, line)) + { + messages::Envelope envelope; + envelope.from_json(nlohmann::json::parse(line)); + + query.Update(envelope); + } + } + + { + std::ifstream ifstream{ expected }; + EXPECT_THAT(functionMap.at(testCaseName)(query), testing::Eq(nlohmann::json::parse(ifstream))); } } + query::Query query; + + std::filesystem::path input; + std::filesystem::path expected; + }; + + TestData GetTestFiles() + { + auto foundFiles = CollectFiles(TESTDATA_SRC); + + TestData testData{}; + + while (!foundFiles.empty()) { - std::ifstream ifstream{ expected }; - EXPECT_THAT(functionMap.at(testCaseName)(query), testing::Eq(nlohmann::json::parse(ifstream))); + const auto begin = foundFiles.begin(); + if (begin->extension() == ".ndjson") + { + testData.ndjson.emplace_back(std::move(foundFiles.extract(begin).value())); + } + else if (begin->extension() == ".json") + { + testData.json.emplace_back(std::move(foundFiles.extract(begin).value())); + } + else if (begin->extension() == ".txt") + { + testData.txt.emplace(std::move(foundFiles.extract(begin).value())); + } + else + { + throw "unknown extension:" + begin->extension().string(); + } } + + return testData; } - cucumber::query::Query query; + std::string FilterName(std::string str) + { + for (auto iter = str.find('-'); iter != std::string::npos; iter = str.find('-')) + { + str.replace(iter, 1, "_"); + } - std::filesystem::path input; - std::filesystem::path expected; - }; + return str; + } + } } GTEST_API_ int main(int argc, char** argv) { + using namespace cucumber::query; auto testData = GetTestFiles(); std::vector testSets{}; From 14572b514552f04a70712a4d4a7a67bec6624504 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Thu, 6 Aug 2026 22:27:22 +0000 Subject: [PATCH 08/56] removed obsolete tests --- ...findAttachmentsByTestRunHookFinished.results.json | 1 - ...findAttachmentsByTestRunHookFinished.results.json | 1 - ...findAttachmentsByTestRunHookFinished.results.json | 1 - ...findAttachmentsByTestRunHookFinished.results.json | 12 ------------ ...findAttachmentsByTestRunHookFinished.results.json | 1 - ...findAttachmentsByTestRunHookFinished.results.json | 1 - ...findAttachmentsByTestRunHookFinished.results.json | 1 - ...findAttachmentsByTestRunHookFinished.results.json | 1 - 8 files changed, 19 deletions(-) delete mode 100644 testdata/src/attachments.findAttachmentsByTestRunHookFinished.results.json delete mode 100644 testdata/src/empty.findAttachmentsByTestRunHookFinished.results.json delete mode 100644 testdata/src/examples-tables.findAttachmentsByTestRunHookFinished.results.json delete mode 100644 testdata/src/global-hooks-attachments.findAttachmentsByTestRunHookFinished.results.json delete mode 100644 testdata/src/global-hooks.findAttachmentsByTestRunHookFinished.results.json delete mode 100644 testdata/src/hooks.findAttachmentsByTestRunHookFinished.results.json delete mode 100644 testdata/src/minimal.findAttachmentsByTestRunHookFinished.results.json delete mode 100644 testdata/src/rules.findAttachmentsByTestRunHookFinished.results.json diff --git a/testdata/src/attachments.findAttachmentsByTestRunHookFinished.results.json b/testdata/src/attachments.findAttachmentsByTestRunHookFinished.results.json deleted file mode 100644 index 8878e547..00000000 --- a/testdata/src/attachments.findAttachmentsByTestRunHookFinished.results.json +++ /dev/null @@ -1 +0,0 @@ -[ ] \ No newline at end of file diff --git a/testdata/src/empty.findAttachmentsByTestRunHookFinished.results.json b/testdata/src/empty.findAttachmentsByTestRunHookFinished.results.json deleted file mode 100644 index 8878e547..00000000 --- a/testdata/src/empty.findAttachmentsByTestRunHookFinished.results.json +++ /dev/null @@ -1 +0,0 @@ -[ ] \ No newline at end of file diff --git a/testdata/src/examples-tables.findAttachmentsByTestRunHookFinished.results.json b/testdata/src/examples-tables.findAttachmentsByTestRunHookFinished.results.json deleted file mode 100644 index 8878e547..00000000 --- a/testdata/src/examples-tables.findAttachmentsByTestRunHookFinished.results.json +++ /dev/null @@ -1 +0,0 @@ -[ ] \ No newline at end of file diff --git a/testdata/src/global-hooks-attachments.findAttachmentsByTestRunHookFinished.results.json b/testdata/src/global-hooks-attachments.findAttachmentsByTestRunHookFinished.results.json deleted file mode 100644 index 7508f5ef..00000000 --- a/testdata/src/global-hooks-attachments.findAttachmentsByTestRunHookFinished.results.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - [ - "8", - "text/plain", - "IDENTITY" - ], - [ - "12", - "text/plain", - "IDENTITY" - ] -] \ No newline at end of file diff --git a/testdata/src/global-hooks.findAttachmentsByTestRunHookFinished.results.json b/testdata/src/global-hooks.findAttachmentsByTestRunHookFinished.results.json deleted file mode 100644 index 8878e547..00000000 --- a/testdata/src/global-hooks.findAttachmentsByTestRunHookFinished.results.json +++ /dev/null @@ -1 +0,0 @@ -[ ] \ No newline at end of file diff --git a/testdata/src/hooks.findAttachmentsByTestRunHookFinished.results.json b/testdata/src/hooks.findAttachmentsByTestRunHookFinished.results.json deleted file mode 100644 index 8878e547..00000000 --- a/testdata/src/hooks.findAttachmentsByTestRunHookFinished.results.json +++ /dev/null @@ -1 +0,0 @@ -[ ] \ No newline at end of file diff --git a/testdata/src/minimal.findAttachmentsByTestRunHookFinished.results.json b/testdata/src/minimal.findAttachmentsByTestRunHookFinished.results.json deleted file mode 100644 index 8878e547..00000000 --- a/testdata/src/minimal.findAttachmentsByTestRunHookFinished.results.json +++ /dev/null @@ -1 +0,0 @@ -[ ] \ No newline at end of file diff --git a/testdata/src/rules.findAttachmentsByTestRunHookFinished.results.json b/testdata/src/rules.findAttachmentsByTestRunHookFinished.results.json deleted file mode 100644 index 8878e547..00000000 --- a/testdata/src/rules.findAttachmentsByTestRunHookFinished.results.json +++ /dev/null @@ -1 +0,0 @@ -[ ] \ No newline at end of file From 606501b9e11159ee9c0570ca050cf17be0e1bf5d Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Thu, 6 Aug 2026 23:33:04 +0000 Subject: [PATCH 09/56] Added findHookBy --- cpp/include/cucumber/query/Query.hpp | 64 ++++++++------------ cpp/src/query/Query.cpp | 90 ++++++++++++++++++++++++---- cpp/test/TestQuery.cpp | 38 +++++++----- 3 files changed, 128 insertions(+), 64 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index d6dc8c7c..1557fdf8 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -82,66 +82,53 @@ namespace cucumber::query [[nodiscard]] std::vector> FindAttachmentsBy( std::variant, std::shared_ptr> element) const; - // FindHookBy(item : TestStep | TestRunHookStarted | TestRunHookFinished) - // : Hook | undefined const; + [[nodiscard]] std::optional> FindHookBy( + std::variant, std::shared_ptr, std::shared_ptr> element) const; - // FindMeta() - // : Meta | undefined const; + // [[nodiscard]] std::optional> FindMeta() - // FindMostSevereTestStepResultBy(element : TestCaseStarted | TestCaseFinished) - // : TestStepResult | undefined const; + // [[nodiscard]] std::optional> FindMostSevereTestStepResultBy(TestCaseStarted | TestCaseFinished &element) - // FindLocationOf(pickle : Pickle) - // : Location | undefined const; + // [[nodiscard]] std::optional> FindLocationOf(Pickle &pickle) - std::optional> FindPickleBy( + [[nodiscard]] std::optional> FindPickleBy( std::variant, std::shared_ptr, std::shared_ptr> element) const; - // FindPickleStepBy(testStep : TestStep) - // : PickleStep | undefined const; + // [[nodiscard]] std::optional> FindPickleStepBy(TestStep &testStep) - // FindStepBy(pickleStep : PickleStep) - // : Step | undefined const; + // [[nodiscard]] std::optional> FindStepBy(PickleStep &pickleStep) - // [[nodiscard]] std::vector> FindStepDefinitionsBy(testStep : TestStep) const; + // [[nodiscard]] std::vector> FindStepDefinitionsBy(TestStep) const &testStep; - // [[nodiscard]] std::vector> findSuggestionsBy(element : PickleStep | Pickle) const; + // [[nodiscard]] std::vector> findSuggestionsBy(PickleStep | Pickle) const &element; - // FindUnambiguousStepDefinitionBy(testStep : TestStep) - // : StepDefinition | undefined const; + // [[nodiscard]] std::optional> FindUnambiguousStepDefinitionBy(TestStep &testStep) - std::optional> FindTestCaseBy(std::variant, std::shared_ptr, - std::shared_ptr, std::shared_ptr> - element) const; + [[nodiscard]] std::optional> FindTestCaseBy(std::variant, + std::shared_ptr, std::shared_ptr, std::shared_ptr> element) const; - // FindTestCaseDurationBy(element : TestCaseStarted | TestCaseFinished) - // : Duration | undefined const; + // [[nodiscard]] std::optional> FindTestCaseDurationBy(TestCaseStarted | TestCaseFinished &element) - std::optional> FindTestCaseStartedBy( + [[nodiscard]] std::optional> FindTestCaseStartedBy( std::variant, std::shared_ptr, std::shared_ptr> element) const; - // FindTestCaseFinishedBy(testCaseStarted : TestCaseStarted) - // : TestCaseFinished | undefined const; + // [[nodiscard]] std::optional> FindTestCaseFinishedBy(TestCaseStarted &testCaseStarted) - // FindTestRunHookStartedBy(testRunHookFinished : TestRunHookFinished) - // : TestRunHookStarted | undefined const; + [[nodiscard]] std::optional> FindTestRunHookStartedBy( + const std::shared_ptr& testRunHookFinished) const; - // FindTestRunHookFinishedBy(testRunHookStarted : TestRunHookStarted) - // : TestRunHookFinished | undefined const; + // [[nodiscard]] std::optional> FindTestRunHookFinishedBy(TestRunHookStarted &testRunHookStarted) - // FindTestRunDuration() - // : Duration | undefined const; + // [[nodiscard]] std::optional> FindTestRunDuration() - // FindTestRunFinished() - // : TestRunFinished | undefined const; + // [[nodiscard]] std::optional> FindTestRunFinished() - // FindTestRunStarted() - // : TestRunStarted | undefined const; + // [[nodiscard]] std::optional> FindTestRunStarted() [[nodiscard]] std::optional> FindTestStepBy( std::variant, std::shared_ptr> element) const; - // [[nodiscard]] std::vector> FindTestStepsStartedBy(element : TestCaseStarted | TestCaseFinished) const; + // [[nodiscard]] std::vector> FindTestStepsStartedBy(TestCaseStarted | TestCaseFinished) const &element; [[nodiscard]] std::vector> FindTestStepsFinishedBy( std::variant, std::shared_ptr> element) const; @@ -149,8 +136,7 @@ namespace cucumber::query [[nodiscard]] std::vector, std::shared_ptr>> FindTestStepFinishedAndTestStepBy( const std::shared_ptr& testCaseStarted) const; - // FindLineageBy(element : Pickle | TestCaseStarted | TestCaseFinished) - // : Lineage | undefined const; + // [[nodiscard]] std::optional> FindLineageBy(Pickle | TestCaseStarted | TestCaseFinished &element) // [[nodiscard]] std::size_t CountTestCasesStarted() const; const; @@ -187,7 +173,7 @@ namespace cucumber::query std::unordered_map> stepById; std::unordered_map> pickleById; std::unordered_map> pickleStepById; - // private readonly hookById: Map = new Map() + std::unordered_map> hookById; std::unordered_map> stepDefinitionById; std::unordered_map> testCaseById; std::unordered_map> testStepById; diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 5927a302..7166c22e 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -18,6 +18,16 @@ namespace cucumber::query { namespace { + template + void SortBy(std::vector& container, const Proj& projection) + { + std::sort(container.begin(), container.end(), + [&projection](const auto& lhs, const auto& rhs) + { + return std::stoi(std::invoke(projection, lhs)) < std::stoi(std::invoke(projection, rhs)); + }); + } + template auto MapValuesToVector(const std::unordered_map& container) { @@ -32,6 +42,16 @@ namespace cucumber::query return result; } + template + auto MapValuesToVectorSortBy(const std::unordered_map& container, const Proj& projection) + { + std::vector result = MapValuesToVector(container); + + SortBy(result, projection); + + return result; + } + template auto MapValuesToVector(const std::unordered_map>& container) { @@ -86,10 +106,10 @@ namespace cucumber::query { UpdatePickle(envelope.pickle.value()); } - // if (envelope.hook) - // { - // this.hookById.set(envelope.hook.id, envelope.hook) - // } + if (envelope.hook.has_value()) + { + hookById[envelope.hook.value()->id] = envelope.hook.value(); + } if (envelope.stepDefinition.has_value()) { stepDefinitionById[envelope.stepDefinition.value()->id] = envelope.stepDefinition.value(); @@ -182,17 +202,17 @@ namespace cucumber::query std::vector> Query::FindAllPickles() const { - return MapValuesToVector(pickleById); + return MapValuesToVectorSortBy(pickleById, &messages::Pickle::id); } std::vector> Query::FindAllPickleSteps() const { - return MapValuesToVector(pickleStepById); + return MapValuesToVectorSortBy(pickleStepById, &messages::PickleStep::id); } std::vector> Query::FindAllStepDefinitions() const { - return MapValuesToVector(stepDefinitionById); + return MapValuesToVectorSortBy(stepDefinitionById, &messages::StepDefinition::id); } std::vector> Query::FindAllTestCaseStarted() const @@ -209,6 +229,8 @@ namespace cucumber::query } } + SortBy(result, &messages::TestCaseStarted::id); + return result; } @@ -224,17 +246,19 @@ namespace cucumber::query } } + SortBy(result, &messages::TestCaseFinished::testCaseStartedId); + return result; } std::vector> Query::FindAllTestSteps() const { - return MapValuesToVector(testStepById); + return MapValuesToVectorSortBy(testStepById, &messages::TestStep::id); } std::vector> Query::FindAllTestCases() const { - return MapValuesToVector(testCaseById); + return MapValuesToVectorSortBy(testCaseById, &messages::TestCase::id); } std::vector> Query::FindAllTestStepStarted() const @@ -249,12 +273,12 @@ namespace cucumber::query std::vector> Query::FindAllTestRunHookStarted() const { - return MapValuesToVector(testRunHookStartedById); + return MapValuesToVectorSortBy(testRunHookStartedById, &messages::TestRunHookStarted::id); } std::vector> Query::FindAllTestRunHookFinished() const { - return MapValuesToVector(testRunHookFinishedByTestRunHookStartedId); + return MapValuesToVectorSortBy(testRunHookFinishedByTestRunHookStartedId, &messages::TestRunHookFinished::testRunHookStartedId); } std::vector> Query::FindAllUndefinedParameterTypes() const @@ -294,6 +318,40 @@ namespace cucumber::query element); } + std::optional> Query::FindHookBy( + std::variant, std::shared_ptr, std::shared_ptr> element) const + { + return std::visit( + overloaded{ + [this](const std::shared_ptr& element) -> std::optional> + { + if (element->hookId.has_value()) + { + return hookById.at(element->hookId.value()); + } + return std::nullopt; + }, + [this](const std::shared_ptr& element) -> std::optional> + { + if (hookById.find(element->hookId) != hookById.end()) + { + return hookById.at(element->hookId); + } + return std::nullopt; + }, + [this](const std::shared_ptr& element) -> std::optional> + { + const auto testRunHookStarted = FindTestRunHookStartedBy(element); + if (!testRunHookStarted.has_value()) + { + throw std::out_of_range{ "Expected to find TestRunHookStarted from TestRunHookFinished" }; + } + return FindHookBy(testRunHookStarted.value()); + }, + }, + element); + } + std::optional> Query::FindPickleBy( std::variant, std::shared_ptr, std::shared_ptr> element) const { @@ -357,6 +415,16 @@ namespace cucumber::query element); } + std::optional> Query::FindTestRunHookStartedBy(const std::shared_ptr& testRunHookFinished) const + { + const auto iter = testRunHookStartedById.find(testRunHookFinished->testRunHookStartedId); + if (iter != testRunHookStartedById.end()) + { + return iter->second; + } + return std::nullopt; + } + std::optional> Query::FindTestStepBy( std::variant, std::shared_ptr> element) const { diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index 2dff90d1..5eb1095d 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -165,23 +165,32 @@ namespace cucumber::query } } - if (actual["testStepFinished"].is_array()) - { - std::sort(actual["testStepFinished"].begin(), actual["testStepFinished"].end(), - [](const nlohmann::json& lhs, const nlohmann::json& rhs) - { - return std::stoi(lhs[0].get()) < std::stoi(rhs[0].get()); - }); - } + return actual; + } + + nlohmann::json FindHookBy(const query::Query& query) + { + nlohmann::json actual; - if (actual["testRunHookFinished"].is_array()) + auto findHookBy = [&actual, &query](const auto& testSteps) { - std::sort(actual["testRunHookFinished"].begin(), actual["testRunHookFinished"].end(), - [](const nlohmann::json& lhs, const nlohmann::json& rhs) + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& testStep : testSteps) + { + const auto& hook = query.FindHookBy(testStep); + if (hook.has_value()) { - return std::stoi(lhs[0].get()) < std::stoi(rhs[0].get()); - }); - } + actual.push_back(hook.value()->id); + } + } + + return actual; + }; + + actual["testStep"] = findHookBy(query.FindAllTestSteps()); + actual["testRunHookStarted"] = findHookBy(query.FindAllTestRunHookStarted()); + actual["testRunHookFinished"] = findHookBy(query.FindAllTestRunHookFinished()); return actual; } @@ -204,6 +213,7 @@ namespace cucumber::query { "findAllTestStepStarted", GetSizeOf<&query::Query::FindAllTestStepStarted> }, { "findAllUndefinedParameterTypes", FindAllUndefinedParameterTypes }, { "findAttachmentsBy", FindAttachmentsBy }, + { "findHookBy", FindHookBy }, }; struct AcceptanceTest : testing::Test From 2b84c50b424201002eba5224445e2737f82e6bc9 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 09:09:42 +0000 Subject: [PATCH 10/56] add FindLineageBy --- cpp/CMakeLists.txt | 4 + cpp/include/cucumber/query/Lineage.hpp | 34 +++++++ cpp/include/cucumber/query/NamingStrategy.hpp | 60 +++++++++++ cpp/include/cucumber/query/Query.hpp | 28 ++---- cpp/src/query/Lineage.cpp | 22 +++++ cpp/src/query/NamingStrategy.cpp | 99 +++++++++++++++++++ cpp/src/query/Query.cpp | 66 +++++++------ cpp/test/TestQuery.cpp | 37 ++++++- 8 files changed, 297 insertions(+), 53 deletions(-) create mode 100644 cpp/include/cucumber/query/Lineage.hpp create mode 100644 cpp/include/cucumber/query/NamingStrategy.hpp create mode 100644 cpp/src/query/Lineage.cpp create mode 100644 cpp/src/query/NamingStrategy.cpp diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 4bd6bde9..c9fb0932 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -61,8 +61,12 @@ add_library(cucumber::query ALIAS cucumber_query_lib) target_sources( cucumber_query_lib PRIVATE + include/cucumber/query/Lineage.hpp include/cucumber/query/Query.hpp + src/query/Lineage.cpp src/query/Query.cpp + include/cucumber/query/NamingStrategy.hpp + src/query/NamingStrategy.cpp ) target_include_directories( diff --git a/cpp/include/cucumber/query/Lineage.hpp b/cpp/include/cucumber/query/Lineage.hpp new file mode 100644 index 00000000..7b00384d --- /dev/null +++ b/cpp/include/cucumber/query/Lineage.hpp @@ -0,0 +1,34 @@ +#ifndef CUCUMBER_QUERY_LINEAGE_HPP +#define CUCUMBER_QUERY_LINEAGE_HPP + +#include "cucumber/messages/Background.hpp" +#include "cucumber/messages/Examples.hpp" +#include "cucumber/messages/Feature.hpp" +#include "cucumber/messages/GherkinDocument.hpp" +#include "cucumber/messages/Rule.hpp" +#include "cucumber/messages/Scenario.hpp" +#include "cucumber/messages/TableRow.hpp" +#include +#include +#include + +namespace cucumber::query +{ + struct Lineage + { + std::shared_ptr gherkinDocument; + std::shared_ptr feature; + std::shared_ptr background; + std::shared_ptr rule; + std::shared_ptr ruleBackground; + std::shared_ptr scenario; + std::shared_ptr examples; + std::optional examplesIndex; + std::shared_ptr example; + std::optional exampleIndex; + + Lineage operator+(const Lineage& other) const; + }; +} + +#endif diff --git a/cpp/include/cucumber/query/NamingStrategy.hpp b/cpp/include/cucumber/query/NamingStrategy.hpp new file mode 100644 index 00000000..205bdb28 --- /dev/null +++ b/cpp/include/cucumber/query/NamingStrategy.hpp @@ -0,0 +1,60 @@ +#ifndef CUCUMBER_QUERY_NAMING_STRATEGY_HPP +#define CUCUMBER_QUERY_NAMING_STRATEGY_HPP + +#include "cucumber/messages/Pickle.hpp" +#include "cucumber/query/Lineage.hpp" +#include +#include + +namespace cucumber::query +{ + struct NamingStrategy + { + NamingStrategy() = default; + + NamingStrategy(const NamingStrategy&) = default; + NamingStrategy(NamingStrategy&&) = default; + NamingStrategy& operator=(const NamingStrategy&) = default; + NamingStrategy& operator=(NamingStrategy&&) = default; + + virtual ~NamingStrategy() = default; + + [[nodiscard]] virtual std::string Reduce(const Lineage& lineage, const messages::Pickle& pickle) const = 0; + }; + + enum class NamingStrategyLength : std::uint8_t + { + longName, + shortName, + }; + + enum class NamingStrategyFeatureName : std::uint8_t + { + include, + exclude, + }; + + enum class NamingStrategyExampleName : std::uint8_t + { + number, + pickle, + numberAndPickleIfParameterized, + }; + + struct BuiltinNamingStrategy : NamingStrategy + { + BuiltinNamingStrategy(NamingStrategyLength length, NamingStrategyFeatureName featureName, NamingStrategyExampleName exampleName); + + [[nodiscard]] std::string Reduce(const Lineage& lineage, const messages::Pickle& pickle) const override; + + private: + NamingStrategyLength length; + NamingStrategyFeatureName featureName; + NamingStrategyExampleName exampleName; + }; + + std::unique_ptr CreateNamingStrategy(NamingStrategyLength length, NamingStrategyFeatureName featureName = NamingStrategyFeatureName::include, + NamingStrategyExampleName exampleName = NamingStrategyExampleName::numberAndPickleIfParameterized); +} + +#endif diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 1557fdf8..771c7282 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -11,6 +11,7 @@ #include "cucumber/messages/TestCaseStarted.hpp" #include "cucumber/messages/TestStepFinished.hpp" #include "cucumber/messages/TestStepResultStatus.hpp" +#include "cucumber/query/Lineage.hpp" #include #include #include @@ -24,20 +25,10 @@ namespace cucumber::query { - struct Lineage + struct LineageAndPickle { - std::shared_ptr gherkinDocument; - std::shared_ptr feature; - std::shared_ptr background; - std::shared_ptr rule; - std::shared_ptr ruleBackground; - std::shared_ptr scenario; - std::shared_ptr examples; - std::size_t examplesIndex; - std::shared_ptr example; - std::size_t exampleIndex; - - Lineage operator+(const Lineage& other) const; + std::shared_ptr lineage; + std::shared_ptr pickle; }; class Query @@ -136,15 +127,16 @@ namespace cucumber::query [[nodiscard]] std::vector, std::shared_ptr>> FindTestStepFinishedAndTestStepBy( const std::shared_ptr& testCaseStarted) const; - // [[nodiscard]] std::optional> FindLineageBy(Pickle | TestCaseStarted | TestCaseFinished &element) + [[nodiscard]] std::optional FindLineageBy( + std::variant, std::shared_ptr, std::shared_ptr> element) const; // [[nodiscard]] std::size_t CountTestCasesStarted() const; const; private: void UpdateGherkinDocument(const std::shared_ptr& gherkinDocument); - void UpdateFeature(const std::shared_ptr& feature, std::unique_ptr lineage); - void UpdateRule(const std::shared_ptr& rule, std::unique_ptr lineage); - void UpdateScenario(const std::shared_ptr& scenario, std::unique_ptr lineage); + void UpdateFeature(const std::shared_ptr& feature, const std::shared_ptr& lineage); + void UpdateRule(const std::shared_ptr& rule, const std::shared_ptr& lineage); + void UpdateScenario(const std::shared_ptr& scenario, const std::shared_ptr& lineage); void UpdateSteps(const std::vector>& steps); void UpdatePickle(std::shared_ptr pickle); void UpdateTestRunHookStarted(const std::shared_ptr& testRunHookStarted); @@ -169,7 +161,7 @@ namespace cucumber::query // private testRunStarted: TestRunStarted // private testRunFinished: TestRunFinished std::unordered_map> testCaseStartedById; - std::unordered_map> lineageById; + std::unordered_map> lineageById; std::unordered_map> stepById; std::unordered_map> pickleById; std::unordered_map> pickleStepById; diff --git a/cpp/src/query/Lineage.cpp b/cpp/src/query/Lineage.cpp new file mode 100644 index 00000000..3dd70cca --- /dev/null +++ b/cpp/src/query/Lineage.cpp @@ -0,0 +1,22 @@ +#include "cucumber/query/Lineage.hpp" + +namespace cucumber::query +{ + Lineage Lineage::operator+(const Lineage& other) const + { + Lineage combined; + + combined.gherkinDocument = other.gherkinDocument ? other.gherkinDocument : gherkinDocument; + combined.feature = other.feature ? other.feature : feature; + combined.background = other.background ? other.background : background; + combined.rule = other.rule ? other.rule : rule; + combined.ruleBackground = other.ruleBackground ? other.ruleBackground : ruleBackground; + combined.scenario = other.scenario ? other.scenario : scenario; + combined.examples = other.examples ? other.examples : examples; + combined.examplesIndex = other.examplesIndex ? other.examplesIndex : examplesIndex; + combined.example = other.example ? other.example : example; + combined.exampleIndex = other.exampleIndex ? other.exampleIndex : exampleIndex; + + return combined; + } +} diff --git a/cpp/src/query/NamingStrategy.cpp b/cpp/src/query/NamingStrategy.cpp new file mode 100644 index 00000000..25aec8f5 --- /dev/null +++ b/cpp/src/query/NamingStrategy.cpp @@ -0,0 +1,99 @@ +#include "cucumber/query/NamingStrategy.hpp" +#include "cucumber/query/Lineage.hpp" +#include +#include +#include +#include +#include +#include + +namespace cucumber::query +{ + BuiltinNamingStrategy::BuiltinNamingStrategy(NamingStrategyLength length, NamingStrategyFeatureName featureName, NamingStrategyExampleName exampleName) + : length{ length } + , featureName{ featureName } + , exampleName{ exampleName } + {} + + std::string BuiltinNamingStrategy::Reduce(const Lineage& lineage, const messages::Pickle& pickle) const + { + static constexpr std::size_t namingStrategyPartsCount = 8; + + std::vector parts(namingStrategyPartsCount); + + if (lineage.feature && !lineage.feature->name.empty() && featureName == NamingStrategyFeatureName::include) + { + parts.emplace_back(lineage.feature->name); + } + + if (lineage.rule && !lineage.rule->name.empty()) + { + parts.emplace_back(lineage.rule->name); + } + + if (lineage.scenario && !lineage.scenario->name.empty()) + { + parts.emplace_back(lineage.scenario->name); + } + else + { + parts.emplace_back(pickle.name); + } + + if (lineage.examples && !lineage.examples->name.empty()) + { + parts.emplace_back(lineage.examples->name); + } + + if (lineage.example) + { + const auto exampleNumber = "#" + std::to_string(lineage.examplesIndex.value_or(0) + 1) + "." + std::to_string(lineage.exampleIndex.value_or(0) + 1); + + switch (exampleName) + { + case NamingStrategyExampleName::number: + parts.emplace_back(exampleNumber); + break; + case NamingStrategyExampleName::pickle: + parts.emplace_back(pickle.name); + break; + case NamingStrategyExampleName::numberAndPickleIfParameterized: + if (lineage.scenario && lineage.scenario->name != pickle.name) + { + parts.emplace_back(exampleNumber + ": " + pickle.name); + } + else + { + parts.emplace_back(exampleNumber); + } + break; + } + } + + if (this->length == NamingStrategyLength::shortName) + { + return parts.back(); + } + + return std::accumulate(parts.begin(), parts.end(), std::string{}, + [](const std::string& cumulative, const std::string& element) + { + if (element.empty()) + { + return cumulative; + } + + if (cumulative.empty()) + { + return element; + } + + return cumulative + " - " + element; + }); + } + + std::unique_ptr CreateNamingStrategy(NamingStrategyLength length, NamingStrategyFeatureName featureName, NamingStrategyExampleName exampleName) + { + return std::make_unique(length, featureName, exampleName); + } +} diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 7166c22e..332e0ec1 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -1,6 +1,7 @@ #include "cucumber/query/Query.hpp" #include "cucumber/messages/All.hpp" #include "cucumber/messages/TestStepResultStatus.hpp" +#include "cucumber/query/Lineage.hpp" #include #include #include @@ -76,22 +77,6 @@ namespace cucumber::query overloaded(Ts...) -> overloaded; } - Lineage Lineage::operator+(const Lineage& other) const - { - Lineage combined; - combined.gherkinDocument = other.gherkinDocument ? other.gherkinDocument : gherkinDocument; - combined.feature = other.feature ? other.feature : feature; - combined.background = other.background ? other.background : background; - combined.rule = other.rule ? other.rule : rule; - combined.ruleBackground = other.ruleBackground ? other.ruleBackground : ruleBackground; - combined.scenario = other.scenario ? other.scenario : scenario; - combined.examples = other.examples ? other.examples : examples; - combined.examplesIndex = (other.examplesIndex != 0) ? other.examplesIndex : examplesIndex; - combined.example = other.example ? other.example : example; - combined.exampleIndex = (other.exampleIndex != 0) ? other.exampleIndex : exampleIndex; - return combined; - } - void Query::Update(const cucumber::messages::Envelope& envelope) { if (envelope.meta.has_value()) @@ -485,22 +470,39 @@ namespace cucumber::query return result; } - ///////////////////////////// - ///////////////////////////// - ///////////////////////////// - ///////////////////////////// - ///////////////////////////// - ///////////////////////////// + auto Query::FindLineageBy(std::variant, std::shared_ptr, std::shared_ptr> element) const + -> std::optional + { + const auto pickle = std::visit( + overloaded{ + [](const std::shared_ptr& pickle) + { + return std::make_optional(pickle); + }, + [this](const auto& element) + { + return FindPickleBy(element); + }, + }, + element); + + if (pickle.has_value()) + { + return LineageAndPickle{ lineageById.at(pickle.value()->astNodeIds.back()), pickle.value() }; + } + + return std::nullopt; + } void Query::UpdateGherkinDocument(const std::shared_ptr& gherkinDocument) { if (gherkinDocument->feature.has_value()) { - UpdateFeature(gherkinDocument->feature.value(), std::make_unique(Lineage{ gherkinDocument })); + UpdateFeature(gherkinDocument->feature.value(), std::make_shared(Lineage{ gherkinDocument })); } } - void Query::UpdateFeature(const std::shared_ptr& feature, std::unique_ptr lineage) + void Query::UpdateFeature(const std::shared_ptr& feature, const std::shared_ptr& lineage) { for (const auto& featureChild : feature->children) { @@ -512,17 +514,17 @@ namespace cucumber::query if (featureChild->scenario.has_value()) { - UpdateScenario(featureChild->scenario.value(), std::make_unique(*lineage + Lineage{ {}, feature })); + UpdateScenario(featureChild->scenario.value(), std::make_shared(*lineage + Lineage{ {}, feature })); } if (featureChild->rule.has_value()) { - UpdateRule(featureChild->rule.value(), std::make_unique(*lineage + Lineage{ {}, feature })); + UpdateRule(featureChild->rule.value(), std::make_shared(*lineage + Lineage{ {}, feature })); } } } - void Query::UpdateRule(const std::shared_ptr& rule, std::unique_ptr lineage) + void Query::UpdateRule(const std::shared_ptr& rule, const std::shared_ptr& lineage) { for (const auto& ruleChild : rule->children) { @@ -534,24 +536,24 @@ namespace cucumber::query if (ruleChild->scenario.has_value()) { - UpdateScenario(ruleChild->scenario.value(), std::make_unique(*lineage + Lineage{ {}, {}, {}, rule })); + UpdateScenario(ruleChild->scenario.value(), std::make_shared(*lineage + Lineage{ {}, {}, {}, rule })); } } } - void Query::UpdateScenario(const std::shared_ptr& scenario, std::unique_ptr lineage) + void Query::UpdateScenario(const std::shared_ptr& scenario, const std::shared_ptr& lineage) { - lineageById[scenario->id] = std::make_unique(*lineage + Lineage{ {}, {}, {}, {}, {}, scenario }); + lineageById[scenario->id] = std::make_shared(*lineage + Lineage{ {}, {}, {}, {}, {}, scenario }); std::size_t examplesIndex = 0; for (const auto& examples : scenario->examples) { - lineageById[examples->id] = std::make_unique(*lineage + Lineage{ {}, {}, {}, {}, {}, scenario, examples, examplesIndex }); + lineageById[examples->id] = std::make_shared(*lineage + Lineage{ {}, {}, {}, {}, {}, scenario, examples, examplesIndex }); std::size_t exampleIndex = 0; for (const auto& example : examples->tableBody) { - lineageById[example->id] = std::make_unique(*lineage + Lineage{ {}, {}, {}, {}, {}, scenario, examples, examplesIndex, example, exampleIndex }); + lineageById[example->id] = std::make_shared(*lineage + Lineage{ {}, {}, {}, {}, {}, scenario, examples, examplesIndex, example, exampleIndex }); ++exampleIndex; } ++examplesIndex; diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index 5eb1095d..4e3680b0 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -1,5 +1,6 @@ #include "cucumber/messages/All.hpp" #include "cucumber/messages/TestStepResultStatus.hpp" +#include "cucumber/query/NamingStrategy.hpp" #include "cucumber/query/Query.hpp" #include "nlohmann/json.hpp" #include "nlohmann/json_fwd.hpp" @@ -170,9 +171,7 @@ namespace cucumber::query nlohmann::json FindHookBy(const query::Query& query) { - nlohmann::json actual; - - auto findHookBy = [&actual, &query](const auto& testSteps) + const auto findHookBy = [&query](const auto& testSteps) { nlohmann::json actual = nlohmann::json::array(); @@ -188,6 +187,8 @@ namespace cucumber::query return actual; }; + nlohmann::json actual; + actual["testStep"] = findHookBy(query.FindAllTestSteps()); actual["testRunHookStarted"] = findHookBy(query.FindAllTestRunHookStarted()); actual["testRunHookFinished"] = findHookBy(query.FindAllTestRunHookFinished()); @@ -195,6 +196,35 @@ namespace cucumber::query return actual; } + nlohmann::json FindLineageBy(const query::Query& query) + { + const auto namingStrategy = CreateNamingStrategy(NamingStrategyLength::longName, NamingStrategyFeatureName::include, NamingStrategyExampleName::number); + + const auto findLineageBy = [&namingStrategy, &query](const auto& items) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& item : items) + { + const auto& lineageAndPickle = query.FindLineageBy(item); + if (lineageAndPickle.has_value()) + { + actual.push_back(namingStrategy->Reduce(*lineageAndPickle.value().lineage, *lineageAndPickle.value().pickle)); + } + } + + return actual; + }; + + nlohmann::json actual; + + actual["testCaseStarted"] = findLineageBy(query.FindAllTestCaseStarted()); + actual["testCaseFinished"] = findLineageBy(query.FindAllTestCaseFinished()); + actual["pickle"] = findLineageBy(query.FindAllPickles()); + + return actual; + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", CountTestCasesStarted }, @@ -214,6 +244,7 @@ namespace cucumber::query { "findAllUndefinedParameterTypes", FindAllUndefinedParameterTypes }, { "findAttachmentsBy", FindAttachmentsBy }, { "findHookBy", FindHookBy }, + { "findLineageBy", FindLineageBy }, }; struct AcceptanceTest : testing::Test From 9ff311b4da481444039a51494d717e428b499396 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 09:20:07 +0000 Subject: [PATCH 11/56] Added FindLocationOf --- cpp/include/cucumber/query/Query.hpp | 2 +- cpp/src/query/Query.cpp | 27 +++++++++++++++++++++++++++ cpp/test/TestQuery.cpp | 17 +++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 771c7282..ccf6872a 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -80,7 +80,7 @@ namespace cucumber::query // [[nodiscard]] std::optional> FindMostSevereTestStepResultBy(TestCaseStarted | TestCaseFinished &element) - // [[nodiscard]] std::optional> FindLocationOf(Pickle &pickle) + [[nodiscard]] std::optional> FindLocationOf(const std::shared_ptr& pickle) const; [[nodiscard]] std::optional> FindPickleBy( std::variant, std::shared_ptr, std::shared_ptr> element) const; diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 332e0ec1..479c4a85 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -337,6 +337,33 @@ namespace cucumber::query element); } + std::optional> Query::FindLocationOf(const std::shared_ptr& pickle) const + { + if (pickle->location.has_value()) + { + return pickle->location.value(); + } + + const auto lineageAndPickle = FindLineageBy(pickle); + + if (lineageAndPickle.has_value()) + { + const auto& lineage = lineageAndPickle.value().lineage; + + if (lineage->example) + { + return lineage->example->location; + } + + if (lineage->scenario) + { + return lineage->scenario->location; + } + } + + return std::nullopt; + } + std::optional> Query::FindPickleBy( std::variant, std::shared_ptr, std::shared_ptr> element) const { diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index 4e3680b0..7cbb15f5 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -225,6 +225,22 @@ namespace cucumber::query return actual; } + nlohmann::json FindLocationOf(const query::Query& query) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& pickle : query.FindAllPickles()) + { + const auto location = query.FindLocationOf(pickle); + if (location.has_value()) + { + actual.push_back({ { "line", location.value()->line }, { "column", location.value()->column } }); + } + } + + return actual; + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", CountTestCasesStarted }, @@ -245,6 +261,7 @@ namespace cucumber::query { "findAttachmentsBy", FindAttachmentsBy }, { "findHookBy", FindHookBy }, { "findLineageBy", FindLineageBy }, + { "findLocationOf", FindLocationOf }, }; struct AcceptanceTest : testing::Test From 7718294410efa8467cf748b3050f972d49fb7d00 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 09:29:23 +0000 Subject: [PATCH 12/56] Added FindMeta --- cpp/include/cucumber/query/Query.hpp | 32 ++++++++++++++-------------- cpp/src/query/Query.cpp | 5 +++++ cpp/test/TestQuery.cpp | 13 +++++++++++ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index ccf6872a..21d0fc09 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -76,50 +76,50 @@ namespace cucumber::query [[nodiscard]] std::optional> FindHookBy( std::variant, std::shared_ptr, std::shared_ptr> element) const; - // [[nodiscard]] std::optional> FindMeta() + [[nodiscard]] std::optional> FindMeta() const; - // [[nodiscard]] std::optional> FindMostSevereTestStepResultBy(TestCaseStarted | TestCaseFinished &element) + // [[nodiscard]] std::optional> FindMostSevereTestStepResultBy(TestCaseStarted | TestCaseFinished &element) const [[nodiscard]] std::optional> FindLocationOf(const std::shared_ptr& pickle) const; [[nodiscard]] std::optional> FindPickleBy( std::variant, std::shared_ptr, std::shared_ptr> element) const; - // [[nodiscard]] std::optional> FindPickleStepBy(TestStep &testStep) + // [[nodiscard]] std::optional> FindPickleStepBy(TestStep &testStep) const - // [[nodiscard]] std::optional> FindStepBy(PickleStep &pickleStep) + // [[nodiscard]] std::optional> FindStepBy(PickleStep &pickleStep) const - // [[nodiscard]] std::vector> FindStepDefinitionsBy(TestStep) const &testStep; + // [[nodiscard]] std::vector> FindStepDefinitionsBy(TestStep) const &testStep - // [[nodiscard]] std::vector> findSuggestionsBy(PickleStep | Pickle) const &element; + // [[nodiscard]] std::vector> findSuggestionsBy(PickleStep | Pickle) const &element - // [[nodiscard]] std::optional> FindUnambiguousStepDefinitionBy(TestStep &testStep) + // [[nodiscard]] std::optional> FindUnambiguousStepDefinitionBy(TestStep &testStep) const [[nodiscard]] std::optional> FindTestCaseBy(std::variant, std::shared_ptr, std::shared_ptr, std::shared_ptr> element) const; - // [[nodiscard]] std::optional> FindTestCaseDurationBy(TestCaseStarted | TestCaseFinished &element) + // [[nodiscard]] std::optional> FindTestCaseDurationBy(TestCaseStarted | TestCaseFinished &element) const [[nodiscard]] std::optional> FindTestCaseStartedBy( std::variant, std::shared_ptr, std::shared_ptr> element) const; - // [[nodiscard]] std::optional> FindTestCaseFinishedBy(TestCaseStarted &testCaseStarted) + // [[nodiscard]] std::optional> FindTestCaseFinishedBy(TestCaseStarted &testCaseStarted) const [[nodiscard]] std::optional> FindTestRunHookStartedBy( const std::shared_ptr& testRunHookFinished) const; - // [[nodiscard]] std::optional> FindTestRunHookFinishedBy(TestRunHookStarted &testRunHookStarted) + // [[nodiscard]] std::optional> FindTestRunHookFinishedBy(TestRunHookStarted &testRunHookStarted) const - // [[nodiscard]] std::optional> FindTestRunDuration() + // [[nodiscard]] std::optional> FindTestRunDuration() const - // [[nodiscard]] std::optional> FindTestRunFinished() + // [[nodiscard]] std::optional> FindTestRunFinished() const - // [[nodiscard]] std::optional> FindTestRunStarted() + // [[nodiscard]] std::optional> FindTestRunStarted() const [[nodiscard]] std::optional> FindTestStepBy( std::variant, std::shared_ptr> element) const; - // [[nodiscard]] std::vector> FindTestStepsStartedBy(TestCaseStarted | TestCaseFinished) const &element; + // [[nodiscard]] std::vector> FindTestStepsStartedBy(TestCaseStarted | TestCaseFinished) const &element [[nodiscard]] std::vector> FindTestStepsFinishedBy( std::variant, std::shared_ptr> element) const; @@ -130,7 +130,7 @@ namespace cucumber::query [[nodiscard]] std::optional FindLineageBy( std::variant, std::shared_ptr, std::shared_ptr> element) const; - // [[nodiscard]] std::size_t CountTestCasesStarted() const; const; + // [[nodiscard]] std::size_t CountTestCasesStarted() const private: void UpdateGherkinDocument(const std::shared_ptr& gherkinDocument); @@ -156,7 +156,7 @@ namespace cucumber::query ///////////// ///////////// - std::shared_ptr meta; + std::optional> meta; // private testRunStarted: TestRunStarted // private testRunFinished: TestRunFinished diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 479c4a85..ad0909f6 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -337,6 +337,11 @@ namespace cucumber::query element); } + std::optional> Query::FindMeta() const + { + return meta; + } + std::optional> Query::FindLocationOf(const std::shared_ptr& pickle) const { if (pickle->location.has_value()) diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index 7cbb15f5..af2b4491 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -241,6 +241,18 @@ namespace cucumber::query return actual; } + nlohmann::json FindMeta(const query::Query& query) + { + const auto meta = query.FindMeta(); + + if (meta.has_value()) + { + return meta.value()->implementation->name; + } + + return {}; + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", CountTestCasesStarted }, @@ -262,6 +274,7 @@ namespace cucumber::query { "findHookBy", FindHookBy }, { "findLineageBy", FindLineageBy }, { "findLocationOf", FindLocationOf }, + { "findMeta", FindMeta }, }; struct AcceptanceTest : testing::Test From a6a5c0ea39eb66d9db76bbc1036e846bb8227d9f Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 09:58:18 +0000 Subject: [PATCH 13/56] Added FindMostSevereTestStepResultBy --- cpp/include/cucumber/query/Query.hpp | 3 +- cpp/src/query/Query.cpp | 50 +++++++++++++++++++++++----- cpp/test/TestQuery.cpp | 27 +++++++++++++++ 3 files changed, 70 insertions(+), 10 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 21d0fc09..149e8e7b 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -78,7 +78,8 @@ namespace cucumber::query [[nodiscard]] std::optional> FindMeta() const; - // [[nodiscard]] std::optional> FindMostSevereTestStepResultBy(TestCaseStarted | TestCaseFinished &element) const + [[nodiscard]] std::optional> FindMostSevereTestStepResultBy( + std::variant, std::shared_ptr> element) const; [[nodiscard]] std::optional> FindLocationOf(const std::shared_ptr& pickle) const; diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index ad0909f6..7fb04852 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -29,6 +29,16 @@ namespace cucumber::query }); } + void SortBySeverity(std::vector, std::shared_ptr>>& container) + { + std::sort(container.begin(), container.end(), + [](const auto& lhs, const auto& rhs) + { + using underlying_type = std::underlying_type_t; + return static_cast(lhs.first->testStepResult->status) > static_cast(rhs.first->testStepResult->status); + }); + } + template auto MapValuesToVector(const std::unordered_map& container) { @@ -163,17 +173,12 @@ namespace cucumber::query for (const auto& testCaseStarted : FindAllTestCaseStarted()) { - auto allFinishedSteps = FindTestStepFinishedAndTestStepBy(testCaseStarted); - if (!allFinishedSteps.empty()) + auto testStepFinishedAndTestStep = FindTestStepFinishedAndTestStepBy(testCaseStarted); + if (!testStepFinishedAndTestStep.empty()) { - std::sort(allFinishedSteps.begin(), allFinishedSteps.end(), - [](const auto& lhs, const auto& rhs) - { - using underlying_type = std::underlying_type_t; - return static_cast(lhs.first->testStepResult->status) > static_cast(rhs.first->testStepResult->status); - }); + SortBySeverity(testStepFinishedAndTestStep); - ++result[allFinishedSteps.front().first->testStepResult->status]; + ++result[testStepFinishedAndTestStep.front().first->testStepResult->status]; } } @@ -342,6 +347,33 @@ namespace cucumber::query return meta; } + std::optional> Query::FindMostSevereTestStepResultBy( + std::variant, std::shared_ptr> element) const + { + const auto testCaseStarted = std::visit(overloaded{ [this](const std::shared_ptr& element) + { + return FindTestCaseStartedBy(element); + }, + [](const auto& element) -> std::optional> + { + return element; + } }, + element); + + if (testCaseStarted.has_value()) + { + auto testStepFinishedAndTestStep = FindTestStepFinishedAndTestStepBy(testCaseStarted.value()); + if (!testStepFinishedAndTestStep.empty()) + { + SortBySeverity(testStepFinishedAndTestStep); + + return testStepFinishedAndTestStep.front().first->testStepResult; + } + } + + return std::nullopt; + } + std::optional> Query::FindLocationOf(const std::shared_ptr& pickle) const { if (pickle->location.has_value()) diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index af2b4491..b1a047d0 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -253,6 +253,32 @@ namespace cucumber::query return {}; } + nlohmann::json FindMostSevereTestStepResultBy(const query::Query& query) + { + const auto findMostSevereTestStepResultBy = [&query](const auto& items) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& item : items) + { + const auto mostSevereTestStepResult = query.FindMostSevereTestStepResultBy(item); + if (mostSevereTestStepResult.has_value()) + { + actual.emplace_back(to_string(mostSevereTestStepResult.value()->status)); + } + } + + return actual; + }; + + nlohmann::json actual; + + actual["testCaseStarted"] = findMostSevereTestStepResultBy(query.FindAllTestCaseStarted()); + actual["testCaseFinished"] = findMostSevereTestStepResultBy(query.FindAllTestCaseFinished()); + + return actual; + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", CountTestCasesStarted }, @@ -275,6 +301,7 @@ namespace cucumber::query { "findLineageBy", FindLineageBy }, { "findLocationOf", FindLocationOf }, { "findMeta", FindMeta }, + { "findMostSevereTestStepResultBy", FindMostSevereTestStepResultBy }, }; struct AcceptanceTest : testing::Test From 78f5465d196347665b19454df17b3e7622419716 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 10:44:54 +0000 Subject: [PATCH 14/56] Added FindPickleBy, FindPickleStepBy, FindStepBy, FindStepDefinitionsBy --- cpp/include/cucumber/query/Query.hpp | 10 ++-- cpp/src/query/Query.cpp | 59 +++++++++++++++++-- cpp/test/TestQuery.cpp | 88 ++++++++++++++++++++++++++-- 3 files changed, 143 insertions(+), 14 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 149e8e7b..662e23df 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -83,14 +83,14 @@ namespace cucumber::query [[nodiscard]] std::optional> FindLocationOf(const std::shared_ptr& pickle) const; - [[nodiscard]] std::optional> FindPickleBy( - std::variant, std::shared_ptr, std::shared_ptr> element) const; + [[nodiscard]] std::optional> FindPickleBy(std::variant, + std::shared_ptr, std::shared_ptr, std::shared_ptr> element) const; - // [[nodiscard]] std::optional> FindPickleStepBy(TestStep &testStep) const + [[nodiscard]] std::optional> FindPickleStepBy(const std::shared_ptr& testStep) const; - // [[nodiscard]] std::optional> FindStepBy(PickleStep &pickleStep) const + [[nodiscard]] std::optional> FindStepBy(const std::shared_ptr& pickleStep) const; - // [[nodiscard]] std::vector> FindStepDefinitionsBy(TestStep) const &testStep + [[nodiscard]] std::vector> FindStepDefinitionsBy(const std::shared_ptr& testStep) const; // [[nodiscard]] std::vector> findSuggestionsBy(PickleStep | Pickle) const &element diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 7fb04852..8b8fef26 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -56,7 +56,7 @@ namespace cucumber::query template auto MapValuesToVectorSortBy(const std::unordered_map& container, const Proj& projection) { - std::vector result = MapValuesToVector(container); + auto result = MapValuesToVector(container); SortBy(result, projection); @@ -77,6 +77,16 @@ namespace cucumber::query return result; } + template + auto MapValuesToVectorSortBy(const std::unordered_map>& container, const Proj& projection) + { + auto result = MapValuesToVector(container); + + SortBy(result, projection); + + return result; + } + template struct overloaded : Ts... { @@ -253,12 +263,12 @@ namespace cucumber::query std::vector> Query::FindAllTestStepStarted() const { - return MapValuesToVector(testStepStartedByTestCaseStartedId); + return MapValuesToVectorSortBy(testStepStartedByTestCaseStartedId, &messages::TestStepStarted::testCaseStartedId); } std::vector> Query::FindAllTestStepFinished() const { - return MapValuesToVector(testStepFinishedByTestCaseStartedId); + return MapValuesToVectorSortBy(testStepFinishedByTestCaseStartedId, &messages::TestStepFinished::testCaseStartedId); } std::vector> Query::FindAllTestRunHookStarted() const @@ -401,8 +411,9 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindPickleBy( - std::variant, std::shared_ptr, std::shared_ptr> element) const + std::optional> Query::FindPickleBy(std::variant, std::shared_ptr, + std::shared_ptr, std::shared_ptr> + element) const { const auto testCase = std::visit( [this](const auto& element) @@ -421,6 +432,44 @@ namespace cucumber::query } } + std::optional> Query::FindPickleStepBy(const std::shared_ptr& testStep) const + { + if (testStep->pickleStepId.has_value()) + { + return pickleStepById.at(testStep->pickleStepId.value()); + } + return std::nullopt; + } + + std::optional> Query::FindStepBy(const std::shared_ptr& pickleStep) const + { + const auto stepId = pickleStep->astNodeIds.front(); + + if (stepById.find(stepId) != stepById.end()) + { + return stepById.at(pickleStep->astNodeIds.front()); + } + return std::nullopt; + } + + std::vector> Query::FindStepDefinitionsBy(const std::shared_ptr& testStep) const + { + std::vector> result; + + if (testStep->stepDefinitionIds.has_value()) + { + for (const auto& stepDefinitionId : testStep->stepDefinitionIds.value()) + { + if (stepDefinitionById.find(stepDefinitionId) != stepDefinitionById.end()) + { + result.push_back(stepDefinitionById.at(stepDefinitionId)); + } + } + } + + return result; + } + std::optional> Query::FindTestCaseBy(std::variant, std::shared_ptr, std::shared_ptr, std::shared_ptr> element) const diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index b1a047d0..39fbb502 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -24,9 +24,6 @@ #include #include -TEST(first, second) -{} - namespace cucumber::query { namespace @@ -70,7 +67,9 @@ namespace cucumber::query }; std::optional> FindPickleBy(const query::Query& query, - std::variant, std::shared_ptr, std::shared_ptr> element) + std::variant, std::shared_ptr, std::shared_ptr, + std::shared_ptr> + element) { return query.FindPickleBy(std::move(element)); }; @@ -279,6 +278,83 @@ namespace cucumber::query return actual; } + nlohmann::json FindPickleBy(const query::Query& query) + { + const auto findPickleBy = [&query](const auto& items) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& item : items) + { + const auto pickle = query.FindPickleBy(item); + if (pickle.has_value()) + { + actual.push_back(pickle.value()->name); + } + } + + return actual; + }; + + nlohmann::json actual; + + actual["testCaseStarted"] = findPickleBy(query.FindAllTestCaseStarted()); + actual["testCaseFinished"] = findPickleBy(query.FindAllTestCaseFinished()); + actual["testStepStarted"] = findPickleBy(query.FindAllTestStepStarted()); + actual["testStepFinished"] = findPickleBy(query.FindAllTestStepFinished()); + + return actual; + } + + nlohmann::json FindPickleStepBy(const query::Query& query) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& testStep : query.FindAllTestSteps()) + { + const auto pickleStep = query.FindPickleStepBy(testStep); + if (pickleStep.has_value()) + { + actual.emplace_back(pickleStep.value()->text); + } + } + + return actual; + } + + nlohmann::json FindStepBy(const query::Query& query) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& pickleStep : query.FindAllPickleSteps()) + { + const auto step = query.FindStepBy(pickleStep); + if (step.has_value()) + { + actual.emplace_back(step.value()->text); + } + } + + return actual; + } + + nlohmann::json FindStepDefinitionsBy(const query::Query& query) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& testStep : query.FindAllTestSteps()) + { + auto& actualIds = actual.emplace_back(nlohmann::json::array()); + + for (const auto& stepDefinition : query.FindStepDefinitionsBy(testStep)) + { + actualIds.emplace_back(stepDefinition->id); + } + } + + return actual; + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", CountTestCasesStarted }, @@ -302,6 +378,10 @@ namespace cucumber::query { "findLocationOf", FindLocationOf }, { "findMeta", FindMeta }, { "findMostSevereTestStepResultBy", FindMostSevereTestStepResultBy }, + { "findPickleBy", FindPickleBy }, + { "findPickleStepBy", FindPickleStepBy }, + { "findStepBy", FindStepBy }, + { "findStepDefinitionsBy", FindStepDefinitionsBy }, }; struct AcceptanceTest : testing::Test From cf23d8c8e144892e34343c7eaf76079de0f6ed3f Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 11:51:24 +0000 Subject: [PATCH 15/56] Added FindSuggestionsBy --- cpp/include/cucumber/query/Query.hpp | 5 +++-- cpp/src/query/Query.cpp | 29 ++++++++++++++++++++++++---- cpp/test/TestQuery.cpp | 26 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 662e23df..df80bf17 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -92,7 +92,8 @@ namespace cucumber::query [[nodiscard]] std::vector> FindStepDefinitionsBy(const std::shared_ptr& testStep) const; - // [[nodiscard]] std::vector> findSuggestionsBy(PickleStep | Pickle) const &element + [[nodiscard]] std::vector> FindSuggestionsBy(const std::shared_ptr& element) const; + [[nodiscard]] std::vector> FindSuggestionsBy(const std::shared_ptr& element) const; // [[nodiscard]] std::optional> FindUnambiguousStepDefinitionBy(TestStep &testStep) const @@ -177,7 +178,7 @@ namespace cucumber::query std::unordered_map>> testStepFinishedByTestCaseStartedId; std::unordered_map>> attachmentsByTestCaseStartedId; std::unordered_map>> attachmentsByTestRunHookStartedId; - // std::unordered_map> suggestionsByPickleStepId; + std::unordered_map> suggestionsByPickleStepId; std::vector> undefinedParameterTypes; }; diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 8b8fef26..c8d7928a 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -159,10 +159,10 @@ namespace cucumber::query // { // this.testRunFinished = envelope.testRunFinished // } - // if (envelope.suggestion) - // { - // this.updateSuggestion(envelope.suggestion) - // } + if (envelope.suggestion.has_value()) + { + suggestionsByPickleStepId[envelope.suggestion.value()->pickleStepId] = envelope.suggestion.value(); + } if (envelope.undefinedParameterType.has_value()) { undefinedParameterTypes.push_back(envelope.undefinedParameterType.value()); @@ -470,6 +470,27 @@ namespace cucumber::query return result; } + std::vector> Query::FindSuggestionsBy(const std::shared_ptr& element) const + { + if (suggestionsByPickleStepId.find(element->id) != suggestionsByPickleStepId.end()) + { + return { suggestionsByPickleStepId.at(element->id) }; + } + + return {}; + } + + std::vector> Query::FindSuggestionsBy(const std::shared_ptr& element) const + { + std::vector> result; + for (const auto& pickleStep : element->steps) + { + const auto suggestions = FindSuggestionsBy(pickleStep); + result.insert(result.end(), suggestions.begin(), suggestions.end()); + } + return result; + } + std::optional> Query::FindTestCaseBy(std::variant, std::shared_ptr, std::shared_ptr, std::shared_ptr> element) const diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index 39fbb502..b35bd79b 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -355,6 +355,31 @@ namespace cucumber::query return actual; } + nlohmann::json FindSuggestionsBy(const query::Query& query) + { + const auto findSuggestionsBy = [&query](const auto& items) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& item : items) + { + for (const auto& suggestion : query.FindSuggestionsBy(item)) + { + actual.emplace_back(suggestion->id); + } + } + + return actual; + }; + + nlohmann::json actual; + + actual["pickleStep"] = findSuggestionsBy(query.FindAllPickleSteps()); + actual["pickle"] = findSuggestionsBy(query.FindAllPickles()); + + return actual; + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", CountTestCasesStarted }, @@ -382,6 +407,7 @@ namespace cucumber::query { "findPickleStepBy", FindPickleStepBy }, { "findStepBy", FindStepBy }, { "findStepDefinitionsBy", FindStepDefinitionsBy }, + { "findSuggestionsBy", FindSuggestionsBy }, }; struct AcceptanceTest : testing::Test From d007cb86110fa02ff411fc90bf83a9107b0e2a50 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 13:09:57 +0000 Subject: [PATCH 16/56] Added FindTestCaseBy, FindTestCaseDurationBy, FindTestCaseFinishedBy, FindTestCaseStartedBy --- cpp/cmake/dependencies.cpm.cmake | 2 +- cpp/include/cucumber/query/Query.hpp | 6 +- cpp/src/query/Query.cpp | 32 +++++++++ cpp/test/TestQuery.cpp | 99 +++++++++++++++++++++++++++- 4 files changed, 135 insertions(+), 4 deletions(-) diff --git a/cpp/cmake/dependencies.cpm.cmake b/cpp/cmake/dependencies.cpm.cmake index a54bf707..04340f44 100644 --- a/cpp/cmake/dependencies.cpm.cmake +++ b/cpp/cmake/dependencies.cpm.cmake @@ -1,7 +1,7 @@ # renovate: datasource=github-tags packageName=cpm-cmake/CPM.cmake versioning=semver set(CPM_DOWNLOAD_TAG_DIGEST v0.43.1 456cb6754daaa010d57444d0c8ce6d95ecf006ab) # renovate: datasource=github-tags packageName=cucumber/messages versioning=semver -set(CUCUMBER_MESSAGES_TAG_DIGEST v34.0.2 5158f5280a38f949fa444f2009c35d6e120063a2) +set(CUCUMBER_MESSAGES_TAG_DIGEST v34.0.2 e13c029f4bd74cb2d92278b935c3e861e47ea5a4) # renovate: datasource=github-tags packageName=google/googletest versioning=semver set(GOOGLE_TEST_TAG_DIGEST v1.17.0 52eb8108c5bdec04579160ae17225d66034bd723) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index df80bf17..d837dd6a 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -100,12 +100,14 @@ namespace cucumber::query [[nodiscard]] std::optional> FindTestCaseBy(std::variant, std::shared_ptr, std::shared_ptr, std::shared_ptr> element) const; - // [[nodiscard]] std::optional> FindTestCaseDurationBy(TestCaseStarted | TestCaseFinished &element) const + [[nodiscard]] std::optional> FindTestCaseDurationBy(const std::shared_ptr& element) const; + + [[nodiscard]] std::optional> FindTestCaseDurationBy(const std::shared_ptr& element) const; [[nodiscard]] std::optional> FindTestCaseStartedBy( std::variant, std::shared_ptr, std::shared_ptr> element) const; - // [[nodiscard]] std::optional> FindTestCaseFinishedBy(TestCaseStarted &testCaseStarted) const + [[nodiscard]] std::optional> FindTestCaseFinishedBy(const std::shared_ptr& testCaseStarted) const; [[nodiscard]] std::optional> FindTestRunHookStartedBy( const std::shared_ptr& testRunHookFinished) const; diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index c8d7928a..8d98f89e 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -1,5 +1,6 @@ #include "cucumber/query/Query.hpp" #include "cucumber/messages/All.hpp" +#include "cucumber/messages/DurationUtil.hpp" #include "cucumber/messages/TestStepResultStatus.hpp" #include "cucumber/query/Lineage.hpp" #include @@ -518,6 +519,28 @@ namespace cucumber::query } } + std::optional> Query::FindTestCaseDurationBy(const std::shared_ptr& element) const + { + const auto& testCaseFinished = FindTestCaseFinishedBy(element); + if (testCaseFinished.has_value()) + { + return std::make_shared(*testCaseFinished.value()->timestamp - *element->timestamp); + } + return std::nullopt; + } + + std::optional> Query::FindTestCaseDurationBy(const std::shared_ptr& element) const + { + const auto testCaseStarted = FindTestCaseStartedBy(element); + + if (testCaseStarted.has_value()) + { + return FindTestCaseDurationBy(testCaseStarted.value()); + } + + return std::nullopt; + } + std::optional> Query::FindTestCaseStartedBy( std::variant, std::shared_ptr, std::shared_ptr> element) const { @@ -534,6 +557,15 @@ namespace cucumber::query element); } + std::optional> Query::FindTestCaseFinishedBy(const std::shared_ptr& testCaseStarted) const + { + if (testCaseFinishedByTestCaseStartedId.find(testCaseStarted->id) != testCaseFinishedByTestCaseStartedId.end()) + { + return testCaseFinishedByTestCaseStartedId.at(testCaseStarted->id); + } + return std::nullopt; + } + std::optional> Query::FindTestRunHookStartedBy(const std::shared_ptr& testRunHookFinished) const { const auto iter = testRunHookStartedById.find(testRunHookFinished->testRunHookStartedId); diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index b35bd79b..a7c876e8 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -6,7 +6,6 @@ #include "nlohmann/json_fwd.hpp" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include #include #include #include @@ -380,6 +379,100 @@ namespace cucumber::query return actual; } + nlohmann::json FindTestCaseBy(const query::Query& query) + { + const auto findTestCaseBy = [&query](const auto& items) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& item : items) + { + const auto& testCase = query.FindTestCaseBy(item); + if (testCase.has_value()) + { + actual.push_back(testCase.value()->id); + } + } + return actual; + }; + + nlohmann::json actual; + + actual["testCaseStarted"] = findTestCaseBy(query.FindAllTestCaseStarted()); + actual["testCaseFinished"] = findTestCaseBy(query.FindAllTestCaseFinished()); + actual["testStepStarted"] = findTestCaseBy(query.FindAllTestStepStarted()); + actual["testStepFinished"] = findTestCaseBy(query.FindAllTestStepFinished()); + + return actual; + } + + nlohmann::json FindTestCaseDurationBy(const query::Query& query) + { + const auto findTestCaseDurationBy = [&query](const auto& items) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& item : items) + { + const auto& testCase = query.FindTestCaseDurationBy(item); + if (testCase.has_value()) + { + testCase.value()->to_json(actual.emplace_back()); + } + } + return actual; + }; + + nlohmann::json actual; + + actual["testCaseStarted"] = findTestCaseDurationBy(query.FindAllTestCaseStarted()); + actual["testCaseFinished"] = findTestCaseDurationBy(query.FindAllTestCaseFinished()); + + return actual; + } + + nlohmann::json FindTestCaseFinishedBy(const query::Query& query) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& testCaseStarted : query.FindAllTestCaseStarted()) + { + const auto& testCaseFinished = query.FindTestCaseFinishedBy(testCaseStarted); + if (testCaseFinished.has_value()) + { + actual.push_back(testCaseFinished.value()->testCaseStartedId); + } + } + + return actual; + } + + nlohmann::json FindTestCaseStartedBy(const query::Query& query) + { + const auto findTestCaseStartedBy = [&query](const auto& items) + { + nlohmann::json actual = nlohmann::json::array(); + for (const auto& testCaseFinished : items) + { + const auto& testCaseStarted = query.FindTestCaseStartedBy(testCaseFinished); + if (testCaseStarted.has_value()) + { + actual.push_back(testCaseStarted.value()->id); + } + } + + return actual; + }; + + nlohmann::json actual; + + actual["testCaseFinished"] = findTestCaseStartedBy(query.FindAllTestCaseFinished()); + actual["testStepStarted"] = findTestCaseStartedBy(query.FindAllTestStepStarted()); + actual["testStepFinished"] = findTestCaseStartedBy(query.FindAllTestStepFinished()); + + return actual; + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", CountTestCasesStarted }, @@ -408,6 +501,10 @@ namespace cucumber::query { "findStepBy", FindStepBy }, { "findStepDefinitionsBy", FindStepDefinitionsBy }, { "findSuggestionsBy", FindSuggestionsBy }, + { "findTestCaseBy", FindTestCaseBy }, + { "findTestCaseDurationBy", FindTestCaseDurationBy }, + { "findTestCaseFinishedBy", FindTestCaseFinishedBy }, + { "findTestCaseStartedBy", FindTestCaseStartedBy }, }; struct AcceptanceTest : testing::Test From 98852abc2dfb2cb1e24933b097743928cd1f2a43 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 13:45:05 +0000 Subject: [PATCH 17/56] Added FindTestRunDuration, FindTestRunFinished, FindTestRunHookFinishedBy, FindTestRunHookStartedBy, FindTestRunStarted --- cpp/include/cucumber/query/Query.hpp | 13 ++--- cpp/src/query/Query.cpp | 53 ++++++++++++++----- cpp/test/TestQuery.cpp | 78 +++++++++++++++++++++++++++- 3 files changed, 124 insertions(+), 20 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index d837dd6a..10688237 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -112,13 +112,13 @@ namespace cucumber::query [[nodiscard]] std::optional> FindTestRunHookStartedBy( const std::shared_ptr& testRunHookFinished) const; - // [[nodiscard]] std::optional> FindTestRunHookFinishedBy(TestRunHookStarted &testRunHookStarted) const + [[nodiscard]] std::optional> FindTestRunHookFinishedBy(const std::shared_ptr& testRunHookStarted) const; - // [[nodiscard]] std::optional> FindTestRunDuration() const + [[nodiscard]] std::optional> FindTestRunDuration() const; - // [[nodiscard]] std::optional> FindTestRunFinished() const + [[nodiscard]] std::optional> FindTestRunFinished() const; - // [[nodiscard]] std::optional> FindTestRunStarted() const + [[nodiscard]] std::optional> FindTestRunStarted() const; [[nodiscard]] std::optional> FindTestStepBy( std::variant, std::shared_ptr> element) const; @@ -162,8 +162,9 @@ namespace cucumber::query std::optional> meta; - // private testRunStarted: TestRunStarted - // private testRunFinished: TestRunFinished + std::optional> testRunStarted; + std::optional> testRunFinished; + std::unordered_map> testCaseStartedById; std::unordered_map> lineageById; std::unordered_map> stepById; diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 8d98f89e..b4b6ceaf 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -120,10 +120,10 @@ namespace cucumber::query { stepDefinitionById[envelope.stepDefinition.value()->id] = envelope.stepDefinition.value(); } - // if (envelope.testRunStarted) - // { - // this.testRunStarted = envelope.testRunStarted - // } + if (envelope.testRunStarted.has_value()) + { + testRunStarted = envelope.testRunStarted.value(); + } if (envelope.testRunHookStarted.has_value()) { UpdateTestRunHookStarted(envelope.testRunHookStarted.value()); @@ -156,10 +156,10 @@ namespace cucumber::query { UpdateTestCaseFinished(envelope.testCaseFinished.value()); } - // if (envelope.testRunFinished) - // { - // this.testRunFinished = envelope.testRunFinished - // } + if (envelope.testRunFinished.has_value()) + { + testRunFinished = envelope.testRunFinished.value(); + } if (envelope.suggestion.has_value()) { suggestionsByPickleStepId[envelope.suggestion.value()->pickleStepId] = envelope.suggestion.value(); @@ -509,14 +509,12 @@ namespace cucumber::query }, element); - try + if (testCaseById.find(testCaseStarted.value()->testCaseId) != testCaseById.end()) { return testCaseById.at(testCaseStarted.value()->testCaseId); } - catch (const std::out_of_range&) - { - return std::nullopt; - } + + return std::nullopt; } std::optional> Query::FindTestCaseDurationBy(const std::shared_ptr& element) const @@ -576,6 +574,35 @@ namespace cucumber::query return std::nullopt; } + std::optional> Query::FindTestRunHookFinishedBy(const std::shared_ptr& testRunHookStarted) const + { + if (testRunHookFinishedByTestRunHookStartedId.find(testRunHookStarted->id) != testRunHookFinishedByTestRunHookStartedId.end()) + { + return testRunHookFinishedByTestRunHookStartedId.at(testRunHookStarted->id); + } + return std::nullopt; + } + + std::optional> Query::FindTestRunDuration() const + { + if (testRunStarted.has_value() && testRunFinished.has_value()) + { + return std::make_shared(*testRunFinished.value()->timestamp - *testRunStarted.value()->timestamp); + } + + return std::nullopt; + } + + std::optional> Query::FindTestRunFinished() const + { + return testRunFinished; + } + + std::optional> Query::FindTestRunStarted() const + { + return testRunStarted; + } + std::optional> Query::FindTestStepBy( std::variant, std::shared_ptr> element) const { diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index a7c876e8..894ba4e2 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -100,7 +100,7 @@ namespace cucumber::query nlohmann::json FindAllTestCaseFinishedOrderBy(const query::Query& query) { - const auto allResults = query.FindAllTestCaseFinishedOrderBy(FindPickleBy, ReversePickleComparator); + const auto allResults = query.FindAllTestCaseFinishedOrderBy(&FindPickleBy, ReversePickleComparator); nlohmann::json actual; for (const auto& testCaseFinished : allResults) { @@ -473,6 +473,77 @@ namespace cucumber::query return actual; } + nlohmann::json FindTestRunDuration(const query::Query& query) + { + nlohmann::json actual; + + const auto testRunDuration = query.FindTestRunDuration(); + if (testRunDuration.has_value()) + { + testRunDuration.value()->to_json(actual); + } + + return actual; + } + + nlohmann::json FindTestRunFinished(const query::Query& query) + { + nlohmann::json actual; + + const auto testRunFinished = query.FindTestRunFinished(); + if (testRunFinished.has_value()) + { + testRunFinished.value()->to_json(actual); + } + + return actual; + } + + nlohmann::json FindTestRunHookFinishedBy(const query::Query& query) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& testRunHookStarted : query.FindAllTestRunHookStarted()) + { + const auto& testRunHookFinished = query.FindTestRunHookFinishedBy(testRunHookStarted); + if (testRunHookFinished.has_value()) + { + actual.emplace_back(testRunHookFinished.value()->testRunHookStartedId); + } + } + + return actual; + } + + nlohmann::json FindTestRunHookStartedBy(const query::Query& query) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& testRunHookFinished : query.FindAllTestRunHookFinished()) + { + const auto& testRunHookStarted = query.FindTestRunHookStartedBy(testRunHookFinished); + if (testRunHookStarted.has_value()) + { + actual.emplace_back(testRunHookStarted.value()->id); + } + } + + return actual; + } + + nlohmann::json FindTestRunStarted(const query::Query& query) + { + nlohmann::json actual; + + const auto testRunStarted = query.FindTestRunStarted(); + if (testRunStarted.has_value()) + { + testRunStarted.value()->to_json(actual); + } + + return actual; + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", CountTestCasesStarted }, @@ -505,6 +576,11 @@ namespace cucumber::query { "findTestCaseDurationBy", FindTestCaseDurationBy }, { "findTestCaseFinishedBy", FindTestCaseFinishedBy }, { "findTestCaseStartedBy", FindTestCaseStartedBy }, + { "findTestRunDuration", FindTestRunDuration }, + { "findTestRunFinished", FindTestRunFinished }, + { "findTestRunHookFinishedBy", FindTestRunHookFinishedBy }, + { "findTestRunHookStartedBy", FindTestRunHookStartedBy }, + { "findTestRunStarted", FindTestRunStarted }, }; struct AcceptanceTest : testing::Test From 2ad670bea747418de93dc8fbe76076a466f02f63 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 14:55:57 +0000 Subject: [PATCH 18/56] Added FindTestStepBy, FindTestStepFinishedAndTestStepBy --- cpp/include/cucumber/query/Query.hpp | 6 ++-- cpp/src/query/Query.cpp | 18 +++++++++++ cpp/test/TestQuery.cpp | 48 +++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 10688237..1e6d79c8 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -112,7 +112,8 @@ namespace cucumber::query [[nodiscard]] std::optional> FindTestRunHookStartedBy( const std::shared_ptr& testRunHookFinished) const; - [[nodiscard]] std::optional> FindTestRunHookFinishedBy(const std::shared_ptr& testRunHookStarted) const; + [[nodiscard]] std::optional> FindTestRunHookFinishedBy( + const std::shared_ptr& testRunHookStarted) const; [[nodiscard]] std::optional> FindTestRunDuration() const; @@ -123,7 +124,8 @@ namespace cucumber::query [[nodiscard]] std::optional> FindTestStepBy( std::variant, std::shared_ptr> element) const; - // [[nodiscard]] std::vector> FindTestStepsStartedBy(TestCaseStarted | TestCaseFinished) const &element + [[nodiscard]] std::vector> FindTestStepsStartedBy(const std::shared_ptr& testCaseStarted) const; + [[nodiscard]] std::vector> FindTestStepsStartedBy(const std::shared_ptr& testCaseFinished) const; [[nodiscard]] std::vector> FindTestStepsFinishedBy( std::variant, std::shared_ptr> element) const; diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index b4b6ceaf..90753173 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -621,6 +621,24 @@ namespace cucumber::query } } + std::vector> Query::FindTestStepsStartedBy(const std::shared_ptr& testCaseStarted) const + { + if (testStepStartedByTestCaseStartedId.find(testCaseStarted->id) != testStepStartedByTestCaseStartedId.end()) + { + return testStepStartedByTestCaseStartedId.at(testCaseStarted->id); + } + return {}; + } + + std::vector> Query::FindTestStepsStartedBy(const std::shared_ptr& testCaseFinished) const + { + if (testStepStartedByTestCaseStartedId.find(testCaseFinished->testCaseStartedId) != testStepStartedByTestCaseStartedId.end()) + { + return testStepStartedByTestCaseStartedId.at(testCaseFinished->testCaseStartedId); + } + return {}; + } + std::vector> Query::FindTestStepsFinishedBy( std::variant, std::shared_ptr> element) const { diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index 894ba4e2..d11e6ab9 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -207,7 +207,8 @@ namespace cucumber::query const auto& lineageAndPickle = query.FindLineageBy(item); if (lineageAndPickle.has_value()) { - actual.push_back(namingStrategy->Reduce(*lineageAndPickle.value().lineage, *lineageAndPickle.value().pickle)); + const auto& [lineage, pickle] = lineageAndPickle.value(); + actual.push_back(namingStrategy->Reduce(*lineage, *pickle)); } } @@ -544,6 +545,49 @@ namespace cucumber::query return actual; } + nlohmann::json FindTestStepBy(const query::Query& query) + { + nlohmann::json actual{ + { "testStepStarted", nlohmann::json::array() }, + { "testStepFinished", nlohmann::json::array() }, + }; + + const auto findTestStepBy = [&](const auto& testSteps, const char* key) + { + for (const auto& testStepEvent : testSteps) + { + const auto& testStep = query.FindTestStepBy(testStepEvent); + if (testStep.has_value()) + { + actual[key].emplace_back(testStep.value()->id); + } + } + }; + + for (const auto& item : query.FindAllTestCaseStarted()) + { + findTestStepBy(query.FindTestStepsStartedBy(item), "testStepStarted"); + findTestStepBy(query.FindTestStepsFinishedBy(item), "testStepFinished"); + } + + return actual; + } + + nlohmann::json FindTestStepFinishedAndTestStepBy(const query::Query& query) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& testCaseStarted : query.FindAllTestCaseStarted()) + { + for (const auto& [testStepFinished, testStep] : query.FindTestStepFinishedAndTestStepBy(testCaseStarted)) + { + actual.push_back({ testStepFinished->testStepId, testStep->id }); + } + } + + return actual; + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", CountTestCasesStarted }, @@ -581,6 +625,8 @@ namespace cucumber::query { "findTestRunHookFinishedBy", FindTestRunHookFinishedBy }, { "findTestRunHookStartedBy", FindTestRunHookStartedBy }, { "findTestRunStarted", FindTestRunStarted }, + { "findTestStepBy", FindTestStepBy }, + { "findTestStepFinishedAndTestStepBy", FindTestStepFinishedAndTestStepBy }, }; struct AcceptanceTest : testing::Test From 6ffde7e5f928f14ba189ca0070843d3689b981ba Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 15:07:44 +0000 Subject: [PATCH 19/56] Added FindTestStepsFinishedBy --- cpp/test/TestQuery.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index d11e6ab9..a10dc686 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -588,6 +588,35 @@ namespace cucumber::query return actual; } + nlohmann::json FindTestStepsFinishedBy(const query::Query& query) + { + + const auto findTestStepsFinishedBy = [&](const auto& items) + { + auto actual = nlohmann::json::array(); + + for (const auto& item : items) + { + auto& nested = actual.emplace_back(nlohmann::json::array()); + const auto& testStepsFinished = query.FindTestStepsFinishedBy(item); + + for (const auto& testStepFinished : testStepsFinished) + { + nested.push_back(testStepFinished->testStepId); + } + } + + return actual; + }; + + nlohmann::json actual; + + actual["testCaseStarted"] = findTestStepsFinishedBy(query.FindAllTestCaseStarted()); + actual["testCaseFinished"] = findTestStepsFinishedBy(query.FindAllTestCaseFinished()); + + return actual; + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", CountTestCasesStarted }, @@ -627,6 +656,7 @@ namespace cucumber::query { "findTestRunStarted", FindTestRunStarted }, { "findTestStepBy", FindTestStepBy }, { "findTestStepFinishedAndTestStepBy", FindTestStepFinishedAndTestStepBy }, + { "findTestStepsFinishedBy", FindTestStepsFinishedBy }, }; struct AcceptanceTest : testing::Test From 6c40e4dedb06592a3d812b18aa79d1663b2ea944 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 15:36:42 +0000 Subject: [PATCH 20/56] Added FindTestStepsStartedBy, FindUnambiguousStepDefinitionBy --- cpp/include/cucumber/query/Query.hpp | 13 +------- cpp/src/query/Query.cpp | 13 ++++++++ cpp/test/TestQuery.cpp | 47 +++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 13 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 1e6d79c8..9039ec93 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -95,7 +95,7 @@ namespace cucumber::query [[nodiscard]] std::vector> FindSuggestionsBy(const std::shared_ptr& element) const; [[nodiscard]] std::vector> FindSuggestionsBy(const std::shared_ptr& element) const; - // [[nodiscard]] std::optional> FindUnambiguousStepDefinitionBy(TestStep &testStep) const + [[nodiscard]] std::optional> FindUnambiguousStepDefinitionBy(const std::shared_ptr& testStep) const; [[nodiscard]] std::optional> FindTestCaseBy(std::variant, std::shared_ptr, std::shared_ptr, std::shared_ptr> element) const; @@ -136,8 +136,6 @@ namespace cucumber::query [[nodiscard]] std::optional FindLineageBy( std::variant, std::shared_ptr, std::shared_ptr> element) const; - // [[nodiscard]] std::size_t CountTestCasesStarted() const - private: void UpdateGherkinDocument(const std::shared_ptr& gherkinDocument); void UpdateFeature(const std::shared_ptr& feature, const std::shared_ptr& lineage); @@ -147,20 +145,11 @@ namespace cucumber::query void UpdatePickle(std::shared_ptr pickle); void UpdateTestRunHookStarted(const std::shared_ptr& testRunHookStarted); void UpdateTestRunHookFinished(const std::shared_ptr& testRunHookFinished); - - ///////////// - ///////////// - ///////////// - void UpdateTestCase(std::shared_ptr testCase); void UpdateTestCaseStarted(std::shared_ptr testCaseStarted); - ///////////// - void UpdateAttachment(const std::shared_ptr& attachment); void UpdateTestStepFinished(std::shared_ptr testStepFinished); void UpdateTestCaseFinished(std::shared_ptr testCaseFinished); - ///////////// - ///////////// std::optional> meta; diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 90753173..0d517a6d 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -492,6 +492,19 @@ namespace cucumber::query return result; } + std::optional> Query::FindUnambiguousStepDefinitionBy(const std::shared_ptr& testStep) const + { + if (testStep->stepDefinitionIds.has_value() && testStep->stepDefinitionIds.value().size() == 1) + { + const auto stepDefinitionId = testStep->stepDefinitionIds.value().front(); + if (stepDefinitionById.find(stepDefinitionId) != stepDefinitionById.end()) + { + return stepDefinitionById.at(stepDefinitionId); + } + } + return std::nullopt; + } + std::optional> Query::FindTestCaseBy(std::variant, std::shared_ptr, std::shared_ptr, std::shared_ptr> element) const diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index a10dc686..d28af4ca 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -590,7 +590,6 @@ namespace cucumber::query nlohmann::json FindTestStepsFinishedBy(const query::Query& query) { - const auto findTestStepsFinishedBy = [&](const auto& items) { auto actual = nlohmann::json::array(); @@ -617,6 +616,50 @@ namespace cucumber::query return actual; } + nlohmann::json FindTestStepsStartedBy(const query::Query& query) + { + const auto findTestStepsStartedBy = [&](const auto& items) + { + auto actual = nlohmann::json::array(); + + for (const auto& item : items) + { + auto& nested = actual.emplace_back(nlohmann::json::array()); + const auto& testStepsFinished = query.FindTestStepsStartedBy(item); + + for (const auto& testStepFinished : testStepsFinished) + { + nested.push_back(testStepFinished->testStepId); + } + } + + return actual; + }; + + nlohmann::json actual; + + actual["testCaseStarted"] = findTestStepsStartedBy(query.FindAllTestCaseStarted()); + actual["testCaseFinished"] = findTestStepsStartedBy(query.FindAllTestCaseFinished()); + + return actual; + } + + nlohmann::json FindUnambiguousStepDefinitionBy(const query::Query& query) + { + nlohmann::json actual = nlohmann::json::array(); + + for (const auto& testStep : query.FindAllTestSteps()) + { + const auto& stepDefinition = query.FindUnambiguousStepDefinitionBy(testStep); + if (stepDefinition.has_value()) + { + actual.push_back(stepDefinition.value()->id); + } + } + + return actual; + } + const std::unordered_map functionMap{ { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, { "countTestCasesStarted", CountTestCasesStarted }, @@ -657,6 +700,8 @@ namespace cucumber::query { "findTestStepBy", FindTestStepBy }, { "findTestStepFinishedAndTestStepBy", FindTestStepFinishedAndTestStepBy }, { "findTestStepsFinishedBy", FindTestStepsFinishedBy }, + { "findTestStepsStartedBy", FindTestStepsStartedBy }, + { "findUnambiguousStepDefinitionBy", FindUnambiguousStepDefinitionBy }, }; struct AcceptanceTest : testing::Test From d0b3fa53aefcb6ecc5cdf9500557ff6c6f3ca5b4 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 15:48:42 +0000 Subject: [PATCH 21/56] convert ot use trailing return types --- cpp/.clang-tidy | 1 - cpp/include/cucumber/query/Lineage.hpp | 2 +- cpp/include/cucumber/query/NamingStrategy.hpp | 12 +- cpp/include/cucumber/query/Query.hpp | 150 +++++++++--------- cpp/src/query/Lineage.cpp | 2 +- cpp/src/query/NamingStrategy.cpp | 4 +- cpp/src/query/Query.cpp | 145 ++++++++--------- cpp/test/TestQuery.cpp | 79 +++++---- 8 files changed, 194 insertions(+), 201 deletions(-) diff --git a/cpp/.clang-tidy b/cpp/.clang-tidy index d42542fb..2be4e46e 100644 --- a/cpp/.clang-tidy +++ b/cpp/.clang-tidy @@ -6,7 +6,6 @@ Checks: ' misc-*, -misc-non-private-member-variables-in-classes, modernize*, - -modernize-use-trailing-return-type, performance*, readability*, ' diff --git a/cpp/include/cucumber/query/Lineage.hpp b/cpp/include/cucumber/query/Lineage.hpp index 7b00384d..4723c0b1 100644 --- a/cpp/include/cucumber/query/Lineage.hpp +++ b/cpp/include/cucumber/query/Lineage.hpp @@ -27,7 +27,7 @@ namespace cucumber::query std::shared_ptr example; std::optional exampleIndex; - Lineage operator+(const Lineage& other) const; + auto operator+(const Lineage& other) const -> Lineage; }; } diff --git a/cpp/include/cucumber/query/NamingStrategy.hpp b/cpp/include/cucumber/query/NamingStrategy.hpp index 205bdb28..5b8ed84e 100644 --- a/cpp/include/cucumber/query/NamingStrategy.hpp +++ b/cpp/include/cucumber/query/NamingStrategy.hpp @@ -14,12 +14,12 @@ namespace cucumber::query NamingStrategy(const NamingStrategy&) = default; NamingStrategy(NamingStrategy&&) = default; - NamingStrategy& operator=(const NamingStrategy&) = default; - NamingStrategy& operator=(NamingStrategy&&) = default; + auto operator=(const NamingStrategy&) -> NamingStrategy& = default; + auto operator=(NamingStrategy&&) -> NamingStrategy& = default; virtual ~NamingStrategy() = default; - [[nodiscard]] virtual std::string Reduce(const Lineage& lineage, const messages::Pickle& pickle) const = 0; + [[nodiscard]] virtual auto Reduce(const Lineage& lineage, const messages::Pickle& pickle) const -> std::string = 0; }; enum class NamingStrategyLength : std::uint8_t @@ -45,7 +45,7 @@ namespace cucumber::query { BuiltinNamingStrategy(NamingStrategyLength length, NamingStrategyFeatureName featureName, NamingStrategyExampleName exampleName); - [[nodiscard]] std::string Reduce(const Lineage& lineage, const messages::Pickle& pickle) const override; + [[nodiscard]] auto Reduce(const Lineage& lineage, const messages::Pickle& pickle) const -> std::string override; private: NamingStrategyLength length; @@ -53,8 +53,8 @@ namespace cucumber::query NamingStrategyExampleName exampleName; }; - std::unique_ptr CreateNamingStrategy(NamingStrategyLength length, NamingStrategyFeatureName featureName = NamingStrategyFeatureName::include, - NamingStrategyExampleName exampleName = NamingStrategyExampleName::numberAndPickleIfParameterized); + auto CreateNamingStrategy(NamingStrategyLength length, NamingStrategyFeatureName featureName = NamingStrategyFeatureName::include, + NamingStrategyExampleName exampleName = NamingStrategyExampleName::numberAndPickleIfParameterized) -> std::unique_ptr; } #endif diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index 9039ec93..d355dbdd 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -34,122 +34,125 @@ namespace cucumber::query class Query { public: - void Update(const cucumber::messages::Envelope& envelope); + auto Update(const cucumber::messages::Envelope& envelope) -> void; - [[nodiscard]] std::unordered_map CountMostSevereTestStepResultStatus() const; + [[nodiscard]] auto CountMostSevereTestStepResultStatus() const -> std::unordered_map; - [[nodiscard]] std::size_t CountTestCasesStarted() const; + [[nodiscard]] auto CountTestCasesStarted() const -> std::size_t; - [[nodiscard]] std::vector> FindAllPickles() const; + [[nodiscard]] auto FindAllPickles() const -> std::vector>; - [[nodiscard]] std::vector> FindAllPickleSteps() const; + [[nodiscard]] auto FindAllPickleSteps() const -> std::vector>; - [[nodiscard]] std::vector> FindAllStepDefinitions() const; + [[nodiscard]] auto FindAllStepDefinitions() const -> std::vector>; - [[nodiscard]] std::vector> FindAllTestCaseStarted() const; + [[nodiscard]] auto FindAllTestCaseStarted() const -> std::vector>; - [[nodiscard]] std::vector> FindAllTestCaseFinished() const; + [[nodiscard]] auto FindAllTestCaseFinished() const -> std::vector>; template - [[nodiscard]] std::vector> FindAllTestCaseStartedOrderBy(TFind findOrderBy, Cmp order) const; + [[nodiscard]] auto FindAllTestCaseStartedOrderBy(TFind findOrderBy, Cmp order) const -> std::vector>; template - [[nodiscard]] std::vector> FindAllTestCaseFinishedOrderBy(TFind findOrderBy, Cmp order) const; + [[nodiscard]] auto FindAllTestCaseFinishedOrderBy(TFind findOrderBy, Cmp order) const -> std::vector>; - [[nodiscard]] std::vector> FindAllTestSteps() const; + [[nodiscard]] auto FindAllTestSteps() const -> std::vector>; - [[nodiscard]] std::vector> FindAllTestCases() const; + [[nodiscard]] auto FindAllTestCases() const -> std::vector>; - [[nodiscard]] std::vector> FindAllTestStepStarted() const; + [[nodiscard]] auto FindAllTestStepStarted() const -> std::vector>; - [[nodiscard]] std::vector> FindAllTestStepFinished() const; + [[nodiscard]] auto FindAllTestStepFinished() const -> std::vector>; - [[nodiscard]] std::vector> FindAllTestRunHookStarted() const; + [[nodiscard]] auto FindAllTestRunHookStarted() const -> std::vector>; - [[nodiscard]] std::vector> FindAllTestRunHookFinished() const; + [[nodiscard]] auto FindAllTestRunHookFinished() const -> std::vector>; - [[nodiscard]] std::vector> FindAllUndefinedParameterTypes() const; + [[nodiscard]] auto FindAllUndefinedParameterTypes() const -> std::vector>; - [[nodiscard]] std::vector> FindAttachmentsBy( - std::variant, std::shared_ptr> element) const; + [[nodiscard]] auto FindAttachmentsBy(std::variant, std::shared_ptr> element) const + -> std::vector>; - [[nodiscard]] std::optional> FindHookBy( - std::variant, std::shared_ptr, std::shared_ptr> element) const; + [[nodiscard]] auto FindHookBy( + std::variant, std::shared_ptr, std::shared_ptr> element) const + -> std::optional>; - [[nodiscard]] std::optional> FindMeta() const; + [[nodiscard]] auto FindMeta() const -> std::optional>; - [[nodiscard]] std::optional> FindMostSevereTestStepResultBy( - std::variant, std::shared_ptr> element) const; + [[nodiscard]] auto FindMostSevereTestStepResultBy(std::variant, std::shared_ptr> element) const + -> std::optional>; - [[nodiscard]] std::optional> FindLocationOf(const std::shared_ptr& pickle) const; + [[nodiscard]] auto FindLocationOf(const std::shared_ptr& pickle) const -> std::optional>; - [[nodiscard]] std::optional> FindPickleBy(std::variant, - std::shared_ptr, std::shared_ptr, std::shared_ptr> element) const; + [[nodiscard]] auto FindPickleBy(std::variant, std::shared_ptr, + std::shared_ptr, std::shared_ptr> element) const -> std::optional>; - [[nodiscard]] std::optional> FindPickleStepBy(const std::shared_ptr& testStep) const; + [[nodiscard]] auto FindPickleStepBy(const std::shared_ptr& testStep) const -> std::optional>; - [[nodiscard]] std::optional> FindStepBy(const std::shared_ptr& pickleStep) const; + [[nodiscard]] auto FindStepBy(const std::shared_ptr& pickleStep) const -> std::optional>; - [[nodiscard]] std::vector> FindStepDefinitionsBy(const std::shared_ptr& testStep) const; + [[nodiscard]] auto FindStepDefinitionsBy(const std::shared_ptr& testStep) const -> std::vector>; - [[nodiscard]] std::vector> FindSuggestionsBy(const std::shared_ptr& element) const; - [[nodiscard]] std::vector> FindSuggestionsBy(const std::shared_ptr& element) const; + [[nodiscard]] auto FindSuggestionsBy(const std::shared_ptr& element) const -> std::vector>; + [[nodiscard]] auto FindSuggestionsBy(const std::shared_ptr& element) const -> std::vector>; - [[nodiscard]] std::optional> FindUnambiguousStepDefinitionBy(const std::shared_ptr& testStep) const; + [[nodiscard]] auto FindUnambiguousStepDefinitionBy(const std::shared_ptr& testStep) const -> std::optional>; - [[nodiscard]] std::optional> FindTestCaseBy(std::variant, - std::shared_ptr, std::shared_ptr, std::shared_ptr> element) const; + [[nodiscard]] auto FindTestCaseBy(std::variant, std::shared_ptr, + std::shared_ptr, std::shared_ptr> element) const -> std::optional>; - [[nodiscard]] std::optional> FindTestCaseDurationBy(const std::shared_ptr& element) const; + [[nodiscard]] auto FindTestCaseDurationBy(const std::shared_ptr& element) const -> std::optional>; - [[nodiscard]] std::optional> FindTestCaseDurationBy(const std::shared_ptr& element) const; + [[nodiscard]] auto FindTestCaseDurationBy(const std::shared_ptr& element) const -> std::optional>; - [[nodiscard]] std::optional> FindTestCaseStartedBy( - std::variant, std::shared_ptr, std::shared_ptr> element) const; + [[nodiscard]] auto FindTestCaseStartedBy( + std::variant, std::shared_ptr, std::shared_ptr> element) const + -> std::optional>; - [[nodiscard]] std::optional> FindTestCaseFinishedBy(const std::shared_ptr& testCaseStarted) const; + [[nodiscard]] auto FindTestCaseFinishedBy(const std::shared_ptr& testCaseStarted) const -> std::optional>; - [[nodiscard]] std::optional> FindTestRunHookStartedBy( - const std::shared_ptr& testRunHookFinished) const; + [[nodiscard]] auto FindTestRunHookStartedBy(const std::shared_ptr& testRunHookFinished) const + -> std::optional>; - [[nodiscard]] std::optional> FindTestRunHookFinishedBy( - const std::shared_ptr& testRunHookStarted) const; + [[nodiscard]] auto FindTestRunHookFinishedBy(const std::shared_ptr& testRunHookStarted) const + -> std::optional>; - [[nodiscard]] std::optional> FindTestRunDuration() const; + [[nodiscard]] auto FindTestRunDuration() const -> std::optional>; - [[nodiscard]] std::optional> FindTestRunFinished() const; + [[nodiscard]] auto FindTestRunFinished() const -> std::optional>; - [[nodiscard]] std::optional> FindTestRunStarted() const; + [[nodiscard]] auto FindTestRunStarted() const -> std::optional>; - [[nodiscard]] std::optional> FindTestStepBy( - std::variant, std::shared_ptr> element) const; + [[nodiscard]] auto FindTestStepBy(std::variant, std::shared_ptr> element) const + -> std::optional>; - [[nodiscard]] std::vector> FindTestStepsStartedBy(const std::shared_ptr& testCaseStarted) const; - [[nodiscard]] std::vector> FindTestStepsStartedBy(const std::shared_ptr& testCaseFinished) const; + [[nodiscard]] auto FindTestStepsStartedBy(const std::shared_ptr& testCaseStarted) const -> std::vector>; + [[nodiscard]] auto FindTestStepsStartedBy(const std::shared_ptr& testCaseFinished) const -> std::vector>; - [[nodiscard]] std::vector> FindTestStepsFinishedBy( - std::variant, std::shared_ptr> element) const; + [[nodiscard]] auto FindTestStepsFinishedBy(std::variant, std::shared_ptr> element) const + -> std::vector>; - [[nodiscard]] std::vector, std::shared_ptr>> FindTestStepFinishedAndTestStepBy( - const std::shared_ptr& testCaseStarted) const; + [[nodiscard]] auto FindTestStepFinishedAndTestStepBy(const std::shared_ptr& testCaseStarted) const + -> std::vector, std::shared_ptr>>; - [[nodiscard]] std::optional FindLineageBy( - std::variant, std::shared_ptr, std::shared_ptr> element) const; + [[nodiscard]] auto FindLineageBy( + std::variant, std::shared_ptr, std::shared_ptr> element) const + -> std::optional; private: - void UpdateGherkinDocument(const std::shared_ptr& gherkinDocument); - void UpdateFeature(const std::shared_ptr& feature, const std::shared_ptr& lineage); - void UpdateRule(const std::shared_ptr& rule, const std::shared_ptr& lineage); - void UpdateScenario(const std::shared_ptr& scenario, const std::shared_ptr& lineage); - void UpdateSteps(const std::vector>& steps); - void UpdatePickle(std::shared_ptr pickle); - void UpdateTestRunHookStarted(const std::shared_ptr& testRunHookStarted); - void UpdateTestRunHookFinished(const std::shared_ptr& testRunHookFinished); - void UpdateTestCase(std::shared_ptr testCase); - void UpdateTestCaseStarted(std::shared_ptr testCaseStarted); - void UpdateAttachment(const std::shared_ptr& attachment); - void UpdateTestStepFinished(std::shared_ptr testStepFinished); - void UpdateTestCaseFinished(std::shared_ptr testCaseFinished); + auto UpdateGherkinDocument(const std::shared_ptr& gherkinDocument) -> void; + auto UpdateFeature(const std::shared_ptr& feature, const std::shared_ptr& lineage) -> void; + auto UpdateRule(const std::shared_ptr& rule, const std::shared_ptr& lineage) -> void; + auto UpdateScenario(const std::shared_ptr& scenario, const std::shared_ptr& lineage) -> void; + auto UpdateSteps(const std::vector>& steps) -> void; + auto UpdatePickle(std::shared_ptr pickle) -> void; + auto UpdateTestRunHookStarted(const std::shared_ptr& testRunHookStarted) -> void; + auto UpdateTestRunHookFinished(const std::shared_ptr& testRunHookFinished) -> void; + auto UpdateTestCase(std::shared_ptr testCase) -> void; + auto UpdateTestCaseStarted(std::shared_ptr testCaseStarted) -> void; + auto UpdateAttachment(const std::shared_ptr& attachment) -> void; + auto UpdateTestStepFinished(std::shared_ptr testStepFinished) -> void; + auto UpdateTestCaseFinished(std::shared_ptr testCaseFinished) -> void; std::optional> meta; @@ -179,7 +182,8 @@ namespace cucumber::query namespace detail { template - [[nodiscard]] std::vector> FindAllOrderBy(const Query& query, const std::vector>& allElements, Transform findOrderBy, Cmp order) + [[nodiscard]] auto FindAllOrderBy(const Query& query, const std::vector>& allElements, Transform findOrderBy, Cmp order) + -> std::vector> { using TransformResult = decltype(std::invoke(findOrderBy, query, std::declval>())); @@ -224,13 +228,13 @@ namespace cucumber::query } template - [[nodiscard]] std::vector> Query::FindAllTestCaseStartedOrderBy(Transform findOrderBy, Cmp order) const + [[nodiscard]] auto Query::FindAllTestCaseStartedOrderBy(Transform findOrderBy, Cmp order) const -> std::vector> { return detail::FindAllOrderBy(*this, FindAllTestCaseStarted(), std::move(findOrderBy), std::move(order)); } template - [[nodiscard]] std::vector> Query::FindAllTestCaseFinishedOrderBy(Transform findOrderBy, Cmp order) const + [[nodiscard]] auto Query::FindAllTestCaseFinishedOrderBy(Transform findOrderBy, Cmp order) const -> std::vector> { return detail::FindAllOrderBy(*this, FindAllTestCaseFinished(), std::move(findOrderBy), std::move(order)); } diff --git a/cpp/src/query/Lineage.cpp b/cpp/src/query/Lineage.cpp index 3dd70cca..9b09d53e 100644 --- a/cpp/src/query/Lineage.cpp +++ b/cpp/src/query/Lineage.cpp @@ -2,7 +2,7 @@ namespace cucumber::query { - Lineage Lineage::operator+(const Lineage& other) const + auto Lineage::operator+(const Lineage& other) const -> Lineage { Lineage combined; diff --git a/cpp/src/query/NamingStrategy.cpp b/cpp/src/query/NamingStrategy.cpp index 25aec8f5..242ac55a 100644 --- a/cpp/src/query/NamingStrategy.cpp +++ b/cpp/src/query/NamingStrategy.cpp @@ -15,7 +15,7 @@ namespace cucumber::query , exampleName{ exampleName } {} - std::string BuiltinNamingStrategy::Reduce(const Lineage& lineage, const messages::Pickle& pickle) const + auto BuiltinNamingStrategy::Reduce(const Lineage& lineage, const messages::Pickle& pickle) const -> std::string { static constexpr std::size_t namingStrategyPartsCount = 8; @@ -92,7 +92,7 @@ namespace cucumber::query }); } - std::unique_ptr CreateNamingStrategy(NamingStrategyLength length, NamingStrategyFeatureName featureName, NamingStrategyExampleName exampleName) + auto CreateNamingStrategy(NamingStrategyLength length, NamingStrategyFeatureName featureName, NamingStrategyExampleName exampleName) -> std::unique_ptr { return std::make_unique(length, featureName, exampleName); } diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 0d517a6d..fbf3d072 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -21,7 +21,7 @@ namespace cucumber::query namespace { template - void SortBy(std::vector& container, const Proj& projection) + auto SortBy(std::vector& container, const Proj& projection) -> void { std::sort(container.begin(), container.end(), [&projection](const auto& lhs, const auto& rhs) @@ -30,7 +30,7 @@ namespace cucumber::query }); } - void SortBySeverity(std::vector, std::shared_ptr>>& container) + auto SortBySeverity(std::vector, std::shared_ptr>>& container) -> void { std::sort(container.begin(), container.end(), [](const auto& lhs, const auto& rhs) @@ -98,7 +98,7 @@ namespace cucumber::query overloaded(Ts...) -> overloaded; } - void Query::Update(const cucumber::messages::Envelope& envelope) + auto Query::Update(const cucumber::messages::Envelope& envelope) -> void { if (envelope.meta.has_value()) { @@ -170,7 +170,7 @@ namespace cucumber::query } } - std::unordered_map Query::CountMostSevereTestStepResultStatus() const + auto Query::CountMostSevereTestStepResultStatus() const -> std::unordered_map { std::unordered_map result{ { messages::TestStepResultStatus::AMBIGUOUS, 0 }, @@ -196,27 +196,27 @@ namespace cucumber::query return result; } - std::size_t Query::CountTestCasesStarted() const + auto Query::CountTestCasesStarted() const -> std::size_t { return FindAllTestCaseStarted().size(); } - std::vector> Query::FindAllPickles() const + auto Query::FindAllPickles() const -> std::vector> { return MapValuesToVectorSortBy(pickleById, &messages::Pickle::id); } - std::vector> Query::FindAllPickleSteps() const + auto Query::FindAllPickleSteps() const -> std::vector> { return MapValuesToVectorSortBy(pickleStepById, &messages::PickleStep::id); } - std::vector> Query::FindAllStepDefinitions() const + auto Query::FindAllStepDefinitions() const -> std::vector> { return MapValuesToVectorSortBy(stepDefinitionById, &messages::StepDefinition::id); } - std::vector> Query::FindAllTestCaseStarted() const + auto Query::FindAllTestCaseStarted() const -> std::vector> { std::vector> result; @@ -235,7 +235,7 @@ namespace cucumber::query return result; } - std::vector> Query::FindAllTestCaseFinished() const + auto Query::FindAllTestCaseFinished() const -> std::vector> { std::vector> result; @@ -252,43 +252,43 @@ namespace cucumber::query return result; } - std::vector> Query::FindAllTestSteps() const + auto Query::FindAllTestSteps() const -> std::vector> { return MapValuesToVectorSortBy(testStepById, &messages::TestStep::id); } - std::vector> Query::FindAllTestCases() const + auto Query::FindAllTestCases() const -> std::vector> { return MapValuesToVectorSortBy(testCaseById, &messages::TestCase::id); } - std::vector> Query::FindAllTestStepStarted() const + auto Query::FindAllTestStepStarted() const -> std::vector> { return MapValuesToVectorSortBy(testStepStartedByTestCaseStartedId, &messages::TestStepStarted::testCaseStartedId); } - std::vector> Query::FindAllTestStepFinished() const + auto Query::FindAllTestStepFinished() const -> std::vector> { return MapValuesToVectorSortBy(testStepFinishedByTestCaseStartedId, &messages::TestStepFinished::testCaseStartedId); } - std::vector> Query::FindAllTestRunHookStarted() const + auto Query::FindAllTestRunHookStarted() const -> std::vector> { return MapValuesToVectorSortBy(testRunHookStartedById, &messages::TestRunHookStarted::id); } - std::vector> Query::FindAllTestRunHookFinished() const + auto Query::FindAllTestRunHookFinished() const -> std::vector> { return MapValuesToVectorSortBy(testRunHookFinishedByTestRunHookStartedId, &messages::TestRunHookFinished::testRunHookStartedId); } - std::vector> Query::FindAllUndefinedParameterTypes() const + auto Query::FindAllUndefinedParameterTypes() const -> std::vector> { return undefinedParameterTypes; } - std::vector> Query::FindAttachmentsBy( - std::variant, std::shared_ptr> element) const + auto Query::FindAttachmentsBy(std::variant, std::shared_ptr> element) const + -> std::vector> { return std::visit( overloaded{ @@ -319,8 +319,9 @@ namespace cucumber::query element); } - std::optional> Query::FindHookBy( + auto Query::FindHookBy( std::variant, std::shared_ptr, std::shared_ptr> element) const + -> std::optional> { return std::visit( overloaded{ @@ -353,13 +354,13 @@ namespace cucumber::query element); } - std::optional> Query::FindMeta() const + auto Query::FindMeta() const -> std::optional> { return meta; } - std::optional> Query::FindMostSevereTestStepResultBy( - std::variant, std::shared_ptr> element) const + auto Query::FindMostSevereTestStepResultBy(std::variant, std::shared_ptr> element) const + -> std::optional> { const auto testCaseStarted = std::visit(overloaded{ [this](const std::shared_ptr& element) { @@ -385,7 +386,7 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindLocationOf(const std::shared_ptr& pickle) const + auto Query::FindLocationOf(const std::shared_ptr& pickle) const -> std::optional> { if (pickle->location.has_value()) { @@ -412,9 +413,9 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindPickleBy(std::variant, std::shared_ptr, - std::shared_ptr, std::shared_ptr> - element) const + auto Query::FindPickleBy(std::variant, std::shared_ptr, std::shared_ptr, + std::shared_ptr> + element) const -> std::optional> { const auto testCase = std::visit( [this](const auto& element) @@ -433,7 +434,7 @@ namespace cucumber::query } } - std::optional> Query::FindPickleStepBy(const std::shared_ptr& testStep) const + auto Query::FindPickleStepBy(const std::shared_ptr& testStep) const -> std::optional> { if (testStep->pickleStepId.has_value()) { @@ -442,7 +443,7 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindStepBy(const std::shared_ptr& pickleStep) const + auto Query::FindStepBy(const std::shared_ptr& pickleStep) const -> std::optional> { const auto stepId = pickleStep->astNodeIds.front(); @@ -453,7 +454,7 @@ namespace cucumber::query return std::nullopt; } - std::vector> Query::FindStepDefinitionsBy(const std::shared_ptr& testStep) const + auto Query::FindStepDefinitionsBy(const std::shared_ptr& testStep) const -> std::vector> { std::vector> result; @@ -471,7 +472,7 @@ namespace cucumber::query return result; } - std::vector> Query::FindSuggestionsBy(const std::shared_ptr& element) const + auto Query::FindSuggestionsBy(const std::shared_ptr& element) const -> std::vector> { if (suggestionsByPickleStepId.find(element->id) != suggestionsByPickleStepId.end()) { @@ -481,7 +482,7 @@ namespace cucumber::query return {}; } - std::vector> Query::FindSuggestionsBy(const std::shared_ptr& element) const + auto Query::FindSuggestionsBy(const std::shared_ptr& element) const -> std::vector> { std::vector> result; for (const auto& pickleStep : element->steps) @@ -492,7 +493,7 @@ namespace cucumber::query return result; } - std::optional> Query::FindUnambiguousStepDefinitionBy(const std::shared_ptr& testStep) const + auto Query::FindUnambiguousStepDefinitionBy(const std::shared_ptr& testStep) const -> std::optional> { if (testStep->stepDefinitionIds.has_value() && testStep->stepDefinitionIds.value().size() == 1) { @@ -505,9 +506,9 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindTestCaseBy(std::variant, std::shared_ptr, - std::shared_ptr, std::shared_ptr> - element) const + auto Query::FindTestCaseBy(std::variant, std::shared_ptr, std::shared_ptr, + std::shared_ptr> + element) const -> std::optional> { const auto testCaseStarted = std::visit( overloaded{ @@ -530,7 +531,7 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindTestCaseDurationBy(const std::shared_ptr& element) const + auto Query::FindTestCaseDurationBy(const std::shared_ptr& element) const -> std::optional> { const auto& testCaseFinished = FindTestCaseFinishedBy(element); if (testCaseFinished.has_value()) @@ -540,7 +541,7 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindTestCaseDurationBy(const std::shared_ptr& element) const + auto Query::FindTestCaseDurationBy(const std::shared_ptr& element) const -> std::optional> { const auto testCaseStarted = FindTestCaseStartedBy(element); @@ -552,8 +553,9 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindTestCaseStartedBy( + auto Query::FindTestCaseStartedBy( std::variant, std::shared_ptr, std::shared_ptr> element) const + -> std::optional> { return std::visit( [this](const auto& item) -> std::optional> @@ -568,7 +570,7 @@ namespace cucumber::query element); } - std::optional> Query::FindTestCaseFinishedBy(const std::shared_ptr& testCaseStarted) const + auto Query::FindTestCaseFinishedBy(const std::shared_ptr& testCaseStarted) const -> std::optional> { if (testCaseFinishedByTestCaseStartedId.find(testCaseStarted->id) != testCaseFinishedByTestCaseStartedId.end()) { @@ -577,7 +579,7 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindTestRunHookStartedBy(const std::shared_ptr& testRunHookFinished) const + auto Query::FindTestRunHookStartedBy(const std::shared_ptr& testRunHookFinished) const -> std::optional> { const auto iter = testRunHookStartedById.find(testRunHookFinished->testRunHookStartedId); if (iter != testRunHookStartedById.end()) @@ -587,7 +589,7 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindTestRunHookFinishedBy(const std::shared_ptr& testRunHookStarted) const + auto Query::FindTestRunHookFinishedBy(const std::shared_ptr& testRunHookStarted) const -> std::optional> { if (testRunHookFinishedByTestRunHookStartedId.find(testRunHookStarted->id) != testRunHookFinishedByTestRunHookStartedId.end()) { @@ -596,7 +598,7 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindTestRunDuration() const + auto Query::FindTestRunDuration() const -> std::optional> { if (testRunStarted.has_value() && testRunFinished.has_value()) { @@ -606,18 +608,18 @@ namespace cucumber::query return std::nullopt; } - std::optional> Query::FindTestRunFinished() const + auto Query::FindTestRunFinished() const -> std::optional> { return testRunFinished; } - std::optional> Query::FindTestRunStarted() const + auto Query::FindTestRunStarted() const -> std::optional> { return testRunStarted; } - std::optional> Query::FindTestStepBy( - std::variant, std::shared_ptr> element) const + auto Query::FindTestStepBy(std::variant, std::shared_ptr> element) const + -> std::optional> { try { @@ -634,7 +636,7 @@ namespace cucumber::query } } - std::vector> Query::FindTestStepsStartedBy(const std::shared_ptr& testCaseStarted) const + auto Query::FindTestStepsStartedBy(const std::shared_ptr& testCaseStarted) const -> std::vector> { if (testStepStartedByTestCaseStartedId.find(testCaseStarted->id) != testStepStartedByTestCaseStartedId.end()) { @@ -643,7 +645,7 @@ namespace cucumber::query return {}; } - std::vector> Query::FindTestStepsStartedBy(const std::shared_ptr& testCaseFinished) const + auto Query::FindTestStepsStartedBy(const std::shared_ptr& testCaseFinished) const -> std::vector> { if (testStepStartedByTestCaseStartedId.find(testCaseFinished->testCaseStartedId) != testStepStartedByTestCaseStartedId.end()) { @@ -652,8 +654,8 @@ namespace cucumber::query return {}; } - std::vector> Query::FindTestStepsFinishedBy( - std::variant, std::shared_ptr> element) const + auto Query::FindTestStepsFinishedBy(std::variant, std::shared_ptr> element) const + -> std::vector> { const auto& optionalTestCaseStarted = std::visit(overloaded{ [this](const std::shared_ptr& element) { @@ -673,8 +675,8 @@ namespace cucumber::query return {}; } - std::vector, std::shared_ptr>> Query::FindTestStepFinishedAndTestStepBy( - const std::shared_ptr& testCaseStarted) const + auto Query::FindTestStepFinishedAndTestStepBy(const std::shared_ptr& testCaseStarted) const + -> std::vector, std::shared_ptr>> { std::vector, std::shared_ptr>> result; const auto testStepsFinishedIter = testStepFinishedByTestCaseStartedId.find(testCaseStarted->id); @@ -718,7 +720,7 @@ namespace cucumber::query return std::nullopt; } - void Query::UpdateGherkinDocument(const std::shared_ptr& gherkinDocument) + auto Query::UpdateGherkinDocument(const std::shared_ptr& gherkinDocument) -> void { if (gherkinDocument->feature.has_value()) { @@ -726,7 +728,7 @@ namespace cucumber::query } } - void Query::UpdateFeature(const std::shared_ptr& feature, const std::shared_ptr& lineage) + auto Query::UpdateFeature(const std::shared_ptr& feature, const std::shared_ptr& lineage) -> void { for (const auto& featureChild : feature->children) { @@ -748,7 +750,7 @@ namespace cucumber::query } } - void Query::UpdateRule(const std::shared_ptr& rule, const std::shared_ptr& lineage) + auto Query::UpdateRule(const std::shared_ptr& rule, const std::shared_ptr& lineage) -> void { for (const auto& ruleChild : rule->children) { @@ -765,7 +767,7 @@ namespace cucumber::query } } - void Query::UpdateScenario(const std::shared_ptr& scenario, const std::shared_ptr& lineage) + auto Query::UpdateScenario(const std::shared_ptr& scenario, const std::shared_ptr& lineage) -> void { lineageById[scenario->id] = std::make_shared(*lineage + Lineage{ {}, {}, {}, {}, {}, scenario }); @@ -786,7 +788,7 @@ namespace cucumber::query UpdateSteps(scenario->steps); } - void Query::UpdateSteps(const std::vector>& steps) + auto Query::UpdateSteps(const std::vector>& steps) -> void { for (const auto& step : steps) { @@ -794,7 +796,7 @@ namespace cucumber::query } } - void Query::UpdatePickle(std::shared_ptr pickle) + auto Query::UpdatePickle(std::shared_ptr pickle) -> void { auto&& entry = pickleById[pickle->id] = std::move(pickle); for (const auto& pickleStep : entry->steps) @@ -803,21 +805,17 @@ namespace cucumber::query } } - void Query::UpdateTestRunHookStarted(const std::shared_ptr& testRunHookStarted) + auto Query::UpdateTestRunHookStarted(const std::shared_ptr& testRunHookStarted) -> void { testRunHookStartedById[testRunHookStarted->id] = testRunHookStarted; } - void Query::UpdateTestRunHookFinished(const std::shared_ptr& testRunHookFinished) + auto Query::UpdateTestRunHookFinished(const std::shared_ptr& testRunHookFinished) -> void { testRunHookFinishedByTestRunHookStartedId[testRunHookFinished->testRunHookStartedId] = testRunHookFinished; } - ///////////////////////////// - ///////////////////////////// - ///////////////////////////// - - void Query::UpdateTestCase(std::shared_ptr testCase) + auto Query::UpdateTestCase(std::shared_ptr testCase) -> void { for (const auto& testStep : testCase->testSteps) { @@ -826,14 +824,12 @@ namespace cucumber::query testCaseById[testCase->id] = std::move(testCase); } - void Query::UpdateTestCaseStarted(std::shared_ptr testCaseStarted) + auto Query::UpdateTestCaseStarted(std::shared_ptr testCaseStarted) -> void { testCaseStartedById[testCaseStarted->id] = std::move(testCaseStarted); } - ///////////////////////////// - - void Query::UpdateAttachment(const std::shared_ptr& attachment) + auto Query::UpdateAttachment(const std::shared_ptr& attachment) -> void { if (attachment->testCaseStartedId.has_value()) { @@ -845,18 +841,13 @@ namespace cucumber::query } } - void Query::UpdateTestStepFinished(std::shared_ptr testStepFinished) + auto Query::UpdateTestStepFinished(std::shared_ptr testStepFinished) -> void { testStepFinishedByTestCaseStartedId[testStepFinished->testCaseStartedId].push_back(std::move(testStepFinished)); } - void Query::UpdateTestCaseFinished(std::shared_ptr testCaseFinished) + auto Query::UpdateTestCaseFinished(std::shared_ptr testCaseFinished) -> void { testCaseFinishedByTestCaseStartedId[testCaseFinished->testCaseStartedId] = std::move(testCaseFinished); } - - ///////////////////////////// - ///////////////////////////// - ///////////////////////////// - ///////////////////////////// } diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index d28af4ca..a56593aa 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -27,7 +27,7 @@ namespace cucumber::query { namespace { - std::set> CollectFiles(const std::filesystem::path& folder) + auto CollectFiles(const std::filesystem::path& folder) -> std::set> { std::set> foundFiles; @@ -52,7 +52,7 @@ namespace cucumber::query std::set> json; }; - std::int32_t ReversePickleComparator(const std::shared_ptr& lhs, const std::shared_ptr& rhs) + auto ReversePickleComparator(const std::shared_ptr& lhs, const std::shared_ptr& rhs) -> std::int32_t { if (lhs->uri != rhs->uri) { @@ -65,22 +65,21 @@ namespace cucumber::query return static_cast(rhs->location.value()->column.value()) - static_cast(lhs->location.value()->column.value()); }; - std::optional> FindPickleBy(const query::Query& query, - std::variant, std::shared_ptr, std::shared_ptr, - std::shared_ptr> - element) + auto FindPickleBy(const query::Query& query, std::variant, std::shared_ptr, + std::shared_ptr, std::shared_ptr> + element) -> std::optional> { return query.FindPickleBy(std::move(element)); }; template - nlohmann::json GetSizeOf(const query::Query& query) + auto GetSizeOf(const query::Query& query) -> nlohmann::json { const auto actual = (query.*F)(); return actual.size(); } - nlohmann::json CountMostSevereTestStepResultStatus(const query::Query& query) + auto CountMostSevereTestStepResultStatus(const query::Query& query) -> nlohmann::json { nlohmann::json actual; @@ -92,13 +91,13 @@ namespace cucumber::query return actual; } - nlohmann::json CountTestCasesStarted(const query::Query& query) + auto CountTestCasesStarted(const query::Query& query) -> nlohmann::json { const auto actual = query.CountTestCasesStarted(); return actual; } - nlohmann::json FindAllTestCaseFinishedOrderBy(const query::Query& query) + auto FindAllTestCaseFinishedOrderBy(const query::Query& query) -> nlohmann::json { const auto allResults = query.FindAllTestCaseFinishedOrderBy(&FindPickleBy, ReversePickleComparator); nlohmann::json actual; @@ -110,7 +109,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindAllTestCaseStartedOrderBy(const query::Query& query) + auto FindAllTestCaseStartedOrderBy(const query::Query& query) -> nlohmann::json { const auto allResults = query.FindAllTestCaseStartedOrderBy(&FindPickleBy, ReversePickleComparator); nlohmann::json actual; @@ -122,7 +121,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindAllUndefinedParameterTypes(query::Query const& query) + auto FindAllUndefinedParameterTypes(query::Query const& query) -> nlohmann::json { nlohmann::json actual = nlohmann::json::array(); @@ -134,7 +133,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindAttachmentsBy(const query::Query& query) + auto FindAttachmentsBy(const query::Query& query) -> nlohmann::json { nlohmann::json actual = { { "testStepFinished", nlohmann::json::array() }, { "testRunHookFinished", nlohmann::json::array() } }; @@ -167,7 +166,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindHookBy(const query::Query& query) + auto FindHookBy(const query::Query& query) -> nlohmann::json { const auto findHookBy = [&query](const auto& testSteps) { @@ -194,7 +193,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindLineageBy(const query::Query& query) + auto FindLineageBy(const query::Query& query) -> nlohmann::json { const auto namingStrategy = CreateNamingStrategy(NamingStrategyLength::longName, NamingStrategyFeatureName::include, NamingStrategyExampleName::number); @@ -224,7 +223,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindLocationOf(const query::Query& query) + auto FindLocationOf(const query::Query& query) -> nlohmann::json { nlohmann::json actual = nlohmann::json::array(); @@ -240,7 +239,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindMeta(const query::Query& query) + auto FindMeta(const query::Query& query) -> nlohmann::json { const auto meta = query.FindMeta(); @@ -252,7 +251,7 @@ namespace cucumber::query return {}; } - nlohmann::json FindMostSevereTestStepResultBy(const query::Query& query) + auto FindMostSevereTestStepResultBy(const query::Query& query) -> nlohmann::json { const auto findMostSevereTestStepResultBy = [&query](const auto& items) { @@ -278,7 +277,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindPickleBy(const query::Query& query) + auto FindPickleBy(const query::Query& query) -> nlohmann::json { const auto findPickleBy = [&query](const auto& items) { @@ -306,7 +305,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindPickleStepBy(const query::Query& query) + auto FindPickleStepBy(const query::Query& query) -> nlohmann::json { nlohmann::json actual = nlohmann::json::array(); @@ -322,7 +321,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindStepBy(const query::Query& query) + auto FindStepBy(const query::Query& query) -> nlohmann::json { nlohmann::json actual = nlohmann::json::array(); @@ -338,7 +337,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindStepDefinitionsBy(const query::Query& query) + auto FindStepDefinitionsBy(const query::Query& query) -> nlohmann::json { nlohmann::json actual = nlohmann::json::array(); @@ -355,7 +354,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindSuggestionsBy(const query::Query& query) + auto FindSuggestionsBy(const query::Query& query) -> nlohmann::json { const auto findSuggestionsBy = [&query](const auto& items) { @@ -380,7 +379,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestCaseBy(const query::Query& query) + auto FindTestCaseBy(const query::Query& query) -> nlohmann::json { const auto findTestCaseBy = [&query](const auto& items) { @@ -407,7 +406,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestCaseDurationBy(const query::Query& query) + auto FindTestCaseDurationBy(const query::Query& query) -> nlohmann::json { const auto findTestCaseDurationBy = [&query](const auto& items) { @@ -432,7 +431,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestCaseFinishedBy(const query::Query& query) + auto FindTestCaseFinishedBy(const query::Query& query) -> nlohmann::json { nlohmann::json actual = nlohmann::json::array(); @@ -448,7 +447,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestCaseStartedBy(const query::Query& query) + auto FindTestCaseStartedBy(const query::Query& query) -> nlohmann::json { const auto findTestCaseStartedBy = [&query](const auto& items) { @@ -474,7 +473,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestRunDuration(const query::Query& query) + auto FindTestRunDuration(const query::Query& query) -> nlohmann::json { nlohmann::json actual; @@ -487,7 +486,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestRunFinished(const query::Query& query) + auto FindTestRunFinished(const query::Query& query) -> nlohmann::json { nlohmann::json actual; @@ -500,7 +499,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestRunHookFinishedBy(const query::Query& query) + auto FindTestRunHookFinishedBy(const query::Query& query) -> nlohmann::json { nlohmann::json actual = nlohmann::json::array(); @@ -516,7 +515,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestRunHookStartedBy(const query::Query& query) + auto FindTestRunHookStartedBy(const query::Query& query) -> nlohmann::json { nlohmann::json actual = nlohmann::json::array(); @@ -532,7 +531,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestRunStarted(const query::Query& query) + auto FindTestRunStarted(const query::Query& query) -> nlohmann::json { nlohmann::json actual; @@ -545,7 +544,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestStepBy(const query::Query& query) + auto FindTestStepBy(const query::Query& query) -> nlohmann::json { nlohmann::json actual{ { "testStepStarted", nlohmann::json::array() }, @@ -573,7 +572,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestStepFinishedAndTestStepBy(const query::Query& query) + auto FindTestStepFinishedAndTestStepBy(const query::Query& query) -> nlohmann::json { nlohmann::json actual = nlohmann::json::array(); @@ -588,7 +587,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestStepsFinishedBy(const query::Query& query) + auto FindTestStepsFinishedBy(const query::Query& query) -> nlohmann::json { const auto findTestStepsFinishedBy = [&](const auto& items) { @@ -616,7 +615,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindTestStepsStartedBy(const query::Query& query) + auto FindTestStepsStartedBy(const query::Query& query) -> nlohmann::json { const auto findTestStepsStartedBy = [&](const auto& items) { @@ -644,7 +643,7 @@ namespace cucumber::query return actual; } - nlohmann::json FindUnambiguousStepDefinitionBy(const query::Query& query) + auto FindUnambiguousStepDefinitionBy(const query::Query& query) -> nlohmann::json { nlohmann::json actual = nlohmann::json::array(); @@ -712,7 +711,7 @@ namespace cucumber::query {} private: - void TestBody() override + auto TestBody() -> void override { const auto* testInfo = testing::UnitTest::GetInstance()->current_test_info(); const auto* testCaseName = testInfo->name(); @@ -747,7 +746,7 @@ namespace cucumber::query std::filesystem::path expected; }; - TestData GetTestFiles() + auto GetTestFiles() -> TestData { auto foundFiles = CollectFiles(TESTDATA_SRC); @@ -777,7 +776,7 @@ namespace cucumber::query return testData; } - std::string FilterName(std::string str) + auto FilterName(std::string str) -> std::string { for (auto iter = str.find('-'); iter != std::string::npos; iter = str.find('-')) { From dda5e912e0549c49ac100545b1f20524e5c61659 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 21:20:42 +0000 Subject: [PATCH 22/56] refactor TestQuery to use google test's parameterized tests --- cpp/.clang-tidy | 1 + cpp/include/cucumber/query/NamingStrategy.hpp | 1 + cpp/test/CMakeLists.txt | 2 +- cpp/test/TestQuery.cpp | 528 +++++++++--------- testdata/.gitattributes | 3 + 5 files changed, 283 insertions(+), 252 deletions(-) create mode 100644 testdata/.gitattributes diff --git a/cpp/.clang-tidy b/cpp/.clang-tidy index 2be4e46e..ceb9f008 100644 --- a/cpp/.clang-tidy +++ b/cpp/.clang-tidy @@ -3,6 +3,7 @@ Checks: ' bugprone-*, clang-analyzer-*, cppcoreguidelines*, + -cppcoreguidelines-non-private-member-variables-in-classes, misc-*, -misc-non-private-member-variables-in-classes, modernize*, diff --git a/cpp/include/cucumber/query/NamingStrategy.hpp b/cpp/include/cucumber/query/NamingStrategy.hpp index 5b8ed84e..152f1144 100644 --- a/cpp/include/cucumber/query/NamingStrategy.hpp +++ b/cpp/include/cucumber/query/NamingStrategy.hpp @@ -4,6 +4,7 @@ #include "cucumber/messages/Pickle.hpp" #include "cucumber/query/Lineage.hpp" #include +#include #include namespace cucumber::query diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index 16a444c6..b3351f00 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -9,7 +9,7 @@ target_sources(cucumber_query_lib.test target_link_libraries(cucumber_query_lib.test PRIVATE cucumber::query - GTest::gmock + GTest::gmock_main ) target_compile_definitions(cucumber_query_lib.test diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index a56593aa..ff8e36af 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -6,19 +6,18 @@ #include "nlohmann/json_fwd.hpp" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include +#include #include -#include #include #include -#include +#include #include -#include #include #include -#include +#include #include #include -#include #include #include #include @@ -27,30 +26,110 @@ namespace cucumber::query { namespace { - auto CollectFiles(const std::filesystem::path& folder) -> std::set> + auto EndsWith(std::string_view value, std::string_view suffix) -> bool { - std::set> foundFiles; + return value.size() >= suffix.size() && value.compare(value.size() - suffix.size(), suffix.size(), suffix) == 0; + } + + struct Expectation + { + std::string_view infix; + std::string_view suffix; + }; + + struct DataSet + { + std::filesystem::path source; + }; + + // Determines how ctest names the generated tests. + auto PrintTo(const DataSet& dataSet, std::ostream* stream) -> void + { + *stream << dataSet.source.stem().string(); + } + + // Data sets are `.ndjson`, their expectations ``. + auto GetDataSets(const Expectation& expectation) -> std::vector + { + std::vector sources; + std::vector expectations; - for (const auto& entry : std::filesystem::directory_iterator{ folder }) + for (const auto& entry : std::filesystem::directory_iterator{ std::filesystem::path{ TESTDATA_SRC } }) { - foundFiles.emplace(entry.path()); + auto fileName = entry.path().filename().string(); + + if (entry.path().extension() == ".ndjson") + { + sources.push_back(entry.path()); + } + else if (EndsWith(fileName, expectation.suffix)) + { + expectations.push_back(std::move(fileName)); + } } - return foundFiles; + std::vector dataSets; + + for (auto& source : sources) + { + const auto prefix = source.stem().string() + std::string{ expectation.infix }; + const auto hasExpectations = std::any_of(expectations.begin(), expectations.end(), + [&prefix](const std::string& expectation) + { + return expectation.compare(0, prefix.size(), prefix) == 0; + }); + + if (hasExpectations) + { + dataSets.push_back(DataSet{ std::move(source) }); + } + } + + std::sort(dataSets.begin(), dataSets.end(), + [](const DataSet& lhs, const DataSet& rhs) + { + return lhs.source < rhs.source; + }); + + return dataSets; } - struct TestData + auto ExpectedPath(const std::filesystem::path& dataSet, const std::string& suffix) -> std::filesystem::path { - std::list ndjson; - std::list json; - std::set> txt; - }; + return dataSet.parent_path() / (dataSet.stem().string() + suffix); + } - struct TestSet + auto DataSetName(const testing::TestParamInfo& info) -> std::string { - std::filesystem::path ndjson; - std::set> json; - }; + auto name = info.param.source.stem().string(); + + std::replace_if( + name.begin(), name.end(), + [](unsigned char character) + { + return std::isalnum(character) == 0; + }, + '_'); + + return name; + } + + auto LoadQuery(const std::filesystem::path& source) -> Query + { + Query query; + + std::ifstream ifstream{ source }; + std::string line; + while (std::getline(ifstream, line)) + { + messages::Envelope envelope; + envelope.from_json(nlohmann::json::parse(line)); + + query.Update(envelope); + } + + return query; + } auto ReversePickleComparator(const std::shared_ptr& lhs, const std::shared_ptr& rhs) -> std::int32_t { @@ -72,14 +151,88 @@ namespace cucumber::query return query.FindPickleBy(std::move(element)); }; - template - auto GetSizeOf(const query::Query& query) -> nlohmann::json + struct QueryAcceptanceTest : testing::TestWithParam + { + protected: + auto SetUp() -> void override + { + query = LoadQuery(GetParam().source); + } + + static auto Verify(std::string_view queryName, const nlohmann::json& actual) -> void + { + const auto expected = ExpectedPath(GetParam().source, "." + std::string{ queryName } + ".results.json"); + + if (!std::filesystem::exists(expected)) + { + GTEST_SKIP() << "No expected results at " << expected; + } + + std::ifstream ifstream{ expected }; + EXPECT_THAT(actual, testing::Eq(nlohmann::json::parse(ifstream))); + } + + Query query; + }; + + INSTANTIATE_TEST_SUITE_P(Acceptance, QueryAcceptanceTest, testing::ValuesIn(GetDataSets({ ".", ".results.json" })), DataSetName); + + TEST_P(QueryAcceptanceTest, findAllPickles) + { + Verify("findAllPickles", query.FindAllPickles().size()); + } + + TEST_P(QueryAcceptanceTest, findAllPickleSteps) + { + Verify("findAllPickleSteps", query.FindAllPickleSteps().size()); + } + + TEST_P(QueryAcceptanceTest, findAllStepDefinitions) + { + Verify("findAllStepDefinitions", query.FindAllStepDefinitions().size()); + } + + TEST_P(QueryAcceptanceTest, findAllTestCaseFinished) + { + Verify("findAllTestCaseFinished", query.FindAllTestCaseFinished().size()); + } + + TEST_P(QueryAcceptanceTest, findAllTestCases) { - const auto actual = (query.*F)(); - return actual.size(); + Verify("findAllTestCases", query.FindAllTestCases().size()); } - auto CountMostSevereTestStepResultStatus(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findAllTestCaseStarted) + { + Verify("findAllTestCaseStarted", query.FindAllTestCaseStarted().size()); + } + + TEST_P(QueryAcceptanceTest, findAllTestRunHookFinished) + { + Verify("findAllTestRunHookFinished", query.FindAllTestRunHookFinished().size()); + } + + TEST_P(QueryAcceptanceTest, findAllTestRunHookStarted) + { + Verify("findAllTestRunHookStarted", query.FindAllTestRunHookStarted().size()); + } + + TEST_P(QueryAcceptanceTest, findAllTestStepFinished) + { + Verify("findAllTestStepFinished", query.FindAllTestStepFinished().size()); + } + + TEST_P(QueryAcceptanceTest, findAllTestSteps) + { + Verify("findAllTestSteps", query.FindAllTestSteps().size()); + } + + TEST_P(QueryAcceptanceTest, findAllTestStepStarted) + { + Verify("findAllTestStepStarted", query.FindAllTestStepStarted().size()); + } + + TEST_P(QueryAcceptanceTest, countMostSevereTestStepResultStatus) { nlohmann::json actual; @@ -88,16 +241,15 @@ namespace cucumber::query actual[to_string(status)] = count; } - return actual; + Verify("countMostSevereTestStepResultStatus", actual); } - auto CountTestCasesStarted(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, countTestCasesStarted) { - const auto actual = query.CountTestCasesStarted(); - return actual; + Verify("countTestCasesStarted", query.CountTestCasesStarted()); } - auto FindAllTestCaseFinishedOrderBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findAllTestCaseFinishedOrderBy) { const auto allResults = query.FindAllTestCaseFinishedOrderBy(&FindPickleBy, ReversePickleComparator); nlohmann::json actual; @@ -106,10 +258,10 @@ namespace cucumber::query actual.push_back(testCaseFinished->testCaseStartedId); } - return actual; + Verify("findAllTestCaseFinishedOrderBy", actual); } - auto FindAllTestCaseStartedOrderBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findAllTestCaseStartedOrderBy) { const auto allResults = query.FindAllTestCaseStartedOrderBy(&FindPickleBy, ReversePickleComparator); nlohmann::json actual; @@ -118,10 +270,10 @@ namespace cucumber::query actual.push_back(testCaseStarted->id); } - return actual; + Verify("findAllTestCaseStartedOrderBy", actual); } - auto FindAllUndefinedParameterTypes(query::Query const& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findAllUndefinedParameterTypes) { nlohmann::json actual = nlohmann::json::array(); @@ -130,10 +282,10 @@ namespace cucumber::query actual.push_back({ undefinedParameterType->name, undefinedParameterType->expression }); } - return actual; + Verify("findAllUndefinedParameterTypes", actual); } - auto FindAttachmentsBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findAttachmentsBy) { nlohmann::json actual = { { "testStepFinished", nlohmann::json::array() }, { "testRunHookFinished", nlohmann::json::array() } }; @@ -163,12 +315,12 @@ namespace cucumber::query } } - return actual; + Verify("findAttachmentsBy", actual); } - auto FindHookBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findHookBy) { - const auto findHookBy = [&query](const auto& testSteps) + const auto findHookBy = [this](const auto& testSteps) { nlohmann::json actual = nlohmann::json::array(); @@ -190,14 +342,14 @@ namespace cucumber::query actual["testRunHookStarted"] = findHookBy(query.FindAllTestRunHookStarted()); actual["testRunHookFinished"] = findHookBy(query.FindAllTestRunHookFinished()); - return actual; + Verify("findHookBy", actual); } - auto FindLineageBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findLineageBy) { const auto namingStrategy = CreateNamingStrategy(NamingStrategyLength::longName, NamingStrategyFeatureName::include, NamingStrategyExampleName::number); - const auto findLineageBy = [&namingStrategy, &query](const auto& items) + const auto findLineageBy = [this, &namingStrategy](const auto& items) { nlohmann::json actual = nlohmann::json::array(); @@ -220,10 +372,10 @@ namespace cucumber::query actual["testCaseFinished"] = findLineageBy(query.FindAllTestCaseFinished()); actual["pickle"] = findLineageBy(query.FindAllPickles()); - return actual; + Verify("findLineageBy", actual); } - auto FindLocationOf(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findLocationOf) { nlohmann::json actual = nlohmann::json::array(); @@ -236,24 +388,25 @@ namespace cucumber::query } } - return actual; + Verify("findLocationOf", actual); } - auto FindMeta(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findMeta) { const auto meta = query.FindMeta(); + nlohmann::json actual; if (meta.has_value()) { - return meta.value()->implementation->name; + actual = meta.value()->implementation->name; } - return {}; + Verify("findMeta", actual); } - auto FindMostSevereTestStepResultBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findMostSevereTestStepResultBy) { - const auto findMostSevereTestStepResultBy = [&query](const auto& items) + const auto findMostSevereTestStepResultBy = [this](const auto& items) { nlohmann::json actual = nlohmann::json::array(); @@ -274,12 +427,12 @@ namespace cucumber::query actual["testCaseStarted"] = findMostSevereTestStepResultBy(query.FindAllTestCaseStarted()); actual["testCaseFinished"] = findMostSevereTestStepResultBy(query.FindAllTestCaseFinished()); - return actual; + Verify("findMostSevereTestStepResultBy", actual); } - auto FindPickleBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findPickleBy) { - const auto findPickleBy = [&query](const auto& items) + const auto findPickleBy = [this](const auto& items) { nlohmann::json actual = nlohmann::json::array(); @@ -302,10 +455,10 @@ namespace cucumber::query actual["testStepStarted"] = findPickleBy(query.FindAllTestStepStarted()); actual["testStepFinished"] = findPickleBy(query.FindAllTestStepFinished()); - return actual; + Verify("findPickleBy", actual); } - auto FindPickleStepBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findPickleStepBy) { nlohmann::json actual = nlohmann::json::array(); @@ -318,10 +471,10 @@ namespace cucumber::query } } - return actual; + Verify("findPickleStepBy", actual); } - auto FindStepBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findStepBy) { nlohmann::json actual = nlohmann::json::array(); @@ -334,10 +487,10 @@ namespace cucumber::query } } - return actual; + Verify("findStepBy", actual); } - auto FindStepDefinitionsBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findStepDefinitionsBy) { nlohmann::json actual = nlohmann::json::array(); @@ -351,12 +504,12 @@ namespace cucumber::query } } - return actual; + Verify("findStepDefinitionsBy", actual); } - auto FindSuggestionsBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findSuggestionsBy) { - const auto findSuggestionsBy = [&query](const auto& items) + const auto findSuggestionsBy = [this](const auto& items) { nlohmann::json actual = nlohmann::json::array(); @@ -376,12 +529,12 @@ namespace cucumber::query actual["pickleStep"] = findSuggestionsBy(query.FindAllPickleSteps()); actual["pickle"] = findSuggestionsBy(query.FindAllPickles()); - return actual; + Verify("findSuggestionsBy", actual); } - auto FindTestCaseBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestCaseBy) { - const auto findTestCaseBy = [&query](const auto& items) + const auto findTestCaseBy = [this](const auto& items) { nlohmann::json actual = nlohmann::json::array(); @@ -403,12 +556,12 @@ namespace cucumber::query actual["testStepStarted"] = findTestCaseBy(query.FindAllTestStepStarted()); actual["testStepFinished"] = findTestCaseBy(query.FindAllTestStepFinished()); - return actual; + Verify("findTestCaseBy", actual); } - auto FindTestCaseDurationBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestCaseDurationBy) { - const auto findTestCaseDurationBy = [&query](const auto& items) + const auto findTestCaseDurationBy = [this](const auto& items) { nlohmann::json actual = nlohmann::json::array(); @@ -428,10 +581,10 @@ namespace cucumber::query actual["testCaseStarted"] = findTestCaseDurationBy(query.FindAllTestCaseStarted()); actual["testCaseFinished"] = findTestCaseDurationBy(query.FindAllTestCaseFinished()); - return actual; + Verify("findTestCaseDurationBy", actual); } - auto FindTestCaseFinishedBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestCaseFinishedBy) { nlohmann::json actual = nlohmann::json::array(); @@ -444,12 +597,12 @@ namespace cucumber::query } } - return actual; + Verify("findTestCaseFinishedBy", actual); } - auto FindTestCaseStartedBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestCaseStartedBy) { - const auto findTestCaseStartedBy = [&query](const auto& items) + const auto findTestCaseStartedBy = [this](const auto& items) { nlohmann::json actual = nlohmann::json::array(); for (const auto& testCaseFinished : items) @@ -470,10 +623,10 @@ namespace cucumber::query actual["testStepStarted"] = findTestCaseStartedBy(query.FindAllTestStepStarted()); actual["testStepFinished"] = findTestCaseStartedBy(query.FindAllTestStepFinished()); - return actual; + Verify("findTestCaseStartedBy", actual); } - auto FindTestRunDuration(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestRunDuration) { nlohmann::json actual; @@ -483,10 +636,10 @@ namespace cucumber::query testRunDuration.value()->to_json(actual); } - return actual; + Verify("findTestRunDuration", actual); } - auto FindTestRunFinished(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestRunFinished) { nlohmann::json actual; @@ -496,10 +649,10 @@ namespace cucumber::query testRunFinished.value()->to_json(actual); } - return actual; + Verify("findTestRunFinished", actual); } - auto FindTestRunHookFinishedBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestRunHookFinishedBy) { nlohmann::json actual = nlohmann::json::array(); @@ -512,10 +665,10 @@ namespace cucumber::query } } - return actual; + Verify("findTestRunHookFinishedBy", actual); } - auto FindTestRunHookStartedBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestRunHookStartedBy) { nlohmann::json actual = nlohmann::json::array(); @@ -528,10 +681,10 @@ namespace cucumber::query } } - return actual; + Verify("findTestRunHookStartedBy", actual); } - auto FindTestRunStarted(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestRunStarted) { nlohmann::json actual; @@ -541,10 +694,10 @@ namespace cucumber::query testRunStarted.value()->to_json(actual); } - return actual; + Verify("findTestRunStarted", actual); } - auto FindTestStepBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestStepBy) { nlohmann::json actual{ { "testStepStarted", nlohmann::json::array() }, @@ -569,10 +722,10 @@ namespace cucumber::query findTestStepBy(query.FindTestStepsFinishedBy(item), "testStepFinished"); } - return actual; + Verify("findTestStepBy", actual); } - auto FindTestStepFinishedAndTestStepBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestStepFinishedAndTestStepBy) { nlohmann::json actual = nlohmann::json::array(); @@ -584,10 +737,10 @@ namespace cucumber::query } } - return actual; + Verify("findTestStepFinishedAndTestStepBy", actual); } - auto FindTestStepsFinishedBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestStepsFinishedBy) { const auto findTestStepsFinishedBy = [&](const auto& items) { @@ -612,10 +765,10 @@ namespace cucumber::query actual["testCaseStarted"] = findTestStepsFinishedBy(query.FindAllTestCaseStarted()); actual["testCaseFinished"] = findTestStepsFinishedBy(query.FindAllTestCaseFinished()); - return actual; + Verify("findTestStepsFinishedBy", actual); } - auto FindTestStepsStartedBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findTestStepsStartedBy) { const auto findTestStepsStartedBy = [&](const auto& items) { @@ -640,10 +793,10 @@ namespace cucumber::query actual["testCaseStarted"] = findTestStepsStartedBy(query.FindAllTestCaseStarted()); actual["testCaseFinished"] = findTestStepsStartedBy(query.FindAllTestCaseFinished()); - return actual; + Verify("findTestStepsStartedBy", actual); } - auto FindUnambiguousStepDefinitionBy(const query::Query& query) -> nlohmann::json + TEST_P(QueryAcceptanceTest, findUnambiguousStepDefinitionBy) { nlohmann::json actual = nlohmann::json::array(); @@ -656,192 +809,65 @@ namespace cucumber::query } } - return actual; - } - - const std::unordered_map functionMap{ - { "countMostSevereTestStepResultStatus", CountMostSevereTestStepResultStatus }, - { "countTestCasesStarted", CountTestCasesStarted }, - { "findAllPickles", GetSizeOf<&query::Query::FindAllPickles> }, - { "findAllPickleSteps", GetSizeOf<&query::Query::FindAllPickleSteps> }, - { "findAllStepDefinitions", GetSizeOf<&query::Query::FindAllStepDefinitions> }, - { "findAllTestCaseFinished", GetSizeOf<&query::Query::FindAllTestCaseFinished> }, - { "findAllTestCaseFinishedOrderBy", FindAllTestCaseFinishedOrderBy }, - { "findAllTestCases", GetSizeOf<&query::Query::FindAllTestCases> }, - { "findAllTestCaseStarted", GetSizeOf<&query::Query::FindAllTestCaseStarted> }, - { "findAllTestCaseStartedOrderBy", FindAllTestCaseStartedOrderBy }, - { "findAllTestRunHookFinished", GetSizeOf<&query::Query::FindAllTestRunHookFinished> }, - { "findAllTestRunHookStarted", GetSizeOf<&query::Query::FindAllTestRunHookStarted> }, - { "findAllTestStepFinished", GetSizeOf<&query::Query::FindAllTestStepFinished> }, - { "findAllTestSteps", GetSizeOf<&query::Query::FindAllTestSteps> }, - { "findAllTestStepStarted", GetSizeOf<&query::Query::FindAllTestStepStarted> }, - { "findAllUndefinedParameterTypes", FindAllUndefinedParameterTypes }, - { "findAttachmentsBy", FindAttachmentsBy }, - { "findHookBy", FindHookBy }, - { "findLineageBy", FindLineageBy }, - { "findLocationOf", FindLocationOf }, - { "findMeta", FindMeta }, - { "findMostSevereTestStepResultBy", FindMostSevereTestStepResultBy }, - { "findPickleBy", FindPickleBy }, - { "findPickleStepBy", FindPickleStepBy }, - { "findStepBy", FindStepBy }, - { "findStepDefinitionsBy", FindStepDefinitionsBy }, - { "findSuggestionsBy", FindSuggestionsBy }, - { "findTestCaseBy", FindTestCaseBy }, - { "findTestCaseDurationBy", FindTestCaseDurationBy }, - { "findTestCaseFinishedBy", FindTestCaseFinishedBy }, - { "findTestCaseStartedBy", FindTestCaseStartedBy }, - { "findTestRunDuration", FindTestRunDuration }, - { "findTestRunFinished", FindTestRunFinished }, - { "findTestRunHookFinishedBy", FindTestRunHookFinishedBy }, - { "findTestRunHookStartedBy", FindTestRunHookStartedBy }, - { "findTestRunStarted", FindTestRunStarted }, - { "findTestStepBy", FindTestStepBy }, - { "findTestStepFinishedAndTestStepBy", FindTestStepFinishedAndTestStepBy }, - { "findTestStepsFinishedBy", FindTestStepsFinishedBy }, - { "findTestStepsStartedBy", FindTestStepsStartedBy }, - { "findUnambiguousStepDefinitionBy", FindUnambiguousStepDefinitionBy }, - }; + Verify("findUnambiguousStepDefinitionBy", actual); + } - struct AcceptanceTest : testing::Test + struct NamingStrategyAcceptanceTest : testing::TestWithParam { - AcceptanceTest(std::filesystem::path input, std::filesystem::path expected) - : input{ std::move(input) } - , expected{ std::move(expected) } - {} - - private: - auto TestBody() -> void override + protected: + auto SetUp() -> void override { - const auto* testInfo = testing::UnitTest::GetInstance()->current_test_info(); - const auto* testCaseName = testInfo->name(); + query = LoadQuery(GetParam().source); + } - if (functionMap.find(testCaseName) == functionMap.end()) - { - GTEST_SKIP() << "No function registered for test case: " << testCaseName; - } + auto Verify(std::string_view variant, const NamingStrategy& strategy) const -> void + { + std::string actual; - // load Query with messages + for (const auto& pickle : query.FindAllPickles()) { - std::ifstream ifstream{ input }; - std::string line; - while (std::getline(ifstream, line)) + const auto lineageAndPickle = query.FindLineageBy(pickle); + if (lineageAndPickle.has_value()) { - messages::Envelope envelope; - envelope.from_json(nlohmann::json::parse(line)); - - query.Update(envelope); + actual += strategy.Reduce(*lineageAndPickle.value().lineage, *lineageAndPickle.value().pickle) + "\n"; } } - { - std::ifstream ifstream{ expected }; - EXPECT_THAT(functionMap.at(testCaseName)(query), testing::Eq(nlohmann::json::parse(ifstream))); - } - } + const auto expected = ExpectedPath(GetParam().source, ".naming-strategy." + std::string{ variant } + ".txt"); - query::Query query; + std::ifstream ifstream{ expected, std::ios::binary }; + EXPECT_EQ(actual, std::string(std::istreambuf_iterator{ ifstream }, std::istreambuf_iterator{})); + } - std::filesystem::path input; - std::filesystem::path expected; + Query query; }; - auto GetTestFiles() -> TestData - { - auto foundFiles = CollectFiles(TESTDATA_SRC); - - TestData testData{}; + INSTANTIATE_TEST_SUITE_P(Acceptance, NamingStrategyAcceptanceTest, testing::ValuesIn(GetDataSets({ ".naming-strategy.", ".txt" })), DataSetName); - while (!foundFiles.empty()) - { - const auto begin = foundFiles.begin(); - if (begin->extension() == ".ndjson") - { - testData.ndjson.emplace_back(std::move(foundFiles.extract(begin).value())); - } - else if (begin->extension() == ".json") - { - testData.json.emplace_back(std::move(foundFiles.extract(begin).value())); - } - else if (begin->extension() == ".txt") - { - testData.txt.emplace(std::move(foundFiles.extract(begin).value())); - } - else - { - throw "unknown extension:" + begin->extension().string(); - } - } - - return testData; - } - - auto FilterName(std::string str) -> std::string + TEST_P(NamingStrategyAcceptanceTest, long) { - for (auto iter = str.find('-'); iter != std::string::npos; iter = str.find('-')) - { - str.replace(iter, 1, "_"); - } - - return str; + Verify("long", *CreateNamingStrategy(NamingStrategyLength::longName)); } - } -} -GTEST_API_ int main(int argc, char** argv) -{ - using namespace cucumber::query; - auto testData = GetTestFiles(); - - std::vector testSets{}; - - for (auto ndjsonIter = testData.ndjson.begin(); ndjsonIter != testData.ndjson.end();) - { - TestSet testSet{}; - const auto& testSetName = ndjsonIter->stem().string(); - - for (auto iter = testData.json.begin(); iter != testData.json.end();) + TEST_P(NamingStrategyAcceptanceTest, long_exclude_feature_name) { - if (iter->filename().string().find(testSetName) == 0) - { - testSet.json.emplace(std::move(*iter)); - testData.json.erase(std::exchange(iter, std::next(iter))); - } - else - { - iter = std::next(iter); - } + Verify("long-exclude-feature-name", *CreateNamingStrategy(NamingStrategyLength::longName, NamingStrategyFeatureName::exclude)); } - if (!testSet.json.empty()) + TEST_P(NamingStrategyAcceptanceTest, long_with_pickle_name) { - testSet.ndjson = std::move(*ndjsonIter); - testSets.push_back(std::move(testSet)); - - testData.ndjson.erase(std::exchange(ndjsonIter, std::next(ndjsonIter))); + Verify("long-with-pickle-name", *CreateNamingStrategy(NamingStrategyLength::longName, NamingStrategyFeatureName::include, NamingStrategyExampleName::pickle)); } - else + + TEST_P(NamingStrategyAcceptanceTest, long_with_pickle_name_if_parameterized) { - ndjsonIter = std::next(ndjsonIter); + Verify("long-with-pickle-name-if-parameterized", + *CreateNamingStrategy(NamingStrategyLength::longName, NamingStrategyFeatureName::include, NamingStrategyExampleName::numberAndPickleIfParameterized)); } - } - for (const auto& suite : testSets) - { - for (const auto& test : suite.json) + TEST_P(NamingStrategyAcceptanceTest, short) { - const auto suiteName = suite.ndjson.stem().string(); - const auto testNameResult = test.stem().string().substr(suiteName.size() + 1); - const auto testName = testNameResult.substr(0, testNameResult.size() - std::strlen(".results")); - - ::testing::RegisterTest(FilterName(suiteName).c_str(), FilterName(testName).c_str(), nullptr, nullptr, test.c_str(), 1, - [ndjson = suite.ndjson, json = test]() -> AcceptanceTest* - { - return new AcceptanceTest(ndjson, json); // NOLINT(cppcoreguidelines-owning-memory) - }); + Verify("short", *CreateNamingStrategy(NamingStrategyLength::shortName)); } } - - testing::InitGoogleMock(&argc, argv); - return RUN_ALL_TESTS(); } diff --git a/testdata/.gitattributes b/testdata/.gitattributes new file mode 100644 index 00000000..ddddd013 --- /dev/null +++ b/testdata/.gitattributes @@ -0,0 +1,3 @@ +*.ndjson text eol=lf +*.json text eol=lf +*.txt text eol=lf From 43b1afca674b06225fe570bedd9e61904c2d0411 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 21:43:10 +0000 Subject: [PATCH 23/56] add clang tidy preset --- cpp/.clang-tidy | 1 + cpp/CMakeLists.txt | 9 +++++++++ cpp/CMakePresets.json | 24 ++++++++++++++++++++++++ cpp/test/CMakeLists.txt | 4 ++++ cpp/test/TestQuery.cpp | 6 +++--- 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/cpp/.clang-tidy b/cpp/.clang-tidy index ceb9f008..a2ac7ffe 100644 --- a/cpp/.clang-tidy +++ b/cpp/.clang-tidy @@ -16,4 +16,5 @@ HeaderFilterRegex: '.*' FormatStyle: file CheckOptions: AllowSoleDefaultDtor: true + modernize-use-trailing-return-type.TransformLambdas: all_except_auto ... diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index c9fb0932..c132d43f 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -26,6 +26,11 @@ endif () option(CUCUMBER_QUERY_BUILD_TESTS "Build the unit tests." Off) option(CUCUMBER_QUERY_FETCH_DEPS "Fetch dependencies via FetchContent." Off) +option(CUCUMBER_QUERY_ENABLE_CLANG_TIDY "Run clang-tidy as part of the build." Off) + +if(CUCUMBER_QUERY_ENABLE_CLANG_TIDY) + find_program(CLANG_TIDY_PROGRAM clang-tidy REQUIRED) +endif() set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -94,6 +99,10 @@ set_target_properties( OUTPUT_NAME cucumber_query ) +if(CUCUMBER_QUERY_ENABLE_CLANG_TIDY) + set_target_properties(cucumber_query_lib PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_PROGRAM}") +endif() + # Installation # Installation # Installation diff --git a/cpp/CMakePresets.json b/cpp/CMakePresets.json index 02dab8bb..f975b947 100644 --- a/cpp/CMakePresets.json +++ b/cpp/CMakePresets.json @@ -21,6 +21,13 @@ "cacheVariables": { "CUCUMBER_QUERY_BUILD_TESTS": "On" } + }, + { + "name": "tidy", + "inherits": "test", + "cacheVariables": { + "CUCUMBER_QUERY_ENABLE_CLANG_TIDY": "On" + } } ], "buildPresets": [ @@ -31,6 +38,10 @@ { "name": "test", "configurePreset": "test" + }, + { + "name": "tidy", + "configurePreset": "tidy" } ], "testPresets": [ @@ -75,6 +86,19 @@ "type": "test" } ] + }, + { + "name": "tidy", + "steps": [ + { + "name": "tidy", + "type": "configure" + }, + { + "name": "tidy", + "type": "build" + } + ] } ] } diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index b3351f00..cc67bedc 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -17,5 +17,9 @@ target_compile_definitions(cucumber_query_lib.test TESTDATA_SRC="${CMAKE_SOURCE_DIR}/../testdata/src" ) +if(CUCUMBER_QUERY_ENABLE_CLANG_TIDY) + set_target_properties(cucumber_query_lib.test PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_PROGRAM}") +endif() + include(GoogleTest) gtest_discover_tests(cucumber_query_lib.test) diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index ff8e36af..8725f572 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -74,7 +74,7 @@ namespace cucumber::query { const auto prefix = source.stem().string() + std::string{ expectation.infix }; const auto hasExpectations = std::any_of(expectations.begin(), expectations.end(), - [&prefix](const std::string& expectation) + [&prefix](const std::string& expectation) -> bool { return expectation.compare(0, prefix.size(), prefix) == 0; }); @@ -86,7 +86,7 @@ namespace cucumber::query } std::sort(dataSets.begin(), dataSets.end(), - [](const DataSet& lhs, const DataSet& rhs) + [](const DataSet& lhs, const DataSet& rhs) -> bool { return lhs.source < rhs.source; }); @@ -105,7 +105,7 @@ namespace cucumber::query std::replace_if( name.begin(), name.end(), - [](unsigned char character) + [](unsigned char character) -> bool { return std::isalnum(character) == 0; }, From 85b7d9c449f56a655078a7feffcf87ccad4d31cb Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 22:15:58 +0000 Subject: [PATCH 24/56] Removed variants from Query --- cpp/include/cucumber/query/Query.hpp | 47 ++-- cpp/src/query/Query.cpp | 368 +++++++++++++++------------ cpp/test/TestQuery.cpp | 34 ++- 3 files changed, 249 insertions(+), 200 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index d355dbdd..bb7271ed 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -20,7 +20,6 @@ #include #include #include -#include #include namespace cucumber::query @@ -70,22 +69,24 @@ namespace cucumber::query [[nodiscard]] auto FindAllUndefinedParameterTypes() const -> std::vector>; - [[nodiscard]] auto FindAttachmentsBy(std::variant, std::shared_ptr> element) const - -> std::vector>; + [[nodiscard]] auto FindAttachmentsBy(const std::shared_ptr& element) const -> std::vector>; + [[nodiscard]] auto FindAttachmentsBy(const std::shared_ptr& element) const -> std::vector>; - [[nodiscard]] auto FindHookBy( - std::variant, std::shared_ptr, std::shared_ptr> element) const - -> std::optional>; + [[nodiscard]] auto FindHookBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindHookBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindHookBy(const std::shared_ptr& element) const -> std::optional>; [[nodiscard]] auto FindMeta() const -> std::optional>; - [[nodiscard]] auto FindMostSevereTestStepResultBy(std::variant, std::shared_ptr> element) const - -> std::optional>; + [[nodiscard]] auto FindMostSevereTestStepResultBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindMostSevereTestStepResultBy(const std::shared_ptr& element) const -> std::optional>; [[nodiscard]] auto FindLocationOf(const std::shared_ptr& pickle) const -> std::optional>; - [[nodiscard]] auto FindPickleBy(std::variant, std::shared_ptr, - std::shared_ptr, std::shared_ptr> element) const -> std::optional>; + [[nodiscard]] auto FindPickleBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindPickleBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindPickleBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindPickleBy(const std::shared_ptr& element) const -> std::optional>; [[nodiscard]] auto FindPickleStepBy(const std::shared_ptr& testStep) const -> std::optional>; @@ -98,16 +99,18 @@ namespace cucumber::query [[nodiscard]] auto FindUnambiguousStepDefinitionBy(const std::shared_ptr& testStep) const -> std::optional>; - [[nodiscard]] auto FindTestCaseBy(std::variant, std::shared_ptr, - std::shared_ptr, std::shared_ptr> element) const -> std::optional>; + [[nodiscard]] auto FindTestCaseBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindTestCaseBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindTestCaseBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindTestCaseBy(const std::shared_ptr& element) const -> std::optional>; [[nodiscard]] auto FindTestCaseDurationBy(const std::shared_ptr& element) const -> std::optional>; [[nodiscard]] auto FindTestCaseDurationBy(const std::shared_ptr& element) const -> std::optional>; - [[nodiscard]] auto FindTestCaseStartedBy( - std::variant, std::shared_ptr, std::shared_ptr> element) const - -> std::optional>; + [[nodiscard]] auto FindTestCaseStartedBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindTestCaseStartedBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindTestCaseStartedBy(const std::shared_ptr& element) const -> std::optional>; [[nodiscard]] auto FindTestCaseFinishedBy(const std::shared_ptr& testCaseStarted) const -> std::optional>; @@ -123,21 +126,21 @@ namespace cucumber::query [[nodiscard]] auto FindTestRunStarted() const -> std::optional>; - [[nodiscard]] auto FindTestStepBy(std::variant, std::shared_ptr> element) const - -> std::optional>; + [[nodiscard]] auto FindTestStepBy(const std::shared_ptr& element) const -> std::optional>; + [[nodiscard]] auto FindTestStepBy(const std::shared_ptr& element) const -> std::optional>; [[nodiscard]] auto FindTestStepsStartedBy(const std::shared_ptr& testCaseStarted) const -> std::vector>; [[nodiscard]] auto FindTestStepsStartedBy(const std::shared_ptr& testCaseFinished) const -> std::vector>; - [[nodiscard]] auto FindTestStepsFinishedBy(std::variant, std::shared_ptr> element) const - -> std::vector>; + [[nodiscard]] auto FindTestStepsFinishedBy(const std::shared_ptr& element) const -> std::vector>; + [[nodiscard]] auto FindTestStepsFinishedBy(const std::shared_ptr& element) const -> std::vector>; [[nodiscard]] auto FindTestStepFinishedAndTestStepBy(const std::shared_ptr& testCaseStarted) const -> std::vector, std::shared_ptr>>; - [[nodiscard]] auto FindLineageBy( - std::variant, std::shared_ptr, std::shared_ptr> element) const - -> std::optional; + [[nodiscard]] auto FindLineageBy(const std::shared_ptr& element) const -> std::optional; + [[nodiscard]] auto FindLineageBy(const std::shared_ptr& element) const -> std::optional; + [[nodiscard]] auto FindLineageBy(const std::shared_ptr& element) const -> std::optional; private: auto UpdateGherkinDocument(const std::shared_ptr& gherkinDocument) -> void; diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index fbf3d072..f45759d0 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include namespace cucumber::query @@ -287,71 +286,57 @@ namespace cucumber::query return undefinedParameterTypes; } - auto Query::FindAttachmentsBy(std::variant, std::shared_ptr> element) const - -> std::vector> + auto Query::FindAttachmentsBy(const std::shared_ptr& element) const -> std::vector> { - return std::visit( - overloaded{ - [this](const std::shared_ptr& element) - { - std::vector> result; - if (attachmentsByTestCaseStartedId.find(element->testCaseStartedId) != attachmentsByTestCaseStartedId.end()) - { - for (const auto& attachment : attachmentsByTestCaseStartedId.at(element->testCaseStartedId)) - { - if (attachment->testStepId == element->testStepId) - { - result.push_back(attachment); - } - } - } - return result; - }, - [this](const std::shared_ptr& element) - { - if (attachmentsByTestRunHookStartedId.find(element->testRunHookStartedId) != attachmentsByTestRunHookStartedId.end()) - { - return attachmentsByTestRunHookStartedId.at(element->testRunHookStartedId); - } - return std::vector>{}; - }, - }, - element); - } - - auto Query::FindHookBy( - std::variant, std::shared_ptr, std::shared_ptr> element) const - -> std::optional> - { - return std::visit( - overloaded{ - [this](const std::shared_ptr& element) -> std::optional> - { - if (element->hookId.has_value()) - { - return hookById.at(element->hookId.value()); - } - return std::nullopt; - }, - [this](const std::shared_ptr& element) -> std::optional> - { - if (hookById.find(element->hookId) != hookById.end()) - { - return hookById.at(element->hookId); - } - return std::nullopt; - }, - [this](const std::shared_ptr& element) -> std::optional> + std::vector> result; + if (attachmentsByTestCaseStartedId.find(element->testCaseStartedId) != attachmentsByTestCaseStartedId.end()) + { + for (const auto& attachment : attachmentsByTestCaseStartedId.at(element->testCaseStartedId)) + { + if (attachment->testStepId == element->testStepId) { - const auto testRunHookStarted = FindTestRunHookStartedBy(element); - if (!testRunHookStarted.has_value()) - { - throw std::out_of_range{ "Expected to find TestRunHookStarted from TestRunHookFinished" }; - } - return FindHookBy(testRunHookStarted.value()); - }, - }, - element); + result.push_back(attachment); + } + } + } + return result; + } + + auto Query::FindAttachmentsBy(const std::shared_ptr& element) const -> std::vector> + { + if (attachmentsByTestRunHookStartedId.find(element->testRunHookStartedId) != attachmentsByTestRunHookStartedId.end()) + { + return attachmentsByTestRunHookStartedId.at(element->testRunHookStartedId); + } + return {}; + } + + auto Query::FindHookBy(const std::shared_ptr& element) const -> std::optional> + { + if (element->hookId.has_value()) + { + return hookById.at(element->hookId.value()); + } + return std::nullopt; + } + + auto Query::FindHookBy(const std::shared_ptr& element) const -> std::optional> + { + if (hookById.find(element->hookId) != hookById.end()) + { + return hookById.at(element->hookId); + } + return std::nullopt; + } + + auto Query::FindHookBy(const std::shared_ptr& element) const -> std::optional> + { + const auto testRunHookStarted = FindTestRunHookStartedBy(element); + if (!testRunHookStarted.has_value()) + { + throw std::out_of_range{ "Expected to find TestRunHookStarted from TestRunHookFinished" }; + } + return FindHookBy(testRunHookStarted.value()); } auto Query::FindMeta() const -> std::optional> @@ -359,30 +344,25 @@ namespace cucumber::query return meta; } - auto Query::FindMostSevereTestStepResultBy(std::variant, std::shared_ptr> element) const - -> std::optional> + auto Query::FindMostSevereTestStepResultBy(const std::shared_ptr& element) const -> std::optional> { - const auto testCaseStarted = std::visit(overloaded{ [this](const std::shared_ptr& element) - { - return FindTestCaseStartedBy(element); - }, - [](const auto& element) -> std::optional> - { - return element; - } }, - element); - - if (testCaseStarted.has_value()) + auto testStepFinishedAndTestStep = FindTestStepFinishedAndTestStepBy(element); + if (!testStepFinishedAndTestStep.empty()) { - auto testStepFinishedAndTestStep = FindTestStepFinishedAndTestStepBy(testCaseStarted.value()); - if (!testStepFinishedAndTestStep.empty()) - { - SortBySeverity(testStepFinishedAndTestStep); + SortBySeverity(testStepFinishedAndTestStep); - return testStepFinishedAndTestStep.front().first->testStepResult; - } + return testStepFinishedAndTestStep.front().first->testStepResult; } + return std::nullopt; + } + auto Query::FindMostSevereTestStepResultBy(const std::shared_ptr& element) const -> std::optional> + { + const auto testCaseStarted = FindTestCaseStartedBy(element); + if (testCaseStarted.has_value()) + { + return FindMostSevereTestStepResultBy(testCaseStarted.value()); + } return std::nullopt; } @@ -413,25 +393,44 @@ namespace cucumber::query return std::nullopt; } - auto Query::FindPickleBy(std::variant, std::shared_ptr, std::shared_ptr, - std::shared_ptr> - element) const -> std::optional> + auto Query::FindPickleBy(const std::shared_ptr& element) const -> std::optional> { - const auto testCase = std::visit( - [this](const auto& element) - { - return FindTestCaseBy(element); - }, - element); + const auto& testCase = FindTestCaseBy(element); + if (testCase.has_value()) + { + return pickleById.at(testCase.value()->pickleId); + } + return std::nullopt; + } - try + auto Query::FindPickleBy(const std::shared_ptr& element) const -> std::optional> + { + const auto& testCase = FindTestCaseBy(element); + if (testCase.has_value()) { return pickleById.at(testCase.value()->pickleId); } - catch (const std::out_of_range&) + return std::nullopt; + } + + auto Query::FindPickleBy(const std::shared_ptr& element) const -> std::optional> + { + const auto& testCase = FindTestCaseBy(element); + if (testCase.has_value()) { - return std::nullopt; + return pickleById.at(testCase.value()->pickleId); } + return std::nullopt; + } + + auto Query::FindPickleBy(const std::shared_ptr& element) const -> std::optional> + { + const auto& testCase = FindTestCaseBy(element); + if (testCase.has_value()) + { + return pickleById.at(testCase.value()->pickleId); + } + return std::nullopt; } auto Query::FindPickleStepBy(const std::shared_ptr& testStep) const -> std::optional> @@ -506,28 +505,43 @@ namespace cucumber::query return std::nullopt; } - auto Query::FindTestCaseBy(std::variant, std::shared_ptr, std::shared_ptr, - std::shared_ptr> - element) const -> std::optional> + auto Query::FindTestCaseBy(const std::shared_ptr& element) const -> std::optional> { - const auto testCaseStarted = std::visit( - overloaded{ - [](std::shared_ptr element) -> std::optional> - { - return element; - }, - [this](auto element) -> std::optional> - { - return FindTestCaseStartedBy(element); - }, - }, - element); + if (testCaseById.find(element->testCaseId) != testCaseById.end()) + { + return testCaseById.at(element->testCaseId); + } - if (testCaseById.find(testCaseStarted.value()->testCaseId) != testCaseById.end()) + return std::nullopt; + } + + auto Query::FindTestCaseBy(const std::shared_ptr& element) const -> std::optional> + { + const auto& testCaseStarted = FindTestCaseStartedBy(element); + if (testCaseStarted.has_value()) + { + return FindTestCaseBy(testCaseStarted.value()); + } + return std::nullopt; + } + + auto Query::FindTestCaseBy(const std::shared_ptr& element) const -> std::optional> + { + const auto& testCaseStarted = FindTestCaseStartedBy(element); + if (testCaseStarted.has_value()) { - return testCaseById.at(testCaseStarted.value()->testCaseId); + return FindTestCaseBy(testCaseStarted.value()); } + return std::nullopt; + } + auto Query::FindTestCaseBy(const std::shared_ptr& element) const -> std::optional> + { + const auto& testCaseStarted = FindTestCaseStartedBy(element); + if (testCaseStarted.has_value()) + { + return FindTestCaseBy(testCaseStarted.value()); + } return std::nullopt; } @@ -553,21 +567,34 @@ namespace cucumber::query return std::nullopt; } - auto Query::FindTestCaseStartedBy( - std::variant, std::shared_ptr, std::shared_ptr> element) const - -> std::optional> + auto Query::FindTestCaseStartedBy(const std::shared_ptr& element) const -> std::optional> { - return std::visit( - [this](const auto& item) -> std::optional> - { - const auto iter = testCaseStartedById.find(item->testCaseStartedId); - if (iter != testCaseStartedById.end()) - { - return iter->second; - } - return std::nullopt; - }, - element); + const auto iter = testCaseStartedById.find(element->testCaseStartedId); + if (iter != testCaseStartedById.end()) + { + return iter->second; + } + return std::nullopt; + } + + auto Query::FindTestCaseStartedBy(const std::shared_ptr& element) const -> std::optional> + { + const auto iter = testCaseStartedById.find(element->testCaseStartedId); + if (iter != testCaseStartedById.end()) + { + return iter->second; + } + return std::nullopt; + } + + auto Query::FindTestCaseStartedBy(const std::shared_ptr& element) const -> std::optional> + { + const auto iter = testCaseStartedById.find(element->testCaseStartedId); + if (iter != testCaseStartedById.end()) + { + return iter->second; + } + return std::nullopt; } auto Query::FindTestCaseFinishedBy(const std::shared_ptr& testCaseStarted) const -> std::optional> @@ -618,22 +645,22 @@ namespace cucumber::query return testRunStarted; } - auto Query::FindTestStepBy(std::variant, std::shared_ptr> element) const - -> std::optional> + auto Query::FindTestStepBy(const std::shared_ptr& element) const -> std::optional> { - try + if (testStepById.find(element->testStepId) != testStepById.end()) { - return std::visit( - [this](const auto& item) - { - return testStepById.at(item->testStepId); - }, - element); + return testStepById.at(element->testStepId); } - catch (const std::out_of_range&) + return std::nullopt; + } + + auto Query::FindTestStepBy(const std::shared_ptr& element) const -> std::optional> + { + if (testStepById.find(element->testStepId) != testStepById.end()) { - return std::nullopt; + return testStepById.at(element->testStepId); } + return std::nullopt; } auto Query::FindTestStepsStartedBy(const std::shared_ptr& testCaseStarted) const -> std::vector> @@ -654,22 +681,23 @@ namespace cucumber::query return {}; } - auto Query::FindTestStepsFinishedBy(std::variant, std::shared_ptr> element) const - -> std::vector> + auto Query::FindTestStepsFinishedBy(const std::shared_ptr& element) const -> std::vector> { - const auto& optionalTestCaseStarted = std::visit(overloaded{ [this](const std::shared_ptr& element) - { - return FindTestCaseStartedBy(element); - }, - [](const auto& element) -> std::optional> - { - return element; - } }, - element); + if (testStepFinishedByTestCaseStartedId.find(element->id) != testStepFinishedByTestCaseStartedId.end()) + { + return testStepFinishedByTestCaseStartedId.at(element->id); + } + + return {}; + } - if (optionalTestCaseStarted.has_value() && testStepFinishedByTestCaseStartedId.find(optionalTestCaseStarted.value()->id) != testStepFinishedByTestCaseStartedId.end()) + auto Query::FindTestStepsFinishedBy(const std::shared_ptr& element) const -> std::vector> + { + const auto& testCaseStarted = FindTestCaseStartedBy(element); + + if (testCaseStarted.has_value()) { - return testStepFinishedByTestCaseStartedId.at(optionalTestCaseStarted.value()->id); + return FindTestStepsFinishedBy(testCaseStarted.value()); } return {}; @@ -696,25 +724,35 @@ namespace cucumber::query return result; } - auto Query::FindLineageBy(std::variant, std::shared_ptr, std::shared_ptr> element) const - -> std::optional + auto Query::FindLineageBy(const std::shared_ptr& element) const -> std::optional { - const auto pickle = std::visit( - overloaded{ - [](const std::shared_ptr& pickle) - { - return std::make_optional(pickle); - }, - [this](const auto& element) - { - return FindPickleBy(element); - }, - }, - element); + if (lineageById.find(element->astNodeIds.back()) != lineageById.end()) + { + return LineageAndPickle{ lineageById.at(element->astNodeIds.back()), element }; + } + + return std::nullopt; + } + + auto Query::FindLineageBy(const std::shared_ptr& element) const -> std::optional + { + const auto& pickle = FindPickleBy(element); + + if (pickle.has_value()) + { + return FindLineageBy(pickle.value()); + } + + return std::nullopt; + } + + auto Query::FindLineageBy(const std::shared_ptr& element) const -> std::optional + { + const auto& pickle = FindPickleBy(element); if (pickle.has_value()) { - return LineageAndPickle{ lineageById.at(pickle.value()->astNodeIds.back()), pickle.value() }; + return FindLineageBy(pickle.value()); } return std::nullopt; diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index 8725f572..5c0272ef 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include namespace cucumber::query @@ -137,19 +136,16 @@ namespace cucumber::query { return static_cast(lhs->uri.compare(rhs->uri)); } - if (lhs->location.has_value() && rhs->location.has_value() && lhs->location.value()->line != rhs->location.value()->line) + if (!lhs->location.has_value() || !rhs->location.has_value()) + { + return 0; + } + if (lhs->location.value()->line != rhs->location.value()->line) { return static_cast(rhs->location.value()->line) - static_cast(lhs->location.value()->line); } - return static_cast(rhs->location.value()->column.value()) - static_cast(lhs->location.value()->column.value()); - }; - - auto FindPickleBy(const query::Query& query, std::variant, std::shared_ptr, - std::shared_ptr, std::shared_ptr> - element) -> std::optional> - { - return query.FindPickleBy(std::move(element)); - }; + return static_cast(rhs->location.value()->column.value_or(0)) - static_cast(lhs->location.value()->column.value_or(0)); + } struct QueryAcceptanceTest : testing::TestWithParam { @@ -251,7 +247,13 @@ namespace cucumber::query TEST_P(QueryAcceptanceTest, findAllTestCaseFinishedOrderBy) { - const auto allResults = query.FindAllTestCaseFinishedOrderBy(&FindPickleBy, ReversePickleComparator); + const auto allResults = query.FindAllTestCaseFinishedOrderBy( + [](const query::Query& query, const auto& element) + { + return query.FindPickleBy(element); + }, + ReversePickleComparator); + nlohmann::json actual; for (const auto& testCaseFinished : allResults) { @@ -263,7 +265,13 @@ namespace cucumber::query TEST_P(QueryAcceptanceTest, findAllTestCaseStartedOrderBy) { - const auto allResults = query.FindAllTestCaseStartedOrderBy(&FindPickleBy, ReversePickleComparator); + const auto allResults = query.FindAllTestCaseStartedOrderBy( + [](const query::Query& query, const auto& element) + { + return query.FindPickleBy(element); + }, + ReversePickleComparator); + nlohmann::json actual; for (const auto& testCaseStarted : allResults) { From e0efad9c153cbefd1e9d8482a34139133d7343f2 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 23:41:22 +0000 Subject: [PATCH 25/56] add gcovr feature to devcontainer configuration --- .devcontainer/cpp/devcontainer-lock.json | 5 +++++ .devcontainer/cpp/devcontainer.json | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.devcontainer/cpp/devcontainer-lock.json b/.devcontainer/cpp/devcontainer-lock.json index e1adc04b..456806ad 100644 --- a/.devcontainer/cpp/devcontainer-lock.json +++ b/.devcontainer/cpp/devcontainer-lock.json @@ -72,6 +72,11 @@ "version": "1.0.2", "resolved": "ghcr.io/devcontainer-community/devcontainer-features/vcpkg.io@sha256:aa1c839509ab397336da9c187c89b16e5cb85666f1c8756a2919f401ed3b44ae", "integrity": "sha256:aa1c839509ab397336da9c187c89b16e5cb85666f1c8756a2919f401ed3b44ae" + }, + "ghcr.io/devcontainers-extra/features/gcovr:1": { + "version": "1.0.0", + "resolved": "ghcr.io/devcontainers-extra/features/gcovr@sha256:2aa70bfc2b1d5a62333ec52a58f3c087135b82f8ada3d420f9ba52d8620123f3", + "integrity": "sha256:2aa70bfc2b1d5a62333ec52a58f3c087135b82f8ada3d420f9ba52d8620123f3" } } } diff --git a/.devcontainer/cpp/devcontainer.json b/.devcontainer/cpp/devcontainer.json index faae09be..aa377644 100644 --- a/.devcontainer/cpp/devcontainer.json +++ b/.devcontainer/cpp/devcontainer.json @@ -4,7 +4,8 @@ "name": "cpp", "image": "mcr.microsoft.com/devcontainers/base:resolute", "features": { - "ghcr.io/devcontainer-community/devcontainer-features/collection-c-cpp:1": {} + "ghcr.io/devcontainer-community/devcontainer-features/collection-c-cpp:1": {}, + "ghcr.io/devcontainers-extra/features/gcovr:1": {} }, "customizations": { "vscode": { From 2b3ca35c29a61dd0c0fc2a733d16b689f7fdd704 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 23:42:01 +0000 Subject: [PATCH 26/56] add coverage vscode settings to devcontainer --- .devcontainer/cpp/devcontainer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.devcontainer/cpp/devcontainer.json b/.devcontainer/cpp/devcontainer.json index aa377644..8818164b 100644 --- a/.devcontainer/cpp/devcontainer.json +++ b/.devcontainer/cpp/devcontainer.json @@ -15,7 +15,11 @@ ], "cmake.copyCompileCommands": "${userHome}/.cpp/compile_commands.json", "cmake.sourceDirectory": "${workspaceFolder}/cpp", - "cmake.useCMakePresets": "auto" + "cmake.useCMakePresets": "auto", + "cmake.postRunCoverageTarget": "generate-coverage-report", + "cmake.coverageInfoFiles": [ + "${workspaceFolder}/cpp/build/coverage/lcov.info" + ] }, "extensions": [ "llvm-vs-code-extensions.vscode-clangd", From 22f0564cdf5d1d44da625cb176893e360fe36146 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 23:42:17 +0000 Subject: [PATCH 27/56] replace throws will nullopt returnsd --- cpp/src/query/Query.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index f45759d0..979f5477 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -332,11 +332,11 @@ namespace cucumber::query auto Query::FindHookBy(const std::shared_ptr& element) const -> std::optional> { const auto testRunHookStarted = FindTestRunHookStartedBy(element); - if (!testRunHookStarted.has_value()) + if (testRunHookStarted.has_value()) { - throw std::out_of_range{ "Expected to find TestRunHookStarted from TestRunHookFinished" }; + return FindHookBy(testRunHookStarted.value()); } - return FindHookBy(testRunHookStarted.value()); + return std::nullopt; } auto Query::FindMeta() const -> std::optional> @@ -714,11 +714,10 @@ namespace cucumber::query for (const auto& testStepFinished : testStepsFinishedIter->second) { const auto& testStep = FindTestStepBy(testStepFinished); - if (!testStep) + if (testStep.has_value()) { - throw std::out_of_range{ "Expected to find TestStep by TestStepFinished" }; + result.emplace_back(testStepFinished, *testStep); } - result.emplace_back(testStepFinished, *testStep); } } return result; From ccadca2bde24a8cf7618d21829d53b5780c27257 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 23:47:29 +0000 Subject: [PATCH 28/56] fix clang-tidy warnings --- cpp/src/query/NamingStrategy.cpp | 2 +- cpp/src/query/Query.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cpp/src/query/NamingStrategy.cpp b/cpp/src/query/NamingStrategy.cpp index 242ac55a..dcf7073e 100644 --- a/cpp/src/query/NamingStrategy.cpp +++ b/cpp/src/query/NamingStrategy.cpp @@ -76,7 +76,7 @@ namespace cucumber::query } return std::accumulate(parts.begin(), parts.end(), std::string{}, - [](const std::string& cumulative, const std::string& element) + [](const std::string& cumulative, const std::string& element) -> std::string { if (element.empty()) { diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index 979f5477..ed706127 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include From 2a223c776e03069943ece410c6356b0cea695e44 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 7 Aug 2026 23:47:43 +0000 Subject: [PATCH 29/56] add coverage preset/target --- cpp/CMakeLists.txt | 40 ++++++++++++++++++++++++++++++----- cpp/CMakePresets.json | 47 ++++++++++++++++++++++++++++++++++++++++- cpp/test/CMakeLists.txt | 4 ---- 3 files changed, 81 insertions(+), 10 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index c132d43f..f2fb3bf8 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -27,11 +27,27 @@ endif () option(CUCUMBER_QUERY_BUILD_TESTS "Build the unit tests." Off) option(CUCUMBER_QUERY_FETCH_DEPS "Fetch dependencies via FetchContent." Off) option(CUCUMBER_QUERY_ENABLE_CLANG_TIDY "Run clang-tidy as part of the build." Off) +option(CUCUMBER_QUERY_ENABLE_COVERAGE "Enable compiler flags for code coverage measurements." Off) if(CUCUMBER_QUERY_ENABLE_CLANG_TIDY) find_program(CLANG_TIDY_PROGRAM clang-tidy REQUIRED) endif() +if(CUCUMBER_QUERY_ENABLE_COVERAGE) + find_program(GCOVR_PROGRAM gcovr REQUIRED) + + add_custom_target( + generate-lcov-report + COMMAND ${GCOVR_PROGRAM} --root ${CMAKE_CURRENT_SOURCE_DIR} --merge-lines --delete --exclude-unreachable-branches --exclude-throw-branches --exclude-noncode-lines --filter include/ --filter src/ + --txt-summary + --lcov ${CMAKE_CURRENT_BINARY_DIR}/lcov.info + --cobertura ${CMAKE_CURRENT_BINARY_DIR}/cobertura.xml --cobertura-pretty + --markdown-summary ${CMAKE_CURRENT_BINARY_DIR}/coverage-summary.md + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Generating code coverage reports" + ) +endif() + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) @@ -59,7 +75,25 @@ endif() # CMake dependencies include(cmake/dependencies.cpm.cmake) -# Target +# Target options +if(CUCUMBER_QUERY_ENABLE_CLANG_TIDY) + set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PROGRAM}") +endif() + +if(CUCUMBER_QUERY_ENABLE_COVERAGE) + add_compile_options( + -g -O0 --coverage -fprofile-arcs -ftest-coverage -fno-inline + $<$:-fno-elide-constructors> + ) + + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + link_libraries(gcov) + else() + add_link_options(--coverage) + endif() +endif() + +# Targets add_library(cucumber_query_lib) add_library(cucumber::query ALIAS cucumber_query_lib) @@ -99,10 +133,6 @@ set_target_properties( OUTPUT_NAME cucumber_query ) -if(CUCUMBER_QUERY_ENABLE_CLANG_TIDY) - set_target_properties(cucumber_query_lib PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_PROGRAM}") -endif() - # Installation # Installation # Installation diff --git a/cpp/CMakePresets.json b/cpp/CMakePresets.json index f975b947..91eedc6f 100644 --- a/cpp/CMakePresets.json +++ b/cpp/CMakePresets.json @@ -28,6 +28,13 @@ "cacheVariables": { "CUCUMBER_QUERY_ENABLE_CLANG_TIDY": "On" } + }, + { + "name": "coverage", + "inherits": "test", + "cacheVariables": { + "CUCUMBER_QUERY_ENABLE_COVERAGE": "On" + } } ], "buildPresets": [ @@ -42,6 +49,17 @@ { "name": "tidy", "configurePreset": "tidy" + }, + { + "name": "coverage", + "configurePreset": "coverage" + }, + { + "name": "coverage-report", + "configurePreset": "coverage", + "targets": [ + "generate-lcov-report" + ] } ], "testPresets": [ @@ -52,8 +70,14 @@ "outputOnFailure": true }, "execution": { - "noTestsAction": "error" + "noTestsAction": "error", + "jobs": 8 } + }, + { + "name": "coverage", + "configurePreset": "coverage", + "inherits": "test" } ], "workflowPresets": [ @@ -99,6 +123,27 @@ "type": "build" } ] + }, + { + "name": "coverage", + "steps": [ + { + "name": "coverage", + "type": "configure" + }, + { + "name": "coverage", + "type": "build" + }, + { + "name": "coverage", + "type": "test" + }, + { + "name": "coverage-report", + "type": "build" + } + ] } ] } diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index cc67bedc..b3351f00 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -17,9 +17,5 @@ target_compile_definitions(cucumber_query_lib.test TESTDATA_SRC="${CMAKE_SOURCE_DIR}/../testdata/src" ) -if(CUCUMBER_QUERY_ENABLE_CLANG_TIDY) - set_target_properties(cucumber_query_lib.test PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_PROGRAM}") -endif() - include(GoogleTest) gtest_discover_tests(cucumber_query_lib.test) From eed51e5426b305298ed6a5da02d6fb86d4f0c76d Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 00:06:26 +0000 Subject: [PATCH 30/56] add sanitizers --- cpp/CMakeLists.txt | 12 ++++++++++++ cpp/CMakePresets.json | 14 +++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index f2fb3bf8..5bec8cef 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -28,6 +28,11 @@ option(CUCUMBER_QUERY_BUILD_TESTS "Build the unit tests." Off) option(CUCUMBER_QUERY_FETCH_DEPS "Fetch dependencies via FetchContent." Off) option(CUCUMBER_QUERY_ENABLE_CLANG_TIDY "Run clang-tidy as part of the build." Off) option(CUCUMBER_QUERY_ENABLE_COVERAGE "Enable compiler flags for code coverage measurements." Off) +option(CUCUMBER_QUERY_ENABLE_SANITIZERS "Enable compiler flags for the address and undefined behaviour sanitizers." Off) + +if(CUCUMBER_QUERY_ENABLE_SANITIZERS AND CUCUMBER_QUERY_ENABLE_COVERAGE) + message(FATAL_ERROR "CUCUMBER_QUERY_ENABLE_SANITIZERS and CUCUMBER_QUERY_ENABLE_COVERAGE are mutually exclusive.") +endif() if(CUCUMBER_QUERY_ENABLE_CLANG_TIDY) find_program(CLANG_TIDY_PROGRAM clang-tidy REQUIRED) @@ -93,6 +98,13 @@ if(CUCUMBER_QUERY_ENABLE_COVERAGE) endif() endif() +if(CUCUMBER_QUERY_ENABLE_SANITIZERS) + if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")) + add_compile_options(-fsanitize=address -fsanitize=undefined) + add_link_options(-fsanitize=address -fsanitize=undefined) + endif() +endif() + # Targets add_library(cucumber_query_lib) add_library(cucumber::query ALIAS cucumber_query_lib) diff --git a/cpp/CMakePresets.json b/cpp/CMakePresets.json index 91eedc6f..93c91890 100644 --- a/cpp/CMakePresets.json +++ b/cpp/CMakePresets.json @@ -16,22 +16,30 @@ } }, { - "name": "test", + "name": "test-base", "inherits": "host", + "hidden": true, "cacheVariables": { "CUCUMBER_QUERY_BUILD_TESTS": "On" } }, + { + "name": "test", + "inherits": "test-base", + "cacheVariables": { + "CUCUMBER_QUERY_ENABLE_SANITIZERS": "On" + } + }, { "name": "tidy", - "inherits": "test", + "inherits": "test-base", "cacheVariables": { "CUCUMBER_QUERY_ENABLE_CLANG_TIDY": "On" } }, { "name": "coverage", - "inherits": "test", + "inherits": "test-base", "cacheVariables": { "CUCUMBER_QUERY_ENABLE_COVERAGE": "On" } From 56c79abfad06e2b3f6a7e177ef5e9a4e5e6a9b66 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 21:16:31 +0000 Subject: [PATCH 31/56] update version file --- cpp/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/VERSION b/cpp/VERSION index 3eefcb9d..1afe54c7 100644 --- a/cpp/VERSION +++ b/cpp/VERSION @@ -1 +1 @@ -1.0.0 +16.1.1 From e24298dbb3264a0a7b2f849397e0ef9c511faea7 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 21:16:37 +0000 Subject: [PATCH 32/56] add CI --- .github/workflows/codeql-cpp.yaml | 74 +++++++++++++++ .github/workflows/test-cpp.yaml | 152 ++++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+) create mode 100644 .github/workflows/codeql-cpp.yaml create mode 100644 .github/workflows/test-cpp.yaml diff --git a/.github/workflows/codeql-cpp.yaml b/.github/workflows/codeql-cpp.yaml new file mode 100644 index 00000000..24039cbb --- /dev/null +++ b/.github/workflows/codeql-cpp.yaml @@ -0,0 +1,74 @@ +name: codeql-cpp + +permissions: {} + +on: + push: + branches: + - main + paths: + - cpp/** + - testdata/** + - .github/** + pull_request: + branches: + - main + paths: + - cpp/** + - testdata/** + - .github/** + schedule: + - cron: '48 5 * * 0' + +concurrency: + # Cancels in-progress runs only for pull requests + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + analyze: + env: + CCACHE_BASEDIR: ${{ github.workspace }} + CCACHE_DIR: ${{ github.workspace }}/.ccache + CPM_SOURCE_CACHE: ${{ github.workspace }}/.cpm + + name: Analyze C++ + runs-on: ubuntu-latest + permissions: + security-events: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install build tools + run: | + sudo apt-get update + sudo apt-get install -y ccache + + - name: Cache CPM packages + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ env.CPM_SOURCE_CACHE }} + key: cpm-${{ hashFiles('cpp/cmake/dependencies.cpm.cmake') }} + + - name: Cache ccache + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ env.CCACHE_DIR }} + key: ccache-${{ github.job }}-${{ github.ref }} + restore-keys: ccache-${{ github.job }}- + + - uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6 + with: + languages: c-cpp + build-mode: manual + tools: linked + + - name: Configure + working-directory: cpp + run: cmake --workflow host + + - uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6 + with: + category: "/language:cpp" diff --git a/.github/workflows/test-cpp.yaml b/.github/workflows/test-cpp.yaml new file mode 100644 index 00000000..10fcdcfa --- /dev/null +++ b/.github/workflows/test-cpp.yaml @@ -0,0 +1,152 @@ +name: test-cpp + +permissions: {} + +on: + push: + branches: + - main + - renovate/** + paths: + - cpp/** + - testdata/** + - .github/** + pull_request: + branches: + - main + paths: + - cpp/** + - testdata/** + - .github/** + +env: + CCACHE_BASEDIR: ${{ github.workspace }} + CCACHE_DIR: ${{ github.workspace }}/.ccache + CPM_SOURCE_CACHE: ${{ github.workspace }}/.cpm + +jobs: + test-cpp: + strategy: + fail-fast: false + matrix: + config: + - { os: ubuntu-24.04, cxx: g++, version: 12 } + - { os: ubuntu-24.04, cxx: g++, version: 13 } + - { os: ubuntu-24.04, cxx: clang++, version: 16 } + - { os: ubuntu-24.04, cxx: clang++, version: 17 } + - { os: ubuntu-26.04, cxx: g++, version: 14 } + - { os: ubuntu-26.04, cxx: g++, version: 15 } + - { os: ubuntu-26.04, cxx: clang++, version: 21 } + - { os: ubuntu-26.04, cxx: clang++, version: 22 } + - { os: macos-latest, cxx: clang++, version: 17 } + - { os: windows-latest, cxx: cl } + + runs-on: ${{ matrix.config.os }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + if: startsWith(matrix.config.os, 'windows') + + - name: Install build tools (ubuntu) + if: startsWith(matrix.config.os, 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install -y ccache + + - name: Install build tools (macos) + if: startsWith(matrix.config.os, 'macos') + run: brew install ccache llvm@${{ matrix.config.version }} + + - name: Cache CPM packages + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ env.CPM_SOURCE_CACHE }} + key: cpm-${{ hashFiles('cpp/cmake/dependencies.cpm.cmake') }} + + - name: Cache ccache + if: "!startsWith(matrix.config.os, 'windows')" + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ env.CCACHE_DIR }} + key: ccache-${{ github.job }}-${{ matrix.config.os }}-${{ matrix.config.cxx }}-${{ matrix.config.version }}-${{ github.ref }} + restore-keys: ccache-${{ github.job }}-${{ matrix.config.os }}-${{ matrix.config.cxx }}-${{ matrix.config.version }}- + + - name: Set CXX (ubuntu) + if: startsWith(matrix.config.os, 'ubuntu') + run: echo "CXX=${{ matrix.config.cxx }}-${{ matrix.config.version }}" >> $GITHUB_ENV + + - name: Set CXX (macos) + if: startsWith(matrix.config.os, 'macos') + run: echo "CXX=$(brew --prefix llvm@${{ matrix.config.version }})/bin/clang++" >> $GITHUB_ENV + + - name: Test + working-directory: cpp + run: cmake --workflow test + + test-cpp-coverage: + runs-on: ubuntu-26.04 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install build tools + run: | + sudo apt-get update + sudo apt-get install -y ccache gcovr + gcovr --version + + - name: Cache CPM packages + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ env.CPM_SOURCE_CACHE }} + key: cpm-${{ hashFiles('cpp/cmake/dependencies.cpm.cmake') }} + + - name: Cache ccache + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ env.CCACHE_DIR }} + key: ccache-${{ github.job }}-${{ github.ref }} + restore-keys: ccache-${{ github.job }}- + + - name: Coverage + working-directory: cpp + run: cmake --workflow coverage + + - name: Show coverage summary + working-directory: cpp + run: cat build/coverage/coverage-summary.md + + test-cpp-lint: + runs-on: ubuntu-26.04 + env: + CXX: clang++ + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install build tools + run: | + sudo apt-get update + sudo apt-get install -y ccache clang clang-tidy + + - name: Cache CPM packages + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ env.CPM_SOURCE_CACHE }} + key: cpm-${{ hashFiles('cpp/cmake/dependencies.cpm.cmake') }} + + - name: Cache ccache + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ env.CCACHE_DIR }} + key: ccache-${{ github.job }}-${{ github.ref }} + restore-keys: ccache-${{ github.job }}- + + - name: Lint + working-directory: cpp + run: cmake --workflow tidy From 3ccc02d8da33d00fc120c266c3b3dd7cf5478a68 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 22:16:43 +0000 Subject: [PATCH 33/56] add Python setup and gcovr installation to CI workflow --- .github/workflows/test-cpp.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-cpp.yaml b/.github/workflows/test-cpp.yaml index 10fcdcfa..d5ec13a3 100644 --- a/.github/workflows/test-cpp.yaml +++ b/.github/workflows/test-cpp.yaml @@ -93,10 +93,16 @@ jobs: with: persist-credentials: false + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 + with: + python-version: '3.12' + cache: 'pip' + - name: Install build tools run: | sudo apt-get update - sudo apt-get install -y ccache gcovr + sudo apt-get install -y ccache + python -m pip install gcovr==8.2 gcovr --version - name: Cache CPM packages From 2fb43076573d18d687a222142c1e048eb9f8c1cb Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 22:23:05 +0000 Subject: [PATCH 34/56] updated messages dependency to remove designated initializers --- cpp/cmake/dependencies.cpm.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/cmake/dependencies.cpm.cmake b/cpp/cmake/dependencies.cpm.cmake index 04340f44..c7783ba2 100644 --- a/cpp/cmake/dependencies.cpm.cmake +++ b/cpp/cmake/dependencies.cpm.cmake @@ -1,7 +1,7 @@ # renovate: datasource=github-tags packageName=cpm-cmake/CPM.cmake versioning=semver set(CPM_DOWNLOAD_TAG_DIGEST v0.43.1 456cb6754daaa010d57444d0c8ce6d95ecf006ab) # renovate: datasource=github-tags packageName=cucumber/messages versioning=semver -set(CUCUMBER_MESSAGES_TAG_DIGEST v34.0.2 e13c029f4bd74cb2d92278b935c3e861e47ea5a4) +set(CUCUMBER_MESSAGES_TAG_DIGEST v34.0.2 58c3ef1d95dae7839bb6766ebaffe524fd569697) # renovate: datasource=github-tags packageName=google/googletest versioning=semver set(GOOGLE_TEST_TAG_DIGEST v1.17.0 52eb8108c5bdec04579160ae17225d66034bd723) From b684c6a08e091d78306e604bd12fcf43e586bf6e Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 22:23:14 +0000 Subject: [PATCH 35/56] remove pip cache from Python setup in CI workflow --- .github/workflows/test-cpp.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-cpp.yaml b/.github/workflows/test-cpp.yaml index d5ec13a3..eed3e20d 100644 --- a/.github/workflows/test-cpp.yaml +++ b/.github/workflows/test-cpp.yaml @@ -96,7 +96,6 @@ jobs: - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: '3.12' - cache: 'pip' - name: Install build tools run: | From f64fbca0d6871d46975f77f362d516ddeaf0b70e Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 22:35:55 +0000 Subject: [PATCH 36/56] add command to check gcovr version in lcov report generation --- cpp/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 5bec8cef..9cd39cd3 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -43,6 +43,7 @@ if(CUCUMBER_QUERY_ENABLE_COVERAGE) add_custom_target( generate-lcov-report + COMMAND ${GCOVR_PROGRAM} --version COMMAND ${GCOVR_PROGRAM} --root ${CMAKE_CURRENT_SOURCE_DIR} --merge-lines --delete --exclude-unreachable-branches --exclude-throw-branches --exclude-noncode-lines --filter include/ --filter src/ --txt-summary --lcov ${CMAKE_CURRENT_BINARY_DIR}/lcov.info From ffab82605e9f351e41b069c24066a6994e017639 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 22:39:59 +0000 Subject: [PATCH 37/56] update gcovr version to 8.6 in CI workflow --- .github/workflows/test-cpp.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-cpp.yaml b/.github/workflows/test-cpp.yaml index eed3e20d..aaa6c6a3 100644 --- a/.github/workflows/test-cpp.yaml +++ b/.github/workflows/test-cpp.yaml @@ -101,7 +101,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y ccache - python -m pip install gcovr==8.2 + python -m pip install gcovr==8.6 gcovr --version - name: Cache CPM packages From cedd4a4ff7b86949bc52c1f5723e4bd18bd9002c Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 22:42:43 +0000 Subject: [PATCH 38/56] update gtest discovery mode to PRE_TEST for cucumber_query_lib.test --- cpp/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index b3351f00..1cd3d111 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -18,4 +18,4 @@ target_compile_definitions(cucumber_query_lib.test ) include(GoogleTest) -gtest_discover_tests(cucumber_query_lib.test) +gtest_discover_tests(cucumber_query_lib.test DISCOVERY_MODE PRE_TEST) From ea28f1d189013f7cfb3a427fbda0262407e2c0da Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 22:47:18 +0000 Subject: [PATCH 39/56] enable test discovery for cucumber_query_lib.test and remove GoogleTest include --- cpp/test/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index 1cd3d111..92d24b5a 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -1,5 +1,5 @@ add_executable(cucumber_query_lib.test) -# add_test(NAME cucumber_query_lib.test COMMAND cucumber_query_lib.test) +add_test(NAME cucumber_query_lib.test COMMAND cucumber_query_lib.test) target_sources(cucumber_query_lib.test PRIVATE @@ -16,6 +16,3 @@ target_compile_definitions(cucumber_query_lib.test PRIVATE TESTDATA_SRC="${CMAKE_SOURCE_DIR}/../testdata/src" ) - -include(GoogleTest) -gtest_discover_tests(cucumber_query_lib.test DISCOVERY_MODE PRE_TEST) From 8ed8d3e82ba252246f284016e37447aa521b1db8 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 22:54:39 +0000 Subject: [PATCH 40/56] add support for undefined behavior sanitizer on Apple platforms --- cpp/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 9cd39cd3..857e81b8 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -100,7 +100,10 @@ if(CUCUMBER_QUERY_ENABLE_COVERAGE) endif() if(CUCUMBER_QUERY_ENABLE_SANITIZERS) - if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")) + if(APPLE) + add_compile_options(-fsanitize=undefined) + add_link_options(-fsanitize=undefined) + elseif(NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")) add_compile_options(-fsanitize=address -fsanitize=undefined) add_link_options(-fsanitize=address -fsanitize=undefined) endif() From 69574565870ee3c2f14b9eb8c050dcd45e5ff37d Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 23:13:26 +0000 Subject: [PATCH 41/56] refine sanitizer options for Apple platforms and restrict to GNU compiler --- cpp/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 857e81b8..63de5036 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -100,10 +100,7 @@ if(CUCUMBER_QUERY_ENABLE_COVERAGE) endif() if(CUCUMBER_QUERY_ENABLE_SANITIZERS) - if(APPLE) - add_compile_options(-fsanitize=undefined) - add_link_options(-fsanitize=undefined) - elseif(NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") add_compile_options(-fsanitize=address -fsanitize=undefined) add_link_options(-fsanitize=address -fsanitize=undefined) endif() From 286f5935938a180f0585308a2ee4fac564799bda Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 8 Aug 2026 23:16:52 +0000 Subject: [PATCH 42/56] remove redundant test registration and ensure test discovery for cucumber_query_lib.test --- cpp/test/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index 92d24b5a..8c273e54 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -1,5 +1,4 @@ add_executable(cucumber_query_lib.test) -add_test(NAME cucumber_query_lib.test COMMAND cucumber_query_lib.test) target_sources(cucumber_query_lib.test PRIVATE @@ -16,3 +15,6 @@ target_compile_definitions(cucumber_query_lib.test PRIVATE TESTDATA_SRC="${CMAKE_SOURCE_DIR}/../testdata/src" ) + +include(GoogleTest) +gtest_discover_tests(cucumber_query_lib.test) From 0c555153a5261114aa0677b3cd31d581f748fdd6 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sun, 9 Aug 2026 21:14:32 +0000 Subject: [PATCH 43/56] Add a check to ensure an error is reported when tests are added to testdata, but not the the cpp tests --- .github/workflows/test-cpp.yaml | 4 ++ cpp/test/CMakeLists.txt | 10 ++++ cpp/test/CheckTestdataCoverage.cmake | 89 ++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 cpp/test/CheckTestdataCoverage.cmake diff --git a/.github/workflows/test-cpp.yaml b/.github/workflows/test-cpp.yaml index aaa6c6a3..d4ff306a 100644 --- a/.github/workflows/test-cpp.yaml +++ b/.github/workflows/test-cpp.yaml @@ -86,6 +86,10 @@ jobs: working-directory: cpp run: cmake --workflow test + - name: Check testdata coverage + working-directory: cpp + run: cmake --build build/test --target check-testdata-coverage + test-cpp-coverage: runs-on: ubuntu-26.04 steps: diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index 8c273e54..0c6decd7 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -18,3 +18,13 @@ target_compile_definitions(cucumber_query_lib.test include(GoogleTest) gtest_discover_tests(cucumber_query_lib.test) + +add_custom_target( + check-testdata-coverage + COMMAND ${CMAKE_COMMAND} + -DTEST_BINARY=$ + -DTESTDATA_SRC=${CMAKE_SOURCE_DIR}/../testdata/src + -P ${CMAKE_CURRENT_SOURCE_DIR}/CheckTestdataCoverage.cmake + DEPENDS cucumber_query_lib.test + COMMENT "Checking testdata coverage in C++ tests" +) diff --git a/cpp/test/CheckTestdataCoverage.cmake b/cpp/test/CheckTestdataCoverage.cmake new file mode 100644 index 00000000..242640ae --- /dev/null +++ b/cpp/test/CheckTestdataCoverage.cmake @@ -0,0 +1,89 @@ +# Verifies that every query type and naming strategy variant in testdata/src +# has a corresponding TEST_P in the C++ acceptance tests. +# +# Required variables (passed via -D): +# TEST_BINARY — path to the built cucumber_query_lib.test binary +# TESTDATA_SRC — path to testdata/src + +execute_process( + COMMAND "${TEST_BINARY}" --gtest_list_tests + OUTPUT_VARIABLE raw_output + RESULT_VARIABLE result_code + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +if(NOT result_code EQUAL 0) + message(FATAL_ERROR "Failed to list tests: ${TEST_BINARY} --gtest_list_tests") +endif() + +string(REPLACE "\r\n" "\n" raw_output "${raw_output}") +string(REPLACE "\n" ";" lines "${raw_output}") + +set(in_query_suite FALSE) +set(in_naming_suite FALSE) +set(cpp_query_names "") +set(cpp_naming_variants "") + +foreach(line IN LISTS lines) + if(line MATCHES "^Acceptance/QueryAcceptanceTest\\.") + set(in_query_suite TRUE) + set(in_naming_suite FALSE) + elseif(line MATCHES "^Acceptance/NamingStrategyAcceptanceTest\\.") + set(in_query_suite FALSE) + set(in_naming_suite TRUE) + elseif(line MATCHES "^[^ ]") + set(in_query_suite FALSE) + set(in_naming_suite FALSE) + elseif(in_query_suite AND line MATCHES "^ [^ ]") + string(REGEX REPLACE "^ ([^ /]+)/.*$" "\\1" test_name "${line}") + list(APPEND cpp_query_names "${test_name}") + elseif(in_naming_suite AND line MATCHES "^ [^ ]") + string(REGEX REPLACE "^ ([^ /]+)/.*$" "\\1" test_name "${line}") + # gtest uses underscores in test names; testdata file variants use hyphens + string(REPLACE "_" "-" variant_name "${test_name}") + list(APPEND cpp_naming_variants "${variant_name}") + endif() +endforeach() + +list(REMOVE_DUPLICATES cpp_query_names) +list(REMOVE_DUPLICATES cpp_naming_variants) + +file(GLOB result_files "${TESTDATA_SRC}/*.results.json") +set(testdata_query_names "") +foreach(f IN LISTS result_files) + get_filename_component(filename "${f}" NAME) + string(REGEX REPLACE "^[^.]+\\.(.+)\\.results\\.json$" "\\1" query_name "${filename}") + list(APPEND testdata_query_names "${query_name}") +endforeach() +list(REMOVE_DUPLICATES testdata_query_names) + +file(GLOB naming_files "${TESTDATA_SRC}/*.naming-strategy.*.txt") +set(testdata_naming_variants "") +foreach(f IN LISTS naming_files) + get_filename_component(filename "${f}" NAME) + string(REGEX REPLACE "^[^.]+\\.naming-strategy\\.(.+)\\.txt$" "\\1" variant "${filename}") + list(APPEND testdata_naming_variants "${variant}") +endforeach() +list(REMOVE_DUPLICATES testdata_naming_variants) + +set(found_gaps FALSE) + +foreach(name IN LISTS testdata_query_names) + if(NOT name IN_LIST cpp_query_names) + message(WARNING "Query type '${name}' exists in testdata but has no TEST_P in QueryAcceptanceTest") + set(found_gaps TRUE) + endif() +endforeach() + +foreach(variant IN LISTS testdata_naming_variants) + if(NOT variant IN_LIST cpp_naming_variants) + message(WARNING "Naming strategy variant '${variant}' exists in testdata but has no TEST_P in NamingStrategyAcceptanceTest") + set(found_gaps TRUE) + endif() +endforeach() + +if(found_gaps) + message(FATAL_ERROR "C++ tests are missing coverage for new testdata. Add TEST_P entries to TestQuery.cpp.") +endif() + +message(STATUS "All testdata query types and naming strategy variants are covered.") From a47b6dd0e6805e7c71b57850ed5acd3ddf273be8 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sun, 9 Aug 2026 21:58:57 +0000 Subject: [PATCH 44/56] add install support --- cpp/CMakeLists.txt | 50 ++++++++++++++++++++---- cpp/cmake/cucumber_query-config.cmake.in | 8 ++++ cpp/cmake/dependencies.cpm.cmake | 4 +- 3 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 cpp/cmake/cucumber_query-config.cmake.in diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 63de5036..cf9d0dab 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -125,7 +125,7 @@ target_include_directories( cucumber_query_lib PUBLIC $ - $ + $ PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src/messages ) @@ -146,13 +146,47 @@ set_target_properties( OUTPUT_NAME cucumber_query ) -# Installation -# Installation -# Installation -# Installation -# Installation -# Installation -# Installation +# Installation support +include(CMakePackageConfigHelpers) + +configure_package_config_file( + "cmake/cucumber_query-config.cmake.in" + "${PROJECT_BINARY_DIR}/cucumber_query-config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cucumber_query" + PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR +) + +write_basic_package_version_file( + "${PROJECT_BINARY_DIR}/cucumber_query-config-version.cmake" + COMPATIBILITY AnyNewerVersion +) + +install( + TARGETS cucumber_query_lib + EXPORT cucumber_query-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +install( + EXPORT cucumber_query-targets + FILE cucumber_query-targets.cmake + NAMESPACE cucumber:: + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cucumber_query" +) + +install( + FILES + "${PROJECT_BINARY_DIR}/cucumber_query-config.cmake" + "${PROJECT_BINARY_DIR}/cucumber_query-config-version.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cucumber_query" +) + +install( + DIRECTORY "${PROJECT_SOURCE_DIR}/include/" + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) # Optional: tests if(CUCUMBER_QUERY_BUILD_TESTS) diff --git a/cpp/cmake/cucumber_query-config.cmake.in b/cpp/cmake/cucumber_query-config.cmake.in new file mode 100644 index 00000000..6861f92f --- /dev/null +++ b/cpp/cmake/cucumber_query-config.cmake.in @@ -0,0 +1,8 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +find_dependency(cucumber_messages) +find_dependency(nlohmann_json) + +include("${CMAKE_CURRENT_LIST_DIR}/cucumber_query-targets.cmake") diff --git a/cpp/cmake/dependencies.cpm.cmake b/cpp/cmake/dependencies.cpm.cmake index c7783ba2..d6c08cdd 100644 --- a/cpp/cmake/dependencies.cpm.cmake +++ b/cpp/cmake/dependencies.cpm.cmake @@ -1,7 +1,7 @@ # renovate: datasource=github-tags packageName=cpm-cmake/CPM.cmake versioning=semver set(CPM_DOWNLOAD_TAG_DIGEST v0.43.1 456cb6754daaa010d57444d0c8ce6d95ecf006ab) # renovate: datasource=github-tags packageName=cucumber/messages versioning=semver -set(CUCUMBER_MESSAGES_TAG_DIGEST v34.0.2 58c3ef1d95dae7839bb6766ebaffe524fd569697) +set(CUCUMBER_MESSAGES_TAG_DIGEST v34.0.2 01e84523a5cbdb4a3a4e10e3ba53cb7a64a97964) # renovate: datasource=github-tags packageName=google/googletest versioning=semver set(GOOGLE_TEST_TAG_DIGEST v1.17.0 52eb8108c5bdec04579160ae17225d66034bd723) @@ -53,8 +53,6 @@ if(CUCUMBER_QUERY_FETCH_DEPS) install(SCRIPT "${cucumber_messages_BINARY_DIR}/cmake_install.cmake") endif() - - if(CUCUMBER_QUERY_BUILD_TESTS) CPMAddPackage( URI "gh:google/googletest@${GOOGLE_TEST_VERSION}#${GOOGLE_TEST_DIGEST}" From 66c2be5fa7f157ec629dadb97308055caf3be09b Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sun, 9 Aug 2026 22:09:55 +0000 Subject: [PATCH 45/56] Replaced std pair with aggregate type --- cpp/include/cucumber/query/Query.hpp | 7 ++++++- cpp/src/query/Query.cpp | 16 ++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cpp/include/cucumber/query/Query.hpp b/cpp/include/cucumber/query/Query.hpp index bb7271ed..7d2f5bd9 100644 --- a/cpp/include/cucumber/query/Query.hpp +++ b/cpp/include/cucumber/query/Query.hpp @@ -30,6 +30,11 @@ namespace cucumber::query std::shared_ptr pickle; }; + struct TestStepFinishedAndTestStep{ + std::shared_ptr testStepFinished; + std::shared_ptr testStep; + }; + class Query { public: @@ -136,7 +141,7 @@ namespace cucumber::query [[nodiscard]] auto FindTestStepsFinishedBy(const std::shared_ptr& element) const -> std::vector>; [[nodiscard]] auto FindTestStepFinishedAndTestStepBy(const std::shared_ptr& testCaseStarted) const - -> std::vector, std::shared_ptr>>; + -> std::vector; [[nodiscard]] auto FindLineageBy(const std::shared_ptr& element) const -> std::optional; [[nodiscard]] auto FindLineageBy(const std::shared_ptr& element) const -> std::optional; diff --git a/cpp/src/query/Query.cpp b/cpp/src/query/Query.cpp index ed706127..83d0b4e4 100644 --- a/cpp/src/query/Query.cpp +++ b/cpp/src/query/Query.cpp @@ -28,13 +28,13 @@ namespace cucumber::query }); } - auto SortBySeverity(std::vector, std::shared_ptr>>& container) -> void + auto SortBySeverity(std::vector& container) -> void { std::sort(container.begin(), container.end(), [](const auto& lhs, const auto& rhs) { using underlying_type = std::underlying_type_t; - return static_cast(lhs.first->testStepResult->status) > static_cast(rhs.first->testStepResult->status); + return static_cast(lhs.testStepFinished->testStepResult->status) > static_cast(rhs.testStepFinished->testStepResult->status); }); } @@ -187,7 +187,7 @@ namespace cucumber::query { SortBySeverity(testStepFinishedAndTestStep); - ++result[testStepFinishedAndTestStep.front().first->testStepResult->status]; + ++result[testStepFinishedAndTestStep.front().testStepFinished->testStepResult->status]; } } @@ -350,7 +350,7 @@ namespace cucumber::query { SortBySeverity(testStepFinishedAndTestStep); - return testStepFinishedAndTestStep.front().first->testStepResult; + return testStepFinishedAndTestStep.front().testStepFinished->testStepResult; } return std::nullopt; } @@ -702,10 +702,9 @@ namespace cucumber::query return {}; } - auto Query::FindTestStepFinishedAndTestStepBy(const std::shared_ptr& testCaseStarted) const - -> std::vector, std::shared_ptr>> + auto Query::FindTestStepFinishedAndTestStepBy(const std::shared_ptr& testCaseStarted) const -> std::vector { - std::vector, std::shared_ptr>> result; + std::vector result; const auto testStepsFinishedIter = testStepFinishedByTestCaseStartedId.find(testCaseStarted->id); if (testStepsFinishedIter != testStepFinishedByTestCaseStartedId.end()) @@ -715,10 +714,11 @@ namespace cucumber::query const auto& testStep = FindTestStepBy(testStepFinished); if (testStep.has_value()) { - result.emplace_back(testStepFinished, *testStep); + result.emplace_back(TestStepFinishedAndTestStep{ testStepFinished, *testStep }); } } } + return result; } From d4703625e9c91dc0980b780d4655fba8d2bf69f3 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sun, 9 Aug 2026 22:10:08 +0000 Subject: [PATCH 46/56] fix post run coverage target --- .devcontainer/cpp/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/cpp/devcontainer.json b/.devcontainer/cpp/devcontainer.json index 8818164b..900fcc80 100644 --- a/.devcontainer/cpp/devcontainer.json +++ b/.devcontainer/cpp/devcontainer.json @@ -16,7 +16,7 @@ "cmake.copyCompileCommands": "${userHome}/.cpp/compile_commands.json", "cmake.sourceDirectory": "${workspaceFolder}/cpp", "cmake.useCMakePresets": "auto", - "cmake.postRunCoverageTarget": "generate-coverage-report", + "cmake.postRunCoverageTarget": "generate-lcov-report", "cmake.coverageInfoFiles": [ "${workspaceFolder}/cpp/build/coverage/lcov.info" ] From 0ef13ca397d574ff61136ea266d4cd2953385bdd Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Mon, 10 Aug 2026 21:39:21 +0000 Subject: [PATCH 47/56] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca9b0802..edd186ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added +- [CPP] Initial C++ implementation ([#201](https://github.com/cucumber/query/pull/201)) ## [16.1.1] - 2026-08-05 ### Fixed From 765a057277bf33f2606eb6d1581421f94eeee251 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Mon, 10 Aug 2026 21:43:05 +0000 Subject: [PATCH 48/56] fix for uibuntu 24 --- cpp/test/CheckTestdataCoverage.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cpp/test/CheckTestdataCoverage.cmake b/cpp/test/CheckTestdataCoverage.cmake index 242640ae..ea047599 100644 --- a/cpp/test/CheckTestdataCoverage.cmake +++ b/cpp/test/CheckTestdataCoverage.cmake @@ -69,14 +69,16 @@ list(REMOVE_DUPLICATES testdata_naming_variants) set(found_gaps FALSE) foreach(name IN LISTS testdata_query_names) - if(NOT name IN_LIST cpp_query_names) + list(FIND cpp_query_names "${name}" query_index) + if(query_index EQUAL -1) message(WARNING "Query type '${name}' exists in testdata but has no TEST_P in QueryAcceptanceTest") set(found_gaps TRUE) endif() endforeach() foreach(variant IN LISTS testdata_naming_variants) - if(NOT variant IN_LIST cpp_naming_variants) + list(FIND cpp_naming_variants "${variant}" variant_index) + if(variant_index EQUAL -1) message(WARNING "Naming strategy variant '${variant}' exists in testdata but has no TEST_P in NamingStrategyAcceptanceTest") set(found_gaps TRUE) endif() From 1900844a969a585734ba6b5fe7756ae08d3ca042 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Wed, 12 Aug 2026 22:50:39 +0000 Subject: [PATCH 49/56] Update CONTRIBUTING.md --- CONTRIBUTING.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b2ee5e2d..fdbe7492 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,6 +12,7 @@ Currently, the list is: - JavaScript - C# (.NET) - Ruby +- c++ Java is the reference implementation in the sense that it is responsible for generating the fixtures that are used in the acceptance tests to verify all @@ -39,11 +40,11 @@ UPDATE_SAMPLES=true mvn test Choosing which type to use in another language based on what we did in Java is an inexact science. This table defines all the decisions we've made so far: -| Java | JavaScript | C# | Ruby | -|---------------|----------------------|--------------------|--------------| -| `Optional` | `T \| undefined`[^1] | `T?` | `T \| nil` | -| `List` | `ReadonlyArray` | `List` | `Array` | -| `Map` | `Map` | `Dictionary` | `Hash` | -| `Map` | `Record` | `Dictionary` | `Hash` | +| Java | JavaScript | C# | Ruby | Cpp | +| ------------- | -------------------- | ------------------ | ------------ | ----------------------- | +| `Optional` | `T \| undefined`[^1] | `T?` | `T \| nil` | std::optional | +| `List` | `ReadonlyArray` | `List` | `Array` | std::vector | +| `Map` | `Map` | `Dictionary` | `Hash` | std::unordered_map | +| `Map` | `Record` | `Dictionary` | `Hash` | std::unordered_map | [^1]: See From 7749664d09fe076799a559f4ea946c98f138239d Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Thu, 20 Aug 2026 22:48:27 +0000 Subject: [PATCH 50/56] Refactor CMake configuration and integrate Conan for dependency management --- .github/workflows/codeql-cpp.yaml | 38 +- .github/workflows/test-cpp.yaml | 267 ++++++++--- cpp/CMakeLists.txt | 5 +- cpp/CMakePresets.json | 140 ++++-- cpp/cmake/conan_provider.cmake | 722 ++++++++++++++++++++++++++++++ cpp/cmake/dependencies.cpm.cmake | 76 ---- cpp/conanfile.py | 91 ++++ 7 files changed, 1152 insertions(+), 187 deletions(-) create mode 100644 cpp/cmake/conan_provider.cmake delete mode 100644 cpp/cmake/dependencies.cpm.cmake create mode 100644 cpp/conanfile.py diff --git a/.github/workflows/codeql-cpp.yaml b/.github/workflows/codeql-cpp.yaml index 24039cbb..d1d5f33f 100644 --- a/.github/workflows/codeql-cpp.yaml +++ b/.github/workflows/codeql-cpp.yaml @@ -27,30 +27,34 @@ concurrency: jobs: analyze: - env: - CCACHE_BASEDIR: ${{ github.workspace }} - CCACHE_DIR: ${{ github.workspace }}/.ccache - CPM_SOURCE_CACHE: ${{ github.workspace }}/.cpm - name: Analyze C++ runs-on: ubuntu-latest permissions: security-events: write + env: + CCACHE_BASEDIR: ${{ github.workspace }} + CCACHE_DIR: ${{ github.workspace }}/.ccache + # Git ref (tag, branch, or SHA) of the cucumber_messages dependency to + # build against. Must match the version required in cpp/CMakeLists.txt and + # cpp/conanfile.py, or the messages branch under test. + MESSAGES_REF: eebd9f2f48ae94e0ada14ab01d53e1ecaaecb172 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - name: Install build tools + - name: Checkout cucumber/messages + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: cucumber/messages + ref: ${{ env.MESSAGES_REF }} + path: messages-src + persist-credentials: false + + - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y ccache - - - name: Cache CPM packages - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: ${{ env.CPM_SOURCE_CACHE }} - key: cpm-${{ hashFiles('cpp/cmake/dependencies.cpm.cmake') }} + sudo apt-get install -y ccache nlohmann-json3-dev - name: Cache ccache uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 @@ -59,6 +63,12 @@ jobs: key: ccache-${{ github.job }}-${{ github.ref }} restore-keys: ccache-${{ github.job }}- + - name: Build and install cucumber_messages + working-directory: messages-src/cpp + run: | + cmake --workflow --preset host-system + sudo cmake --install build/host-system + - uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6 with: languages: c-cpp @@ -67,7 +77,7 @@ jobs: - name: Configure working-directory: cpp - run: cmake --workflow host + run: cmake --workflow --preset host-system - uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6 with: diff --git a/.github/workflows/test-cpp.yaml b/.github/workflows/test-cpp.yaml index d4ff306a..76836b12 100644 --- a/.github/workflows/test-cpp.yaml +++ b/.github/workflows/test-cpp.yaml @@ -12,20 +12,21 @@ on: - testdata/** - .github/** pull_request: - branches: - - main paths: - cpp/** - testdata/** - .github/** env: - CCACHE_BASEDIR: ${{ github.workspace }} - CCACHE_DIR: ${{ github.workspace }}/.ccache - CPM_SOURCE_CACHE: ${{ github.workspace }}/.cpm + # Git ref (tag, branch, or SHA) of the cucumber_messages dependency to build + # against. For releases use a tag matching the version required in + # cpp/CMakeLists.txt (find_package) and cpp/conanfile.py; for cross-repo + # feature work, set this to the messages branch under test. + MESSAGES_REF: eebd9f2f48ae94e0ada14ab01d53e1ecaaecb172 jobs: - test-cpp: + test-cpp-system-packages-linux: + runs-on: ${{ matrix.config.os }} strategy: fail-fast: false matrix: @@ -38,92 +39,216 @@ jobs: - { os: ubuntu-26.04, cxx: g++, version: 15 } - { os: ubuntu-26.04, cxx: clang++, version: 21 } - { os: ubuntu-26.04, cxx: clang++, version: 22 } - - { os: macos-latest, cxx: clang++, version: 17 } - - { os: windows-latest, cxx: cl } - - runs-on: ${{ matrix.config.os }} + env: + CXX: ${{ matrix.config.cxx }}-${{ matrix.config.version }} steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + + - name: Checkout cucumber/messages + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: + repository: cucumber/messages + ref: ${{ env.MESSAGES_REF }} + path: messages-src persist-credentials: false - - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 - if: startsWith(matrix.config.os, 'windows') + - name: ccache + uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 + with: + key: ${{ github.job }}-${{ matrix.config.os }}-${{ matrix.config.cxx }}-${{ matrix.config.version }}-${{ github.ref }} + append-timestamp: false + save: ${{ github.ref == 'refs/heads/main' }} - - name: Install build tools (ubuntu) - if: startsWith(matrix.config.os, 'ubuntu') + - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y ccache + sudo apt-get install -y nlohmann-json3-dev libgtest-dev libgmock-dev + + - name: Build and install cucumber_messages + working-directory: messages-src/cpp + run: | + cmake --workflow --preset host-system + sudo cmake --install build/host-system + + - name: Build and unit test + working-directory: cpp + run: cmake --workflow --preset test-system + + - name: Check testdata coverage + working-directory: cpp + run: cmake --build build/test-system --target check-testdata-coverage + + test-cpp-system-packages-macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + + - name: Checkout cucumber/messages + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + repository: cucumber/messages + ref: ${{ env.MESSAGES_REF }} + path: messages-src + persist-credentials: false + + - name: ccache + uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 + with: + key: ${{ github.job }}-${{ github.ref }} + append-timestamp: false + save: ${{ github.ref == 'refs/heads/main' }} + + - name: Install dependencies + run: brew install nlohmann-json googletest - - name: Install build tools (macos) - if: startsWith(matrix.config.os, 'macos') - run: brew install ccache llvm@${{ matrix.config.version }} + - name: Build and install cucumber_messages + working-directory: messages-src/cpp + run: | + cmake --workflow --preset host-system + sudo cmake --install build/host-system + + - name: Build and unit test + working-directory: cpp + run: cmake --workflow --preset test-system - - name: Cache CPM packages - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + - name: Check testdata coverage + working-directory: cpp + run: cmake --build build/test-system --target check-testdata-coverage + + test-cpp-system-packages-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: - path: ${{ env.CPM_SOURCE_CACHE }} - key: cpm-${{ hashFiles('cpp/cmake/dependencies.cpm.cmake') }} + persist-credentials: false - - name: Cache ccache - if: "!startsWith(matrix.config.os, 'windows')" - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + - name: Checkout cucumber/messages + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ github.job }}-${{ matrix.config.os }}-${{ matrix.config.cxx }}-${{ matrix.config.version }}-${{ github.ref }} - restore-keys: ccache-${{ github.job }}-${{ matrix.config.os }}-${{ matrix.config.cxx }}-${{ matrix.config.version }}- + repository: cucumber/messages + ref: ${{ env.MESSAGES_REF }} + path: messages-src + persist-credentials: false - - name: Set CXX (ubuntu) - if: startsWith(matrix.config.os, 'ubuntu') - run: echo "CXX=${{ matrix.config.cxx }}-${{ matrix.config.version }}" >> $GITHUB_ENV + - name: Install build tools + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 - - name: Set CXX (macos) - if: startsWith(matrix.config.os, 'macos') - run: echo "CXX=$(brew --prefix llvm@${{ matrix.config.version }})/bin/clang++" >> $GITHUB_ENV + - name: Install dependencies + shell: pwsh + run: | + vcpkg install nlohmann-json gtest --triplet x64-windows + # Expose the vcpkg toolchain so find_package() locates the packages. + echo "CMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $env:GITHUB_ENV - - name: Test + - name: Build and install cucumber_messages + working-directory: messages-src/cpp + run: | + cmake --workflow --preset host-system + cmake --install build/host-system + + - name: Build and unit test working-directory: cpp - run: cmake --workflow test + run: cmake --workflow --preset test-system - name: Check testdata coverage working-directory: cpp - run: cmake --build build/test --target check-testdata-coverage + run: cmake --build build/test-system --target check-testdata-coverage + + test-cpp-conan: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-24.04, ubuntu-26.04, macos-latest, windows-latest] + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + + - name: Checkout cucumber/messages + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + repository: cucumber/messages + ref: ${{ env.MESSAGES_REF }} + path: messages-src + persist-credentials: false + + - name: Install build tools (windows) + if: startsWith(matrix.os, 'windows') + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + + - name: ccache + uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 + with: + key: ${{ github.job }}-${{ matrix.os }}-${{ github.ref }} + append-timestamp: false + save: ${{ github.ref == 'refs/heads/main' }} + + - name: Setup Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: '3.x' + + - name: Install Conan + run: python -m pip install --upgrade "conan>=2,<3" + + - name: Detect Conan profile + run: conan profile detect --force + + - name: Create cucumber_messages Conan package + working-directory: messages-src/cpp + run: conan create . --build=missing -s compiler.cppstd=17 + + - name: Build and unit test (Conan dependencies) + working-directory: cpp + run: cmake --workflow --preset test-conan test-cpp-coverage: runs-on: ubuntu-26.04 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + + - name: Checkout cucumber/messages + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: + repository: cucumber/messages + ref: ${{ env.MESSAGES_REF }} + path: messages-src persist-credentials: false - - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: '3.12' - - name: Install build tools + - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y ccache + sudo apt-get install -y nlohmann-json3-dev libgtest-dev libgmock-dev python -m pip install gcovr==8.6 gcovr --version - - name: Cache CPM packages - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + - name: ccache + uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 with: - path: ${{ env.CPM_SOURCE_CACHE }} - key: cpm-${{ hashFiles('cpp/cmake/dependencies.cpm.cmake') }} + key: ${{ github.job }}-${{ github.ref }} + append-timestamp: false + save: ${{ github.ref == 'refs/heads/main' }} - - name: Cache ccache - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ github.job }}-${{ github.ref }} - restore-keys: ccache-${{ github.job }}- + - name: Build and install cucumber_messages + working-directory: messages-src/cpp + run: | + cmake --workflow --preset host-system + sudo cmake --install build/host-system - name: Coverage working-directory: cpp - run: cmake --workflow coverage + run: cmake --workflow --preset coverage - name: Show coverage summary working-directory: cpp @@ -134,28 +259,36 @@ jobs: env: CXX: clang++ steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: persist-credentials: false - - name: Install build tools + - name: Checkout cucumber/messages + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + repository: cucumber/messages + ref: ${{ env.MESSAGES_REF }} + path: messages-src + persist-credentials: false + + - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y ccache clang clang-tidy + sudo apt-get install -y clang clang-tidy nlohmann-json3-dev libgtest-dev libgmock-dev - - name: Cache CPM packages - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + - name: ccache + uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 with: - path: ${{ env.CPM_SOURCE_CACHE }} - key: cpm-${{ hashFiles('cpp/cmake/dependencies.cpm.cmake') }} + key: ${{ github.job }}-${{ github.ref }} + append-timestamp: false + save: ${{ github.ref == 'refs/heads/main' }} - - name: Cache ccache - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ github.job }}-${{ github.ref }} - restore-keys: ccache-${{ github.job }}- + - name: Build and install cucumber_messages + working-directory: messages-src/cpp + run: | + cmake --workflow --preset host-system + sudo cmake --install build/host-system - name: Lint working-directory: cpp - run: cmake --workflow tidy + run: cmake --workflow --preset tidy diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index cf9d0dab..8d5b4bb7 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -25,7 +25,6 @@ if (POLICY CMP0077) endif () option(CUCUMBER_QUERY_BUILD_TESTS "Build the unit tests." Off) -option(CUCUMBER_QUERY_FETCH_DEPS "Fetch dependencies via FetchContent." Off) option(CUCUMBER_QUERY_ENABLE_CLANG_TIDY "Run clang-tidy as part of the build." Off) option(CUCUMBER_QUERY_ENABLE_COVERAGE "Enable compiler flags for code coverage measurements." Off) option(CUCUMBER_QUERY_ENABLE_SANITIZERS "Enable compiler flags for the address and undefined behaviour sanitizers." Off) @@ -79,7 +78,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") endif() # CMake dependencies -include(cmake/dependencies.cpm.cmake) +find_package(nlohmann_json 3.11 REQUIRED) +find_package(cucumber_messages 34.2.1 REQUIRED) # Target options if(CUCUMBER_QUERY_ENABLE_CLANG_TIDY) @@ -190,6 +190,7 @@ install( # Optional: tests if(CUCUMBER_QUERY_BUILD_TESTS) + find_package(GTest REQUIRED) include(CTest) enable_testing() add_subdirectory(test) diff --git a/cpp/CMakePresets.json b/cpp/CMakePresets.json index 93c91890..39212082 100644 --- a/cpp/CMakePresets.json +++ b/cpp/CMakePresets.json @@ -6,53 +6,96 @@ }, "configurePresets": [ { - "name": "host", + "name": "base", + "hidden": true, "binaryDir": "${sourceDir}/build/${presetName}", "generator": "Ninja", "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": "On", - "CUCUMBER_QUERY_FETCH_DEPS": "On", + "CMAKE_EXPORT_COMPILE_COMMANDS": "On" + } + }, + { + "name": "host-system", + "displayName": "Host build (system dependencies)", + "description": "Build and install the library using C++ dependencies already installed on the system. Does not use Conan and does not build tests.", + "inherits": "base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "test-system", + "displayName": "Test build (system dependencies)", + "description": "Build with unit tests and sanitizers enabled using system dependencies. Used by CI to build and run the test suite.", + "inherits": "base", + "cacheVariables": { + "CUCUMBER_QUERY_BUILD_TESTS": "On", + "CUCUMBER_QUERY_ENABLE_SANITIZERS": "On", "CMAKE_BUILD_TYPE": "Debug" } }, { - "name": "test-base", - "inherits": "host", - "hidden": true, + "name": "host-conan", + "displayName": "Host build (Conan dependencies)", + "description": "Build and install the library using Conan-provided dependencies. Used by CI. Does not build tests.", + "inherits": "base", "cacheVariables": { - "CUCUMBER_QUERY_BUILD_TESTS": "On" + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "${sourceDir}/cmake/conan_provider.cmake", + "CMAKE_BUILD_TYPE": "Release", + "CONAN_INSTALL_ARGS": "--build=missing" } }, { - "name": "test", - "inherits": "test-base", + "name": "test-conan", + "displayName": "Test build (automatic Conan)", + "description": "Build with unit tests enabled using Conan-provided dependencies. Used by CI.", + "inherits": "base", "cacheVariables": { - "CUCUMBER_QUERY_ENABLE_SANITIZERS": "On" + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "${sourceDir}/cmake/conan_provider.cmake", + "CUCUMBER_QUERY_BUILD_TESTS": "On", + "CMAKE_BUILD_TYPE": "Debug", + "CONAN_INSTALL_ARGS": "--build=missing" } }, { "name": "tidy", - "inherits": "test-base", + "displayName": "Lint build (clang-tidy, system dependencies)", + "description": "Build with unit tests and clang-tidy enabled using system dependencies.", + "inherits": "base", "cacheVariables": { - "CUCUMBER_QUERY_ENABLE_CLANG_TIDY": "On" + "CUCUMBER_QUERY_BUILD_TESTS": "On", + "CUCUMBER_QUERY_ENABLE_CLANG_TIDY": "On", + "CMAKE_BUILD_TYPE": "Debug" } }, { "name": "coverage", - "inherits": "test-base", + "displayName": "Coverage build (system dependencies)", + "description": "Build with unit tests and code coverage instrumentation using system dependencies.", + "inherits": "base", "cacheVariables": { - "CUCUMBER_QUERY_ENABLE_COVERAGE": "On" + "CUCUMBER_QUERY_BUILD_TESTS": "On", + "CUCUMBER_QUERY_ENABLE_COVERAGE": "On", + "CMAKE_BUILD_TYPE": "Debug" } } ], "buildPresets": [ { - "name": "host", - "configurePreset": "host" + "name": "host-system", + "configurePreset": "host-system" }, { - "name": "test", - "configurePreset": "test" + "name": "test-system", + "configurePreset": "test-system" + }, + { + "name": "host-conan", + "configurePreset": "host-conan" + }, + { + "name": "test-conan", + "configurePreset": "test-conan" }, { "name": "tidy", @@ -72,8 +115,19 @@ ], "testPresets": [ { - "name": "test", - "configurePreset": "test", + "name": "test-system", + "configurePreset": "test-system", + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error", + "jobs": 8 + } + }, + { + "name": "test-conan", + "configurePreset": "test-conan", "output": { "outputOnFailure": true }, @@ -85,36 +139,66 @@ { "name": "coverage", "configurePreset": "coverage", - "inherits": "test" + "inherits": "test-system" } ], "workflowPresets": [ { - "name": "host", + "name": "host-system", + "steps": [ + { + "name": "host-system", + "type": "configure" + }, + { + "name": "host-system", + "type": "build" + } + ] + }, + { + "name": "test-system", + "steps": [ + { + "name": "test-system", + "type": "configure" + }, + { + "name": "test-system", + "type": "build" + }, + { + "name": "test-system", + "type": "test" + } + ] + }, + { + "name": "host-conan", "steps": [ { - "name": "host", + "name": "host-conan", "type": "configure" }, { - "name": "host", + "name": "host-conan", "type": "build" } ] }, { - "name": "test", + "name": "test-conan", "steps": [ { - "name": "test", + "name": "test-conan", "type": "configure" }, { - "name": "test", + "name": "test-conan", "type": "build" }, { - "name": "test", + "name": "test-conan", "type": "test" } ] diff --git a/cpp/cmake/conan_provider.cmake b/cpp/cmake/conan_provider.cmake new file mode 100644 index 00000000..b2a6f0fa --- /dev/null +++ b/cpp/cmake/conan_provider.cmake @@ -0,0 +1,722 @@ +# The MIT License (MIT) +# +# Copyright (c) 2024 JFrog +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +set(CONAN_MINIMUM_VERSION 2.0.5) + +# Create a new policy scope and set the minimum required cmake version so the +# features behind a policy setting like if(... IN_LIST ...) behaves as expected +# even if the parent project does not specify a minimum cmake version or a minimum +# version less than this module requires (e.g. 3.0) before the first project() call. +# (see: https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.html) +# +# The policy-affecting calls like cmake_policy(SET...) or `cmake_minimum_required` only +# affects the current policy scope, i.e. between the PUSH and POP in this case. +# +# https://cmake.org/cmake/help/book/mastering-cmake/chapter/Policies.html#the-policy-stack +cmake_policy(PUSH) +cmake_minimum_required(VERSION 3.24) + + +function(detect_os os os_api_level os_sdk os_subsystem os_version) + # it could be cross compilation + message(STATUS "CMake-Conan: cmake_system_name=${CMAKE_SYSTEM_NAME}") + if(CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Generic") + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(${os} Macos PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX") + set(${os} Neutrino PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME STREQUAL "CYGWIN") + set(${os} Windows PARENT_SCOPE) + set(${os_subsystem} cygwin PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME MATCHES "^MSYS") + set(${os} Windows PARENT_SCOPE) + set(${os_subsystem} msys2 PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") + # https://github.com/emscripten-core/emscripten/blob/4.0.6/cmake/Modules/Platform/Emscripten.cmake#L17C1-L17C34 + set(${os} Emscripten PARENT_SCOPE) + else() + set(${os} ${CMAKE_SYSTEM_NAME} PARENT_SCOPE) + endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Android") + if(DEFINED ANDROID_PLATFORM) + string(REGEX MATCH "[0-9]+" _os_api_level ${ANDROID_PLATFORM}) + elseif(DEFINED CMAKE_SYSTEM_VERSION) + set(_os_api_level ${CMAKE_SYSTEM_VERSION}) + endif() + message(STATUS "CMake-Conan: android api level=${_os_api_level}") + set(${os_api_level} ${_os_api_level} PARENT_SCOPE) + endif() + if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS") + # CMAKE_OSX_SYSROOT contains the full path to the SDK for MakeFile/Ninja + # generators, but just has the original input string for Xcode. + if(NOT IS_DIRECTORY ${CMAKE_OSX_SYSROOT}) + set(_os_sdk ${CMAKE_OSX_SYSROOT}) + else() + if(CMAKE_OSX_SYSROOT MATCHES Simulator) + set(apple_platform_suffix simulator) + else() + set(apple_platform_suffix os) + endif() + if(CMAKE_OSX_SYSROOT MATCHES AppleTV) + set(_os_sdk "appletv${apple_platform_suffix}") + elseif(CMAKE_OSX_SYSROOT MATCHES iPhone) + set(_os_sdk "iphone${apple_platform_suffix}") + elseif(CMAKE_OSX_SYSROOT MATCHES Watch) + set(_os_sdk "watch${apple_platform_suffix}") + endif() + endif() + if(DEFINED os_sdk) + message(STATUS "CMake-Conan: cmake_osx_sysroot=${CMAKE_OSX_SYSROOT}") + set(${os_sdk} ${_os_sdk} PARENT_SCOPE) + endif() + if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET) + message(STATUS "CMake-Conan: cmake_osx_deployment_target=${CMAKE_OSX_DEPLOYMENT_TARGET}") + set(${os_version} ${CMAKE_OSX_DEPLOYMENT_TARGET} PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + + +function(detect_arch arch) + # CMAKE_OSX_ARCHITECTURES can contain multiple architectures, but Conan only supports one. + # Therefore this code only finds one. If the recipes support multiple architectures, the + # build will work. Otherwise, there will be a linker error for the missing architecture(s). + if(DEFINED CMAKE_OSX_ARCHITECTURES) + string(REPLACE " " ";" apple_arch_list "${CMAKE_OSX_ARCHITECTURES}") + list(LENGTH apple_arch_list apple_arch_count) + if(apple_arch_count GREATER 1) + message(WARNING "CMake-Conan: Multiple architectures detected, this will only work if Conan recipe(s) produce fat binaries.") + endif() + endif() + if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS" AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL "") + set(host_arch ${CMAKE_OSX_ARCHITECTURES}) + elseif(MSVC) + set(host_arch ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}) + else() + set(host_arch ${CMAKE_SYSTEM_PROCESSOR}) + endif() + if(host_arch MATCHES "aarch64|arm64|ARM64") + set(_arch armv8) + elseif(host_arch MATCHES "armv7|armv7-a|armv7l|ARMV7") + set(_arch armv7) + elseif(host_arch MATCHES armv7s) + set(_arch armv7s) + elseif(host_arch MATCHES "i686|i386|X86") + set(_arch x86) + elseif(host_arch MATCHES "AMD64|amd64|x86_64|x64") + set(_arch x86_64) + endif() + if(EMSCRIPTEN) + # https://github.com/emscripten-core/emscripten/blob/4.0.6/cmake/Modules/Platform/Emscripten.cmake#L294C1-L294C80 + set(_arch wasm) + endif() + message(STATUS "CMake-Conan: cmake_system_processor=${_arch}") + set(${arch} ${_arch} PARENT_SCOPE) +endfunction() + + +function(detect_cxx_standard compiler cxx_standard) + set(${cxx_standard} ${CMAKE_CXX_STANDARD} PARENT_SCOPE) + if(CMAKE_CXX_EXTENSIONS) + if(compiler STREQUAL "msvc") + set(${cxx_standard} "${CMAKE_CXX_STANDARD}" PARENT_SCOPE) + else() + set(${cxx_standard} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE) + endif() + endif() +endfunction() + + +macro(detect_gnu_libstdcxx) + # _conan_is_gnu_libstdcxx true if GNU libstdc++ + check_cxx_source_compiles(" + #include + #if !defined(__GLIBCXX__) && !defined(__GLIBCPP__) + static_assert(false); + #endif + int main(){}" _conan_is_gnu_libstdcxx) + + # _conan_gnu_libstdcxx_is_cxx11_abi true if C++11 ABI + check_cxx_source_compiles(" + #include + static_assert(sizeof(std::string) != sizeof(void*), \"using libstdc++\"); + int main () {}" _conan_gnu_libstdcxx_is_cxx11_abi) + + set(_conan_gnu_libstdcxx_suffix "") + if(_conan_gnu_libstdcxx_is_cxx11_abi) + set(_conan_gnu_libstdcxx_suffix "11") + endif() + unset (_conan_gnu_libstdcxx_is_cxx11_abi) +endmacro() + + +macro(detect_libcxx) + # _conan_is_libcxx true if LLVM libc++ + check_cxx_source_compiles(" + #include + #if !defined(_LIBCPP_VERSION) + static_assert(false); + #endif + int main(){}" _conan_is_libcxx) +endmacro() + + +function(detect_lib_cxx lib_cxx) + if(CMAKE_SYSTEM_NAME STREQUAL "Android") + message(STATUS "CMake-Conan: android_stl=${CMAKE_ANDROID_STL_TYPE}") + set(${lib_cxx} ${CMAKE_ANDROID_STL_TYPE} PARENT_SCOPE) + return() + endif() + + include(CheckCXXSourceCompiles) + + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + detect_gnu_libstdcxx() + set(${lib_cxx} "libstdc++${_conan_gnu_libstdcxx_suffix}" PARENT_SCOPE) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") + set(${lib_cxx} "libc++" PARENT_SCOPE) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows") + # Check for libc++ + detect_libcxx() + if(_conan_is_libcxx) + set(${lib_cxx} "libc++" PARENT_SCOPE) + return() + endif() + + # Check for libstdc++ + detect_gnu_libstdcxx() + if(_conan_is_gnu_libstdcxx) + set(${lib_cxx} "libstdc++${_conan_gnu_libstdcxx_suffix}" PARENT_SCOPE) + return() + endif() + + # TODO: it would be an error if we reach this point + elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + # Do nothing - compiler.runtime and compiler.runtime_type + # should be handled separately: https://github.com/conan-io/cmake-conan/pull/516 + return() + else() + # TODO: unable to determine, ask user to provide a full profile file instead + endif() +endfunction() + + +function(detect_compiler compiler compiler_version compiler_runtime compiler_runtime_type) + if(DEFINED CMAKE_CXX_COMPILER_ID) + set(_compiler ${CMAKE_CXX_COMPILER_ID}) + set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION}) + else() + if(NOT DEFINED CMAKE_C_COMPILER_ID) + message(FATAL_ERROR "C or C++ compiler not defined") + endif() + set(_compiler ${CMAKE_C_COMPILER_ID}) + set(_compiler_version ${CMAKE_C_COMPILER_VERSION}) + endif() + + message(STATUS "CMake-Conan: CMake compiler=${_compiler}") + message(STATUS "CMake-Conan: CMake compiler version=${_compiler_version}") + + if(_compiler MATCHES MSVC) + set(_compiler "msvc") + string(SUBSTRING ${MSVC_VERSION} 0 3 _compiler_version) + # Configure compiler.runtime and compiler.runtime_type settings for MSVC + if(CMAKE_MSVC_RUNTIME_LIBRARY) + set(_msvc_runtime_library ${CMAKE_MSVC_RUNTIME_LIBRARY}) + else() + set(_msvc_runtime_library MultiThreaded$<$:Debug>DLL) # default value documented by CMake + endif() + + set(_KNOWN_MSVC_RUNTIME_VALUES "") + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded MultiThreadedDLL) + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreadedDebug MultiThreadedDebugDLL) + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded$<$:Debug> MultiThreaded$<$:Debug>DLL) + + # only accept the 6 possible values, otherwise we don't don't know to map this + if(NOT _msvc_runtime_library IN_LIST _KNOWN_MSVC_RUNTIME_VALUES) + message(FATAL_ERROR "CMake-Conan: unable to map MSVC runtime: ${_msvc_runtime_library} to Conan settings") + endif() + + # Runtime is "dynamic" in all cases if it ends in DLL + if(_msvc_runtime_library MATCHES ".*DLL$") + set(_compiler_runtime "dynamic") + else() + set(_compiler_runtime "static") + endif() + message(STATUS "CMake-Conan: CMake compiler.runtime=${_compiler_runtime}") + + # Only define compiler.runtime_type when explicitly requested + # If a generator expression is used, let Conan handle it conditional on build_type + if(NOT _msvc_runtime_library MATCHES ":Debug>") + if(_msvc_runtime_library MATCHES "Debug") + set(_compiler_runtime_type "Debug") + else() + set(_compiler_runtime_type "Release") + endif() + message(STATUS "CMake-Conan: CMake compiler.runtime_type=${_compiler_runtime_type}") + endif() + + unset(_KNOWN_MSVC_RUNTIME_VALUES) + + elseif(_compiler MATCHES AppleClang) + set(_compiler "apple-clang") + string(REPLACE "." ";" VERSION_LIST ${_compiler_version}) + list(GET VERSION_LIST 0 _compiler_version) + elseif(_compiler MATCHES Clang) + set(_compiler "clang") + string(REPLACE "." ";" VERSION_LIST ${_compiler_version}) + list(GET VERSION_LIST 0 _compiler_version) + elseif(_compiler MATCHES GNU) + set(_compiler "gcc") + string(REPLACE "." ";" VERSION_LIST ${_compiler_version}) + list(GET VERSION_LIST 0 _compiler_version) + endif() + + message(STATUS "CMake-Conan: [settings] compiler=${_compiler}") + message(STATUS "CMake-Conan: [settings] compiler.version=${_compiler_version}") + if (_compiler_runtime) + message(STATUS "CMake-Conan: [settings] compiler.runtime=${_compiler_runtime}") + endif() + if (_compiler_runtime_type) + message(STATUS "CMake-Conan: [settings] compiler.runtime_type=${_compiler_runtime_type}") + endif() + + set(${compiler} ${_compiler} PARENT_SCOPE) + set(${compiler_version} ${_compiler_version} PARENT_SCOPE) + set(${compiler_runtime} ${_compiler_runtime} PARENT_SCOPE) + set(${compiler_runtime_type} ${_compiler_runtime_type} PARENT_SCOPE) +endfunction() + + +function(detect_build_type build_type) + get_property(multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(NOT multiconfig_generator) + # Only set when we know we are in a single-configuration generator + # Note: we may want to fail early if `CMAKE_BUILD_TYPE` is not defined + set(${build_type} ${CMAKE_BUILD_TYPE} PARENT_SCOPE) + endif() +endfunction() + + +macro(set_conan_compiler_if_appleclang lang command output_variable) + if(CMAKE_${lang}_COMPILER_ID STREQUAL "AppleClang") + execute_process(COMMAND xcrun --find ${command} + OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE) + cmake_path(GET _xcrun_out PARENT_PATH _xcrun_toolchain_path) + cmake_path(GET CMAKE_${lang}_COMPILER PARENT_PATH _compiler_parent_path) + if ("${_xcrun_toolchain_path}" STREQUAL "${_compiler_parent_path}") + set(${output_variable} "") + endif() + unset(_xcrun_out) + unset(_xcrun_toolchain_path) + unset(_compiler_parent_path) + endif() +endmacro() + + +macro(append_compiler_executables_configuration) + set(_conan_c_compiler "") + set(_conan_cpp_compiler "") + set(_conan_rc_compiler "") + set(_conan_compilers_list "") + if(CMAKE_C_COMPILER) + set(_conan_c_compiler "\"c\":\"${CMAKE_C_COMPILER}\"") + set_conan_compiler_if_appleclang(C cc _conan_c_compiler) + list(APPEND _conan_compilers_list ${_conan_c_compiler}) + else() + message(WARNING "CMake-Conan: The C compiler is not defined. " + "Please define CMAKE_C_COMPILER or enable the C language.") + endif() + if(CMAKE_CXX_COMPILER) + set(_conan_cpp_compiler "\"cpp\":\"${CMAKE_CXX_COMPILER}\"") + set_conan_compiler_if_appleclang(CXX c++ _conan_cpp_compiler) + list(APPEND _conan_compilers_list ${_conan_cpp_compiler}) + else() + message(WARNING "CMake-Conan: The C++ compiler is not defined. " + "Please define CMAKE_CXX_COMPILER or enable the C++ language.") + endif() + if(CMAKE_RC_COMPILER) + set(_conan_rc_compiler "\"rc\":\"${CMAKE_RC_COMPILER}\"") + list(APPEND _conan_compilers_list ${_conan_rc_compiler}) + # Not necessary to warn if RC not defined + endif() + if(NOT "x${_conan_compilers_list}" STREQUAL "x") + if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + string(REPLACE ";" "," _conan_compilers_list "${_conan_compilers_list}") + string(APPEND profile "tools.build:compiler_executables={${_conan_compilers_list}}\n") + endif() + endif() + unset(_conan_c_compiler) + unset(_conan_cpp_compiler) + unset(_conan_rc_compiler) + unset(_conan_compilers_list) +endmacro() + + +function(detect_host_profile output_file) + detect_os(os os_api_level os_sdk os_subsystem os_version) + detect_arch(arch) + detect_compiler(compiler compiler_version compiler_runtime compiler_runtime_type) + detect_cxx_standard(${compiler} compiler_cppstd) + detect_lib_cxx(compiler_libcxx) + detect_build_type(build_type) + + set(profile "") + string(APPEND profile "[settings]\n") + if(arch) + string(APPEND profile arch=${arch} "\n") + endif() + if(os) + string(APPEND profile os=${os} "\n") + endif() + if(os_api_level) + string(APPEND profile os.api_level=${os_api_level} "\n") + endif() + if(os_version) + string(APPEND profile os.version=${os_version} "\n") + endif() + if(os_sdk) + string(APPEND profile os.sdk=${os_sdk} "\n") + endif() + if(os_subsystem) + string(APPEND profile os.subsystem=${os_subsystem} "\n") + endif() + if(compiler) + string(APPEND profile compiler=${compiler} "\n") + endif() + if(compiler_version) + string(APPEND profile compiler.version=${compiler_version} "\n") + endif() + if(compiler_runtime) + string(APPEND profile compiler.runtime=${compiler_runtime} "\n") + endif() + if(compiler_runtime_type) + string(APPEND profile compiler.runtime_type=${compiler_runtime_type} "\n") + endif() + if(compiler_cppstd) + string(APPEND profile compiler.cppstd=${compiler_cppstd} "\n") + endif() + if(compiler_libcxx) + string(APPEND profile compiler.libcxx=${compiler_libcxx} "\n") + endif() + if(build_type) + string(APPEND profile "build_type=${build_type}\n") + endif() + + if(NOT DEFINED output_file) + set(file_name "${CMAKE_BINARY_DIR}/profile") + else() + set(file_name ${output_file}) + endif() + + string(APPEND profile "[conf]\n") + string(APPEND profile "tools.cmake.cmaketoolchain:generator=${CMAKE_GENERATOR}\n") + + # propagate compilers via profile + append_compiler_executables_configuration() + + if(os STREQUAL "Android") + string(APPEND profile "tools.android:ndk_path=${CMAKE_ANDROID_NDK}\n") + endif() + + message(STATUS "CMake-Conan: Creating profile ${file_name}") + file(WRITE ${file_name} ${profile}) + message(STATUS "CMake-Conan: Profile: \n${profile}") +endfunction() + + +function(conan_profile_detect_default) + message(STATUS "CMake-Conan: Checking if a default profile exists") + execute_process(COMMAND ${CONAN_COMMAND} profile path default + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + ECHO_OUTPUT_VARIABLE + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + if(NOT ${return_code} EQUAL "0") + message(STATUS "CMake-Conan: The default profile doesn't exist, detecting it.") + execute_process(COMMAND ${CONAN_COMMAND} profile detect + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + ECHO_OUTPUT_VARIABLE + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() +endfunction() + + +function(conan_install) + set(conan_output_folder ${CMAKE_BINARY_DIR}/conan) + # Invoke "conan install" with the provided arguments + set(conan_args -of=${conan_output_folder}) + list(JOIN ARGN " " argn_str) + message(STATUS "CMake-Conan: conan install ${CMAKE_SOURCE_DIR} ${conan_args} ${argn_str}") + + + # In case there was not a valid cmake executable in the PATH, we inject the + # same we used to invoke the provider to the PATH + if(DEFINED PATH_TO_CMAKE_BIN) + set(old_path $ENV{PATH}) + if(CMAKE_HOST_WIN32) + set(ENV{PATH} "$ENV{PATH};${PATH_TO_CMAKE_BIN}") + else() + set(ENV{PATH} "$ENV{PATH}:${PATH_TO_CMAKE_BIN}") + endif() + endif() + + execute_process(COMMAND ${CONAN_COMMAND} install ${CMAKE_SOURCE_DIR} ${conan_args} ${ARGN} --format=json + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + + if(DEFINED PATH_TO_CMAKE_BIN) + set(ENV{PATH} "${old_path}") + endif() + + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan install failed='${return_code}'") + endif() + + # the files are generated in a folder that depends on the layout used, if + # one is specified, but we don't know a priori where this is. + # TODO: this can be made more robust if Conan can provide this in the json output + string(JSON conan_generators_folder GET "${conan_stdout}" graph nodes 0 generators_folder) + cmake_path(CONVERT ${conan_generators_folder} TO_CMAKE_PATH_LIST conan_generators_folder) + + message(STATUS "CMake-Conan: CONAN_GENERATORS_FOLDER=${conan_generators_folder}") + set_property(GLOBAL PROPERTY CONAN_GENERATORS_FOLDER "${conan_generators_folder}") + # reconfigure on conanfile changes + string(JSON conanfile GET "${conan_stdout}" graph nodes 0 label) + message(STATUS "CMake-Conan: CONANFILE=${CMAKE_SOURCE_DIR}/${conanfile}") + set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/${conanfile}") + # success + set_property(GLOBAL PROPERTY CONAN_INSTALL_SUCCESS TRUE) + +endfunction() + + +function(conan_get_version conan_command conan_current_version) + execute_process( + COMMAND ${conan_command} --version + OUTPUT_VARIABLE conan_output + RESULT_VARIABLE conan_result + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(conan_result) + message(FATAL_ERROR "CMake-Conan: Error when trying to run Conan") + endif() + + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" conan_version ${conan_output}) + set(${conan_current_version} ${conan_version} PARENT_SCOPE) +endfunction() + + +function(conan_version_check) + set(options ) + set(one_value_args MINIMUM CURRENT) + set(multi_value_args ) + cmake_parse_arguments(conan_version_check + "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) + + if(NOT conan_version_check_MINIMUM) + message(FATAL_ERROR "CMake-Conan: Required parameter MINIMUM not set!") + endif() + if(NOT conan_version_check_CURRENT) + message(FATAL_ERROR "CMake-Conan: Required parameter CURRENT not set!") + endif() + + if(conan_version_check_CURRENT VERSION_LESS conan_version_check_MINIMUM) + message(FATAL_ERROR "CMake-Conan: Conan version must be ${conan_version_check_MINIMUM} or later") + endif() +endfunction() + + +macro(construct_profile_argument argument_variable profile_list) + set(${argument_variable} "") + if("${profile_list}" STREQUAL "CONAN_HOST_PROFILE") + set(_arg_flag "--profile:host=") + elseif("${profile_list}" STREQUAL "CONAN_BUILD_PROFILE") + set(_arg_flag "--profile:build=") + endif() + + set(_profile_list "${${profile_list}}") + list(TRANSFORM _profile_list REPLACE "auto-cmake" "${CMAKE_BINARY_DIR}/conan_host_profile") + list(TRANSFORM _profile_list PREPEND ${_arg_flag}) + set(${argument_variable} ${_profile_list}) + + unset(_arg_flag) + unset(_profile_list) +endmacro() + + +macro(conan_provide_dependency method package_name) + set_property(GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED TRUE) + get_property(_conan_install_success GLOBAL PROPERTY CONAN_INSTALL_SUCCESS) + if(NOT _conan_install_success) + find_program(CONAN_COMMAND "conan" REQUIRED) + conan_get_version("${CONAN_COMMAND}" CONAN_CURRENT_VERSION) + conan_version_check(MINIMUM ${CONAN_MINIMUM_VERSION} CURRENT ${CONAN_CURRENT_VERSION}) + message(STATUS "CMake-Conan: first find_package() found. Installing dependencies with Conan") + if("default" IN_LIST CONAN_HOST_PROFILE OR "default" IN_LIST CONAN_BUILD_PROFILE) + conan_profile_detect_default() + endif() + if("auto-cmake" IN_LIST CONAN_HOST_PROFILE) + detect_host_profile(${CMAKE_BINARY_DIR}/conan_host_profile) + endif() + construct_profile_argument(_host_profile_flags CONAN_HOST_PROFILE) + construct_profile_argument(_build_profile_flags CONAN_BUILD_PROFILE) + if(EXISTS "${CMAKE_SOURCE_DIR}/conanfile.py") + file(READ "${CMAKE_SOURCE_DIR}/conanfile.py" outfile) + if(NOT "${outfile}" MATCHES ".*CMakeConfigDeps.*") + message(WARNING "Cmake-conan: CMakeConfigDeps generator was not defined in the conanfile") + endif() + elseif (EXISTS "${CMAKE_SOURCE_DIR}/conanfile.txt") + file(READ "${CMAKE_SOURCE_DIR}/conanfile.txt" outfile) + if(NOT "${outfile}" MATCHES ".*CMakeConfigDeps.*") + message(WARNING "Cmake-conan: CMakeConfigDeps generator was not defined in the conanfile") + endif() + endif() + + get_property(_multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + + if(DEFINED CONAN_INSTALL_BUILD_CONFIGURATIONS) + # Configurations are specified by the project or user + set(_build_configs "${CONAN_INSTALL_BUILD_CONFIGURATIONS}") + list(LENGTH _build_configs _build_configs_length) + if(NOT _multiconfig_generator AND _build_configs_length GREATER 1) + message(FATAL_ERROR "cmake-conan: when using a single-config CMake generator, " + "please only specify a single configuration in CONAN_INSTALL_BUILD_CONFIGURATIONS") + endif() + unset(_build_configs_length) + else() + # No configuration overrides, provide sensible defaults + if(_multiconfig_generator) + set(_build_configs Release Debug) + else() + set(_build_configs ${CMAKE_BUILD_TYPE}) + endif() + + endif() + + list(JOIN _build_configs ", " _build_configs_msg) + message(STATUS "CMake-Conan: Installing configuration(s): ${_build_configs_msg}") + foreach(_build_config IN LISTS _build_configs) + set(_self_build_config "") + if(NOT _multiconfig_generator AND NOT _build_config STREQUAL "${CMAKE_BUILD_TYPE}") + set(_self_build_config -s &:build_type=${CMAKE_BUILD_TYPE}) + endif() + conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=${_build_config} ${_self_build_config} ${CONAN_INSTALL_ARGS}) + endforeach() + + get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER) + if(EXISTS "${_conan_generators_folder}/conan_cmakedeps_paths.cmake") + message(STATUS "CMake-Conan: Loading conan_cmakedeps_paths.cmake file") + include(${_conan_generators_folder}/conan_cmakedeps_paths.cmake) + endif() + + unset(_self_build_config) + unset(_multiconfig_generator) + unset(_build_configs) + unset(_build_configs_msg) + unset(_host_profile_flags) + unset(_build_profile_flags) + unset(_conan_install_success) + else() + message(STATUS "CMake-Conan: find_package(${ARGV1}) found, 'conan install' already ran") + unset(_conan_install_success) + endif() + + get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER) + + # Ensure that we consider Conan-provided packages ahead of any other, + # irrespective of other settings that modify the search order or search paths + # This follows the guidelines from the find_package documentation + # (https://cmake.org/cmake/help/latest/command/find_package.html): + # find_package ( PATHS paths... NO_DEFAULT_PATH) + # find_package () + + # Filter out `REQUIRED` from the argument list, as the first call may fail + set(_find_args_${package_name} "${ARGN}") + list(REMOVE_ITEM _find_args_${package_name} "REQUIRED") + if(NOT "MODULE" IN_LIST _find_args_${package_name}) + find_package(${package_name} ${_find_args_${package_name}} BYPASS_PROVIDER PATHS "${_conan_generators_folder}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + unset(_find_args_${package_name}) + endif() + + # Invoke find_package a second time - if the first call succeeded, + # this will simply reuse the result. If not, fall back to CMake default search + # behaviour, also allowing modules to be searched. + if(NOT ${package_name}_FOUND) + list(FIND CMAKE_MODULE_PATH "${_conan_generators_folder}" _index) + if(_index EQUAL -1) + list(PREPEND CMAKE_MODULE_PATH "${_conan_generators_folder}") + endif() + unset(_index) + find_package(${package_name} ${ARGN} BYPASS_PROVIDER) + list(REMOVE_ITEM CMAKE_MODULE_PATH "${_conan_generators_folder}") + endif() +endmacro() + + +cmake_language( + SET_DEPENDENCY_PROVIDER conan_provide_dependency + SUPPORTED_METHODS FIND_PACKAGE +) + + +macro(conan_provide_dependency_check) + set(_conan_provide_dependency_invoked FALSE) + get_property(_conan_provide_dependency_invoked GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED) + if(NOT _conan_provide_dependency_invoked) + message(WARNING "Conan is correctly configured as dependency provider, " + "but Conan has not been invoked. Please add at least one " + "call to `find_package()`.") + if(DEFINED CONAN_COMMAND) + # supress warning in case `CONAN_COMMAND` was specified but unused. + set(_conan_command ${CONAN_COMMAND}) + unset(_conan_command) + endif() + endif() + unset(_conan_provide_dependency_invoked) +endmacro() + + +# Add a deferred call at the end of processing the top-level directory +# to check if the dependency provider was invoked at all. +cmake_language(DEFER DIRECTORY "${CMAKE_SOURCE_DIR}" CALL conan_provide_dependency_check) + +# Configurable variables for Conan profiles +set(CONAN_HOST_PROFILE "default;auto-cmake" CACHE STRING "Conan host profile") +set(CONAN_BUILD_PROFILE "default" CACHE STRING "Conan build profile") +set(CONAN_INSTALL_ARGS "--build=missing" CACHE STRING "Command line arguments for conan install") + +find_program(_cmake_program NAMES cmake NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) +if(NOT _cmake_program) + get_filename_component(PATH_TO_CMAKE_BIN "${CMAKE_COMMAND}" DIRECTORY) + set(PATH_TO_CMAKE_BIN "${PATH_TO_CMAKE_BIN}" CACHE INTERNAL "Path where the CMake executable is") +endif() + +cmake_policy(POP) diff --git a/cpp/cmake/dependencies.cpm.cmake b/cpp/cmake/dependencies.cpm.cmake deleted file mode 100644 index d6c08cdd..00000000 --- a/cpp/cmake/dependencies.cpm.cmake +++ /dev/null @@ -1,76 +0,0 @@ -# renovate: datasource=github-tags packageName=cpm-cmake/CPM.cmake versioning=semver -set(CPM_DOWNLOAD_TAG_DIGEST v0.43.1 456cb6754daaa010d57444d0c8ce6d95ecf006ab) -# renovate: datasource=github-tags packageName=cucumber/messages versioning=semver -set(CUCUMBER_MESSAGES_TAG_DIGEST v34.0.2 01e84523a5cbdb4a3a4e10e3ba53cb7a64a97964) -# renovate: datasource=github-tags packageName=google/googletest versioning=semver -set(GOOGLE_TEST_TAG_DIGEST v1.17.0 52eb8108c5bdec04579160ae17225d66034bd723) - -list(GET CPM_DOWNLOAD_TAG_DIGEST 0 CPM_DOWNLOAD_TAG) -list(GET CPM_DOWNLOAD_TAG_DIGEST 1 CPM_DOWNLOAD_DIGEST) -string(SUBSTRING "${CPM_DOWNLOAD_TAG}" 1 -1 CPM_DOWNLOAD_VERSION) - -list(GET CUCUMBER_MESSAGES_TAG_DIGEST 0 CUCUMBER_MESSAGES_TAG) -list(GET CUCUMBER_MESSAGES_TAG_DIGEST 1 CUCUMBER_MESSAGES_DIGEST) -string(SUBSTRING "${CUCUMBER_MESSAGES_TAG}" 1 -1 CUCUMBER_MESSAGES_VERSION) - -list(GET GOOGLE_TEST_TAG_DIGEST 0 GOOGLE_TEST_TAG) -list(GET GOOGLE_TEST_TAG_DIGEST 1 GOOGLE_TEST_DIGEST) -string(SUBSTRING "${GOOGLE_TEST_TAG}" 1 -1 GOOGLE_TEST_VERSION) - -if(CUCUMBER_QUERY_FETCH_DEPS) - if(NOT COMMAND CPMAddPackage) - # --------------------------------------------------------------------------- - # CPM – download on first configure if not already cached (standalone only) - # --------------------------------------------------------------------------- - set(CPM_USE_LOCAL_PACKAGES ON) - set(CPM_DOWNLOAD_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") - - if(NOT EXISTS "${CPM_DOWNLOAD_LOCATION}") - message(STATUS "Downloading CPM.cmake ${CPM_DOWNLOAD_VERSION}…") - file(DOWNLOAD - "https://github.com/cpm-cmake/CPM.cmake/releases/download/${CPM_DOWNLOAD_TAG}/CPM.cmake" - "${CPM_DOWNLOAD_LOCATION}" - TLS_VERIFY ON - ) - endif() - - include("${CPM_DOWNLOAD_LOCATION}") - endif() - - # --------------------------------------------------------------------------- - # Dependencies - # --------------------------------------------------------------------------- - CPMAddPackage( - URI "gh:cucumber/messages@${CUCUMBER_MESSAGES_VERSION}#${CUCUMBER_MESSAGES_DIGEST}" - NAME cucumber_messages - SOURCE_SUBDIR cpp - OPTIONS - "CUCUMBER_MESSAGES_FETCH_DEPS ON" - ) - - if(cucumber_messages_ADDED) - # Propagate cucumber_messages install rules so 'cmake --install' also installs it - install(SCRIPT "${cucumber_messages_BINARY_DIR}/cmake_install.cmake") - endif() - - if(CUCUMBER_QUERY_BUILD_TESTS) - CPMAddPackage( - URI "gh:google/googletest@${GOOGLE_TEST_VERSION}#${GOOGLE_TEST_DIGEST}" - NAME googletest - OPTIONS - "INSTALL_GTEST OFF" - "gtest_force_shared_crt ON" - ) - - set_target_properties(gtest gtest_main gmock gmock_main PROPERTIES - FOLDER External/GoogleTest - ) - endif() - -else() - find_package(cucumber_messages ${CUCUMBER_MESSAGES_VERSION} REQUIRED) - - if (CUCUMBER_QUERY_BUILD_TESTS) - find_package(GTest ${GOOGLE_TEST_VERSION} REQUIRED) - endif() -endif() diff --git a/cpp/conanfile.py b/cpp/conanfile.py new file mode 100644 index 00000000..8780ede2 --- /dev/null +++ b/cpp/conanfile.py @@ -0,0 +1,91 @@ +from conan import ConanFile +from conan.tools.build import can_run, check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +import os + +class CucumberQuery(ConanFile): + name = "cucumber_query" + version = "0.1.0" + package_type = "library" + + license = "MIT" + url = "https://github.com/cucumber/query" + homepage = "https://github.com/cucumber/query" + description = "Cucumber Query for C++" + topics = ("cucumber", "query", "bdd", "json") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def set_version(self): + version_file = os.path.join(self.recipe_folder, "VERSION") + if os.path.exists(version_file): + with open(version_file, "r", encoding="utf-8") as f: + self.version = f.readline().strip() + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def _build_tests(self): + # Unit tests read the repo-root testdata/ folder, which is not part of + # the exported package, so only build them when that folder is present. + if self.conf.get("tools.build:skip_test", default=False): + return False + return os.path.isdir(os.path.join(self.source_folder, os.pardir, "testdata")) + + def requirements(self): + self.requires("nlohmann_json/3.12.0") + self.requires("cucumber_messages/34.2.1") + + def build_requirements(self): + if not self.conf.get("tools.build:skip_test", default=False): + self.test_requires("gtest/1.17.0") + + def validate(self): + check_min_cppstd(self, 17) + + def layout(self): + cmake_layout(self) + + def generate(self): + cmake_deps = CMakeDeps(self) + cmake_deps.generate() + + cmake_toolchain = CMakeToolchain(self) + cmake_toolchain.user_presets_path = False + cmake_toolchain.cache_variables["CUCUMBER_QUERY_BUILD_TESTS"] = self._build_tests() + cmake_toolchain.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + if self._build_tests() and can_run(self): + cmake.ctest() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "cucumber_query") + self.cpp_info.set_property("cmake_target_name", "cucumber::query") + self.cpp_info.libs = ["cucumber_query"] + + + exports_sources = ( + "cmake/*", + "include/*", + "src/*", + "CMakeLists.txt", + "README.md", + "VERSION", + ) From bf7aba280ffaf05b52322c40f45b38d9a2684a29 Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 21 Aug 2026 06:54:19 +0000 Subject: [PATCH 51/56] Add ToJson utility function for optional values and update JSON serialization in tests --- cpp/test/TestQuery.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cpp/test/TestQuery.cpp b/cpp/test/TestQuery.cpp index 5c0272ef..b7eb6b5e 100644 --- a/cpp/test/TestQuery.cpp +++ b/cpp/test/TestQuery.cpp @@ -30,6 +30,12 @@ namespace cucumber::query return value.size() >= suffix.size() && value.compare(value.size() - suffix.size(), suffix.size(), suffix) == 0; } + template + auto ToJson(const std::optional& value) -> nlohmann::json + { + return value.has_value() ? nlohmann::json(*value) : nlohmann::json(nullptr); + } + struct Expectation { std::string_view infix; @@ -307,7 +313,7 @@ namespace cucumber::query for (const auto& attachment : attachments) { - actual["testStepFinished"].push_back({ attachment->testStepId, attachment->testCaseStartedId, attachment->mediaType, attachment->contentEncoding }); + actual["testStepFinished"].push_back({ ToJson(attachment->testStepId), ToJson(attachment->testCaseStartedId), attachment->mediaType, attachment->contentEncoding }); } } } @@ -319,7 +325,7 @@ namespace cucumber::query for (const auto& attachment : attachments) { - actual["testRunHookFinished"].push_back({ attachment->testRunHookStartedId, attachment->mediaType, attachment->contentEncoding }); + actual["testRunHookFinished"].push_back({ ToJson(attachment->testRunHookStartedId), attachment->mediaType, attachment->contentEncoding }); } } @@ -392,7 +398,7 @@ namespace cucumber::query const auto location = query.FindLocationOf(pickle); if (location.has_value()) { - actual.push_back({ { "line", location.value()->line }, { "column", location.value()->column } }); + actual.push_back({ { "line", location.value()->line }, { "column", ToJson(location.value()->column) } }); } } From 75e149c6f2af142e54e234188db8b3b2936ae64c Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 21 Aug 2026 08:34:21 +0000 Subject: [PATCH 52/56] Update CMake configuration and ignore compile_commands.json - Change CompilationDatabase path in .clangd to current directory - Add compile_commands.json to .gitignore - Create custom target for clangd compile commands in CMakeLists.txt - Update find_package for nlohmann_json and cucumber_messages --- cpp/.clangd | 2 +- cpp/.gitignore | 1 + cpp/CMakeLists.txt | 16 ++++++++++++++-- cpp/test/CMakeLists.txt | 4 ++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/cpp/.clangd b/cpp/.clangd index 5daeaa58..ae388a6f 100644 --- a/cpp/.clangd +++ b/cpp/.clangd @@ -1,6 +1,6 @@ --- CompileFlags: - CompilationDatabase: ~/.cpp/compile_commands.json + CompilationDatabase: . Diagnostics: UnusedIncludes: Strict MissingIncludes: Strict diff --git a/cpp/.gitignore b/cpp/.gitignore index bcdff71f..6508b2fc 100644 --- a/cpp/.gitignore +++ b/cpp/.gitignore @@ -1,2 +1,3 @@ build install +compile_commands.json diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 8d5b4bb7..dce36919 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -24,6 +24,15 @@ if (POLICY CMP0077) cmake_policy(SET CMP0077 NEW) endif () +set(CMAKE_EXPORT_COMPILE_COMMANDS On) +if(PROJECT_IS_TOP_LEVEL AND CMAKE_EXPORT_COMPILE_COMMANDS) + add_custom_target(clangd_compile_commands ALL + COMMAND "${CMAKE_COMMAND}" -E copy_if_different + "${CMAKE_BINARY_DIR}/compile_commands.json" + "${CMAKE_SOURCE_DIR}/compile_commands.json" + VERBATIM) +endif() + option(CUCUMBER_QUERY_BUILD_TESTS "Build the unit tests." Off) option(CUCUMBER_QUERY_ENABLE_CLANG_TIDY "Run clang-tidy as part of the build." Off) option(CUCUMBER_QUERY_ENABLE_COVERAGE "Enable compiler flags for code coverage measurements." Off) @@ -78,8 +87,11 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") endif() # CMake dependencies -find_package(nlohmann_json 3.11 REQUIRED) -find_package(cucumber_messages 34.2.1 REQUIRED) +find_package(nlohmann_json REQUIRED) +find_package(cucumber_messages QUIET) +if (NOT cucumber_messages_FOUND AND NOT TARGET cucumber::messages) + message(FATAL_ERROR "cucumber::messages not found") +endif() # Target options if(CUCUMBER_QUERY_ENABLE_CLANG_TIDY) diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index 0c6decd7..de57ecf5 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(cucumber_query_lib.test target_compile_definitions(cucumber_query_lib.test PRIVATE - TESTDATA_SRC="${CMAKE_SOURCE_DIR}/../testdata/src" + TESTDATA_SRC="${PROJECT_SOURCE_DIR}/../testdata/src" ) include(GoogleTest) @@ -23,7 +23,7 @@ add_custom_target( check-testdata-coverage COMMAND ${CMAKE_COMMAND} -DTEST_BINARY=$ - -DTESTDATA_SRC=${CMAKE_SOURCE_DIR}/../testdata/src + -DTESTDATA_SRC=${PROJECT_SOURCE_DIR}/../testdata/src -P ${CMAKE_CURRENT_SOURCE_DIR}/CheckTestdataCoverage.cmake DEPENDS cucumber_query_lib.test COMMENT "Checking testdata coverage in C++ tests" From 528e22579de18199ad381424be25ae372f80074c Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 21 Aug 2026 09:12:45 +0000 Subject: [PATCH 53/56] Update CMakePresets.json to set build type to Debug for host-system and host-conan presets --- cpp/CMakePresets.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/CMakePresets.json b/cpp/CMakePresets.json index 39212082..273a7cbb 100644 --- a/cpp/CMakePresets.json +++ b/cpp/CMakePresets.json @@ -20,7 +20,7 @@ "description": "Build and install the library using C++ dependencies already installed on the system. Does not use Conan and does not build tests.", "inherits": "base", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" + "CMAKE_BUILD_TYPE": "Debug" } }, { @@ -41,7 +41,7 @@ "inherits": "base", "cacheVariables": { "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "${sourceDir}/cmake/conan_provider.cmake", - "CMAKE_BUILD_TYPE": "Release", + "CMAKE_BUILD_TYPE": "Debug", "CONAN_INSTALL_ARGS": "--build=missing" } }, From 2d432352bb6d82c4092ce8b33f280149b1f7fcea Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Fri, 21 Aug 2026 09:15:03 +0000 Subject: [PATCH 54/56] Update MESSAGES_REF in workflow files to match the latest dependency version --- .github/workflows/codeql-cpp.yaml | 18 ++++++++---------- .github/workflows/test-cpp.yaml | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/codeql-cpp.yaml b/.github/workflows/codeql-cpp.yaml index d1d5f33f..98310da9 100644 --- a/.github/workflows/codeql-cpp.yaml +++ b/.github/workflows/codeql-cpp.yaml @@ -32,17 +32,22 @@ jobs: permissions: security-events: write env: - CCACHE_BASEDIR: ${{ github.workspace }} - CCACHE_DIR: ${{ github.workspace }}/.ccache # Git ref (tag, branch, or SHA) of the cucumber_messages dependency to # build against. Must match the version required in cpp/CMakeLists.txt and # cpp/conanfile.py, or the messages branch under test. - MESSAGES_REF: eebd9f2f48ae94e0ada14ab01d53e1ecaaecb172 + MESSAGES_REF: 8cd6cacecd0a657095c93b069c850f51009e0499 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + - name: ccache + uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 + with: + key: ${{ github.job }}-${{ github.ref }} + append-timestamp: false + save: ${{ github.ref == 'refs/heads/main' }} + - name: Checkout cucumber/messages uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -56,13 +61,6 @@ jobs: sudo apt-get update sudo apt-get install -y ccache nlohmann-json3-dev - - name: Cache ccache - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ github.job }}-${{ github.ref }} - restore-keys: ccache-${{ github.job }}- - - name: Build and install cucumber_messages working-directory: messages-src/cpp run: | diff --git a/.github/workflows/test-cpp.yaml b/.github/workflows/test-cpp.yaml index 76836b12..8ef5ec41 100644 --- a/.github/workflows/test-cpp.yaml +++ b/.github/workflows/test-cpp.yaml @@ -22,7 +22,7 @@ env: # against. For releases use a tag matching the version required in # cpp/CMakeLists.txt (find_package) and cpp/conanfile.py; for cross-repo # feature work, set this to the messages branch under test. - MESSAGES_REF: eebd9f2f48ae94e0ada14ab01d53e1ecaaecb172 + MESSAGES_REF: 8cd6cacecd0a657095c93b069c850f51009e0499 jobs: test-cpp-system-packages-linux: From ee1f3e6a16091f24317bd5f9d00dfaf179a9843a Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 22 Aug 2026 23:03:05 +0000 Subject: [PATCH 55/56] fix private include directory --- cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index dce36919..7f8cab2c 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -139,7 +139,7 @@ target_include_directories( $ $ PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/src/messages + ${CMAKE_CURRENT_LIST_DIR}/src/query ) target_link_libraries( From 0c191422f6168a5d7a76fa2b6a283df9c14b88de Mon Sep 17 00:00:00 2001 From: "Timmer, Daan" Date: Sat, 22 Aug 2026 23:45:08 +0000 Subject: [PATCH 56/56] Remove clangd and supporting code --- cpp/.clangd | 13 - cpp/.gitignore | 2 - cpp/CMakeLists.txt | 9 - cpp/compile_commands.json | 578 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 578 insertions(+), 24 deletions(-) delete mode 100644 cpp/.clangd create mode 100644 cpp/compile_commands.json diff --git a/cpp/.clangd b/cpp/.clangd deleted file mode 100644 index ae388a6f..00000000 --- a/cpp/.clangd +++ /dev/null @@ -1,13 +0,0 @@ ---- -CompileFlags: - CompilationDatabase: . -Diagnostics: - UnusedIncludes: Strict - MissingIncludes: Strict - ClangTidy: - Add: [] - Remove: [] -InlayHints: - Enabled: Yes - ParameterNames: No - DeducedTypes: No diff --git a/cpp/.gitignore b/cpp/.gitignore index 6508b2fc..378eac25 100644 --- a/cpp/.gitignore +++ b/cpp/.gitignore @@ -1,3 +1 @@ build -install -compile_commands.json diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 7f8cab2c..cf1d00c9 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -24,15 +24,6 @@ if (POLICY CMP0077) cmake_policy(SET CMP0077 NEW) endif () -set(CMAKE_EXPORT_COMPILE_COMMANDS On) -if(PROJECT_IS_TOP_LEVEL AND CMAKE_EXPORT_COMPILE_COMMANDS) - add_custom_target(clangd_compile_commands ALL - COMMAND "${CMAKE_COMMAND}" -E copy_if_different - "${CMAKE_BINARY_DIR}/compile_commands.json" - "${CMAKE_SOURCE_DIR}/compile_commands.json" - VERBATIM) -endif() - option(CUCUMBER_QUERY_BUILD_TESTS "Build the unit tests." Off) option(CUCUMBER_QUERY_ENABLE_CLANG_TIDY "Run clang-tidy as part of the build." Off) option(CUCUMBER_QUERY_ENABLE_COVERAGE "Enable compiler flags for code coverage measurements." Off) diff --git a/cpp/compile_commands.json b/cpp/compile_commands.json new file mode 100644 index 00000000..57dcfbbd --- /dev/null +++ b/cpp/compile_commands.json @@ -0,0 +1,578 @@ +[ +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Attachment.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Attachment.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Attachment.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Attachment.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/AttachmentContentEncoding.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/AttachmentContentEncoding.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/AttachmentContentEncoding.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/AttachmentContentEncoding.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Background.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Background.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Background.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Background.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Ci.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Ci.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Ci.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Ci.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Comment.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Comment.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Comment.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Comment.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/DataTable.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/DataTable.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/DataTable.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/DataTable.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/DocString.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/DocString.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/DocString.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/DocString.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Duration.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Duration.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Duration.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Duration.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Envelope.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Envelope.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Envelope.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Envelope.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Examples.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Examples.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Examples.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Examples.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Exception.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Exception.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Exception.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Exception.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/ExternalAttachment.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/ExternalAttachment.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/ExternalAttachment.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/ExternalAttachment.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Feature.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Feature.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Feature.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Feature.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/FeatureChild.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/FeatureChild.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/FeatureChild.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/FeatureChild.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/GherkinDocument.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/GherkinDocument.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/GherkinDocument.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/GherkinDocument.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Git.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Git.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Git.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Git.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Group.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Group.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Group.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Group.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Hook.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Hook.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Hook.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Hook.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/HookType.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/HookType.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/HookType.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/HookType.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/JavaMethod.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/JavaMethod.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/JavaMethod.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/JavaMethod.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/JavaStackTraceElement.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/JavaStackTraceElement.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/JavaStackTraceElement.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/JavaStackTraceElement.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Location.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Location.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Location.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Location.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Meta.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Meta.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Meta.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Meta.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/ParameterType.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/ParameterType.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/ParameterType.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/ParameterType.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/ParseError.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/ParseError.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/ParseError.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/ParseError.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Pickle.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Pickle.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Pickle.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Pickle.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleDocString.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleDocString.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleDocString.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleDocString.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleStep.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleStep.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleStep.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleStep.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleStepArgument.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleStepArgument.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleStepArgument.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleStepArgument.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleStepType.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleStepType.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleStepType.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleStepType.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleTable.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleTable.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleTable.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleTable.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleTableCell.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleTableCell.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleTableCell.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleTableCell.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleTableRow.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleTableRow.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleTableRow.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleTableRow.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleTag.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleTag.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/PickleTag.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/PickleTag.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Product.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Product.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Product.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Product.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Rule.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Rule.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Rule.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Rule.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/RuleChild.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/RuleChild.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/RuleChild.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/RuleChild.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Scenario.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Scenario.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Scenario.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Scenario.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Snippet.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Snippet.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Snippet.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Snippet.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Source.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Source.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Source.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Source.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/SourceMediaType.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/SourceMediaType.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/SourceMediaType.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/SourceMediaType.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/SourceReference.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/SourceReference.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/SourceReference.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/SourceReference.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Step.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Step.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Step.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Step.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepDefinition.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepDefinition.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepDefinition.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepDefinition.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepDefinitionPattern.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepDefinitionPattern.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepDefinitionPattern.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepDefinitionPattern.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepDefinitionPatternType.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepDefinitionPatternType.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepDefinitionPatternType.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepDefinitionPatternType.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepKeywordType.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepKeywordType.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepKeywordType.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepKeywordType.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepMatchArgument.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepMatchArgument.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepMatchArgument.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepMatchArgument.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepMatchArgumentsList.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepMatchArgumentsList.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/StepMatchArgumentsList.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/StepMatchArgumentsList.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Suggestion.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Suggestion.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Suggestion.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Suggestion.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TableCell.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TableCell.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TableCell.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TableCell.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TableRow.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TableRow.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TableRow.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TableRow.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Tag.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Tag.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Tag.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Tag.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestCase.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestCase.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestCase.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestCase.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestCaseFinished.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestCaseFinished.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestCaseFinished.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestCaseFinished.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestCaseStarted.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestCaseStarted.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestCaseStarted.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestCaseStarted.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestRunFinished.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestRunFinished.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestRunFinished.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestRunFinished.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestRunHookFinished.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestRunHookFinished.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestRunHookFinished.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestRunHookFinished.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestRunHookStarted.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestRunHookStarted.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestRunHookStarted.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestRunHookStarted.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestRunStarted.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestRunStarted.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestRunStarted.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestRunStarted.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestStep.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestStep.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestStep.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestStep.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestStepFinished.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestStepFinished.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestStepFinished.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestStepFinished.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestStepResult.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestStepResult.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestStepResult.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestStepResult.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestStepResultStatus.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestStepResultStatus.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestStepResultStatus.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestStepResultStatus.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestStepStarted.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestStepStarted.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/TestStepStarted.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/TestStepStarted.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Timestamp.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Timestamp.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/Timestamp.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/Timestamp.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/UndefinedParameterType.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/UndefinedParameterType.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/generated/cucumber/messages/UndefinedParameterType.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/generated/cucumber/messages/UndefinedParameterType.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -I/workspaces/cucumber-cpp-development/messages/cpp/src/messages -O3 -DNDEBUG -std=c++17 -o messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/messages/cucumber/messages/DurationUtil.cpp.o -c /workspaces/cucumber-cpp-development/messages/cpp/src/messages/cucumber/messages/DurationUtil.cpp", + "file": "/workspaces/cucumber-cpp-development/messages/cpp/src/messages/cucumber/messages/DurationUtil.cpp", + "output": "messages/cpp/CMakeFiles/cucumber_messages_lib.dir/src/messages/cucumber/messages/DurationUtil.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/App.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/App.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/App.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/App.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/AstBuilder.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/AstBuilder.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/AstBuilder.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/AstBuilder.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/AstNode.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/AstNode.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/AstNode.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/AstNode.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Demangle.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Demangle.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Demangle.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Demangle.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Dialect.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Dialect.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Dialect.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Dialect.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Exceptions.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Exceptions.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Exceptions.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Exceptions.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/IdGenerator.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/IdGenerator.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/IdGenerator.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/IdGenerator.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Keywords.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Keywords.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Keywords.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Keywords.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Line.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Line.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Line.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Line.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/ParseError.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/ParseError.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/ParseError.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/ParseError.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/PickleCompiler.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/PickleCompiler.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/PickleCompiler.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/PickleCompiler.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/PickleCompilerContext.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/PickleCompilerContext.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/PickleCompilerContext.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/PickleCompilerContext.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Regex.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Regex.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Regex.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Regex.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/RuleType.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/RuleType.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/RuleType.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/RuleType.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Token.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Token.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Token.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Token.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/TokenFormatterBuilder.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/TokenFormatterBuilder.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/TokenFormatterBuilder.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/TokenFormatterBuilder.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/TokenMatcher.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/TokenMatcher.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/TokenMatcher.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/TokenMatcher.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/TokenScanner.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/TokenScanner.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/TokenScanner.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/TokenScanner.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Utils.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Utils.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/lib/gherkin/cucumber/gherkin/Utils.cpp", + "output": "gherkin/cpp/src/lib/gherkin/CMakeFiles/cucumber_gherkin_lib.dir/cucumber/gherkin/Utils.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/bin/gherkin -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/bin/gherkin/CMakeFiles/cucumber_gherkin_bin.dir/Gherkin.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/bin/gherkin/Gherkin.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/bin/gherkin/Gherkin.cpp", + "output": "gherkin/cpp/src/bin/gherkin/CMakeFiles/cucumber_gherkin_bin.dir/Gherkin.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/gherkin/cpp/src/bin/gherkin-generate-tokens -I/workspaces/cucumber-cpp-development/gherkin/cpp/include/gherkin -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o gherkin/cpp/src/bin/gherkin-generate-tokens/CMakeFiles/cucumber_gherkin_generate_tokens_bin.dir/GherkinGenerateTokens.cpp.o -c /workspaces/cucumber-cpp-development/gherkin/cpp/src/bin/gherkin-generate-tokens/GherkinGenerateTokens.cpp", + "file": "/workspaces/cucumber-cpp-development/gherkin/cpp/src/bin/gherkin-generate-tokens/GherkinGenerateTokens.cpp", + "output": "gherkin/cpp/src/bin/gherkin-generate-tokens/CMakeFiles/cucumber_gherkin_generate_tokens_bin.dir/GherkinGenerateTokens.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/query/cpp/include -I/workspaces/cucumber-cpp-development/query/cpp/src/query -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o query/cpp/CMakeFiles/cucumber_query_lib.dir/src/query/Lineage.cpp.o -c /workspaces/cucumber-cpp-development/query/cpp/src/query/Lineage.cpp", + "file": "/workspaces/cucumber-cpp-development/query/cpp/src/query/Lineage.cpp", + "output": "query/cpp/CMakeFiles/cucumber_query_lib.dir/src/query/Lineage.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/query/cpp/include -I/workspaces/cucumber-cpp-development/query/cpp/src/query -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o query/cpp/CMakeFiles/cucumber_query_lib.dir/src/query/Query.cpp.o -c /workspaces/cucumber-cpp-development/query/cpp/src/query/Query.cpp", + "file": "/workspaces/cucumber-cpp-development/query/cpp/src/query/Query.cpp", + "output": "query/cpp/CMakeFiles/cucumber_query_lib.dir/src/query/Query.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/query/cpp/include -I/workspaces/cucumber-cpp-development/query/cpp/src/query -I/workspaces/cucumber-cpp-development/messages/cpp/include/util -I/workspaces/cucumber-cpp-development/messages/cpp/include/generated -O3 -DNDEBUG -std=c++17 -o query/cpp/CMakeFiles/cucumber_query_lib.dir/src/query/NamingStrategy.cpp.o -c /workspaces/cucumber-cpp-development/query/cpp/src/query/NamingStrategy.cpp", + "file": "/workspaces/cucumber-cpp-development/query/cpp/src/query/NamingStrategy.cpp", + "output": "query/cpp/CMakeFiles/cucumber_query_lib.dir/src/query/NamingStrategy.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/tag-expressions/cpp/include -I/workspaces/cucumber-cpp-development/tag-expressions/cpp/src -O3 -DNDEBUG -std=c++17 -o tag-expressions/cpp/CMakeFiles/cucumber_tag_expressions_lib.dir/src/cucumber/tag-expressions/Error.cpp.o -c /workspaces/cucumber-cpp-development/tag-expressions/cpp/src/cucumber/tag-expressions/Error.cpp", + "file": "/workspaces/cucumber-cpp-development/tag-expressions/cpp/src/cucumber/tag-expressions/Error.cpp", + "output": "tag-expressions/cpp/CMakeFiles/cucumber_tag_expressions_lib.dir/src/cucumber/tag-expressions/Error.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/tag-expressions/cpp/include -I/workspaces/cucumber-cpp-development/tag-expressions/cpp/src -O3 -DNDEBUG -std=c++17 -o tag-expressions/cpp/CMakeFiles/cucumber_tag_expressions_lib.dir/src/cucumber/tag-expressions/Model.cpp.o -c /workspaces/cucumber-cpp-development/tag-expressions/cpp/src/cucumber/tag-expressions/Model.cpp", + "file": "/workspaces/cucumber-cpp-development/tag-expressions/cpp/src/cucumber/tag-expressions/Model.cpp", + "output": "tag-expressions/cpp/CMakeFiles/cucumber_tag_expressions_lib.dir/src/cucumber/tag-expressions/Model.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/tag-expressions/cpp/include -I/workspaces/cucumber-cpp-development/tag-expressions/cpp/src -O3 -DNDEBUG -std=c++17 -o tag-expressions/cpp/CMakeFiles/cucumber_tag_expressions_lib.dir/src/cucumber/tag-expressions/Parser.cpp.o -c /workspaces/cucumber-cpp-development/tag-expressions/cpp/src/cucumber/tag-expressions/Parser.cpp", + "file": "/workspaces/cucumber-cpp-development/tag-expressions/cpp/src/cucumber/tag-expressions/Parser.cpp", + "output": "tag-expressions/cpp/CMakeFiles/cucumber_tag_expressions_lib.dir/src/cucumber/tag-expressions/Parser.cpp.o" +}, +{ + "directory": "/workspaces/cucumber-cpp-development/build/host-system", + "command": "/usr/bin/c++ -I/workspaces/cucumber-cpp-development/tag-expressions/cpp/include -I/workspaces/cucumber-cpp-development/tag-expressions/cpp/src -O3 -DNDEBUG -std=c++17 -o tag-expressions/cpp/CMakeFiles/cucumber_tag_expressions_lib.dir/src/cucumber/tag-expressions/Token.cpp.o -c /workspaces/cucumber-cpp-development/tag-expressions/cpp/src/cucumber/tag-expressions/Token.cpp", + "file": "/workspaces/cucumber-cpp-development/tag-expressions/cpp/src/cucumber/tag-expressions/Token.cpp", + "output": "tag-expressions/cpp/CMakeFiles/cucumber_tag_expressions_lib.dir/src/cucumber/tag-expressions/Token.cpp.o" +} +] \ No newline at end of file