// Copyright (c) 2026 Progmasoft. // SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-2.0 #pragma once #include "Catalog.hpp" #include "Expected.hpp" #include "Git.hpp" #include "History.hpp" #include "Options.hpp" #include #include #include #include #include #include namespace Progmasoft::Catch3::Runner { /// One test the run will start, with everything decided in advance. struct PlannedTest final { const TestEntry *entry = nullptr; std::string selectionReason; double failureProbability = 0.0; std::int64_t predictedMicroseconds = 0; /// Zero: no limit. std::chrono::milliseconds timeout{0}; bool timeoutLearned = false; unsigned retryLimit = 0; bool quarantined = false; std::string quarantineReason; /// The history shows the test passing and failing with the same /// inputs. bool flakyHistory = false; /// Positions in `Plan::tests` of the tests this one waits for. std::vector dependencies; /// What the result depends on; equal for an unchanged test. std::string fingerprint; /// For --replay: the tests (catalog indices) to run before it in the /// same fresh process, and the seed it failed with. std::optional> replaySequence; std::optional replaySeed; }; /// What a run will do, decided before the first test starts. struct Plan final { /// In the order the scheduler should prefer. std::vector tests; /// Tests whose earlier result stands: up to date or out of the /// selection but needed by nothing. std::vector kept; std::vector unmatchedSpecs; std::vector notes; /// Tests that matched the specs, before selection and sharding. std::size_t candidates = 0; std::map fingerprints; }; /// What the planner reads besides the options. struct PlanInputs final { const Catalog *catalog = nullptr; /// The tests the specs matched, in registration order. std::vector matched; std::vector unmatchedSpecs; const History *history = nullptr; /// Present when Git answered. const Changes *changes = nullptr; /// A digest of the test binary. std::string binaryFingerprint; }; [[nodiscard]] Expected MakePlan(const Options &options, const PlanInputs &inputs); /// The shard of a group of tests that must stay together, by a hash of /// its first key. Every machine computes the same answer. [[nodiscard]] unsigned StableShard(const std::string &key, unsigned count) noexcept; } // namespace Progmasoft::Catch3::Runner