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

summaryrefslogtreecommitdiffhomepage
path: root/src/Progmasoft/Runner/ProjectConfig.hpp
diff options
context:
space:
mode:
authorLeitwolf2026-10-30 00:06:27 +0300
committerGitHub2026-10-30 00:06:27 +0300
commit471756b77331fa1ab77bc94e6aae228baef903e0 (patch)
tree3af5223ff664544d15eaf20a10eccdf3465d9958 /src/Progmasoft/Runner/ProjectConfig.hpp
parent1d48419b7ef642917ebf7dfd16c3bc1b3050d8f1 (diff)
parent0b4b57a0688f2943f4c797c20d68d533cf70fd15 (diff)
downloadcatch3-471756b77331fa1ab77bc94e6aae228baef903e0.tar.gz
Merge pull request #20 from Progmasoft/feature/catch3-json
Read the options of a project from catch3.json
Diffstat (limited to 'src/Progmasoft/Runner/ProjectConfig.hpp')
-rw-r--r--src/Progmasoft/Runner/ProjectConfig.hpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/Progmasoft/Runner/ProjectConfig.hpp b/src/Progmasoft/Runner/ProjectConfig.hpp
new file mode 100644
index 00000000..c715b1ed
--- /dev/null
+++ b/src/Progmasoft/Runner/ProjectConfig.hpp
@@ -0,0 +1,44 @@
+// Copyright (c) 2026 Progmasoft.
+// SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-1.1
+#pragma once
+
+#include <filesystem>
+#include <optional>
+#include <string>
+#include <string_view>
+#include <vector>
+
+#include "Expected.hpp"
+#include "Options.hpp"
+
+namespace Progmasoft::Catch3::Runner
+{
+ /// The name of the project configuration file.
+ inline constexpr std::string_view kProjectConfigName = "catch3.json";
+
+ /// The `catch3.json` that applies in `start`: the nearest one in `start`
+ /// or a directory above it, up to the root of the Git repository that
+ /// holds `start`. Outside a repository only `start` itself is searched,
+ /// so a stray file in a home directory never applies.
+ [[nodiscard]] std::optional<std::filesystem::path>
+ FindProjectConfig(const std::filesystem::path &start);
+
+ /// Applies the text of a `catch3.json` to `options`. Its keys are the long
+ /// options of the command line, and its values go through the same checks;
+ /// relative paths are read from `directory`, the file's own. `file` names
+ /// the file in messages.
+ [[nodiscard]] Expected<Options>
+ ApplyProjectConfig(std::string_view text,
+ const std::filesystem::path &directory,
+ std::string_view file,
+ Options options = {});
+
+ /// Reads the command line together with the `catch3.json` it selects:
+ /// --config names one, --no-config reads none, and otherwise
+ /// FindProjectConfig searches from `workingDirectory`. Options on the
+ /// command line win over the file, and test specs on the command line
+ /// replace those of the file. Workers, --help and --version read no file.
+ [[nodiscard]] Expected<Options>
+ ParseCommandLine(const std::vector<std::string> &arguments,
+ const std::filesystem::path &workingDirectory);
+} // namespace Progmasoft::Catch3::Runner