test(pipeline): the checks of the pure pipeline
Stream, Normalize, Merge, Dispositions, Config, CodeKeys and the pure half of CommitsMode, each a test of its own (131 checks). The fixture rewrites are checked in (code-keys/<name>/, commits3/), so the suite reads fixtures and edits nothing. The allowlist, command-line and MCP checks of CommitsMode come with the pool they test. Among them: this binary's `<exe> sql` spelling counts as a SQL call, and a result line with a raw U+2028 in a JSON string is still the result line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
741e3a656d
commit
71dba5690f
12 changed files with 3778 additions and 1 deletions
46
tests/Dispositions/main.cpp
Normal file
46
tests/Dispositions/main.cpp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
// Dispositions: in force, carried, lapsed, and the prompt block.
|
||||
|
||||
import std;
|
||||
import Crafter.Review;
|
||||
namespace fs = std::filesystem;
|
||||
using namespace Crafter::Review;
|
||||
|
||||
namespace {
|
||||
std::int32_t Failures = 0;
|
||||
|
||||
void Check(std::string_view name, bool cond, std::string_view detail = {}) {
|
||||
std::println("{}{}{}", cond ? " ok " : " FAIL ", name, !cond && !detail.empty() ? std::format(" ({})", detail) : std::string());
|
||||
if (!cond) ++Failures;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::println("dispositions: in-force / carried / lapsed, the prompt block");
|
||||
const fs::path td = fs::temp_directory_path() / std::format("crafter-review-dispositions-{}", Platform::PublishedPid());
|
||||
fs::create_directories(td);
|
||||
std::ofstream(td / "0001-a.patch", std::ios::binary) << "x\nANCHOR TEXT\ny\nANCHOR TEXT\n";
|
||||
const std::vector<Json> e = {
|
||||
{{"id", "a"}, {"hash", "H1"}},
|
||||
{{"id", "b"}, {"hash", "H0"}, {"carry", true}, {"anchors", {{{"file", "0001-a.patch"}, {"text", "ANCHOR TEXT"}, {"count", 2}}}}},
|
||||
{{"id", "c"}, {"hash", "H0"}, {"carry", true}, {"anchors", {{{"file", "0001-a.patch"}, {"text", "ANCHOR TEXT"}, {"count", 1}}}}},
|
||||
{{"id", "d"}, {"hash", "H0"}},
|
||||
};
|
||||
std::map<std::string, std::string> rows;
|
||||
for (const Json& row : Dispositions::Classify(e, "H1", td)) rows[row.at("id").get<std::string>()] = row.at("status").get<std::string>();
|
||||
const std::map<std::string, std::string> expected = {{"a", "in-force"}, {"b", "carried"}, {"c", "lapsed"}, {"d", "lapsed"}};
|
||||
Check("hash match in-force, count match carried, count mismatch lapsed, no carry lapsed", rows == expected);
|
||||
const std::vector<Json> inf = Dispositions::InForce(e, Dispositions::Classify(e, "H1", td));
|
||||
Check("in_force = in-force + carried", inf.size() == 2 && inf[0].at("id") == "a" && inf[1].at("id") == "b");
|
||||
const std::string blk = Dispositions::Block(inf, Dispositions::Classify(e, "H1", td), "repo-bug-prover.md", "H1");
|
||||
Check("block text names the carried entry, nothing outside the register discharges, Gate 4 named", blk.contains("CARRIED to this hash") && blk.contains("- a [")
|
||||
&& blk.contains("Nothing outside this list") && blk.contains("Gate 4") && !blk.contains("ledger"));
|
||||
const std::vector<Json> e2 = {{{"id", "r"}, {"hash", "H1"}, {"kind", "refuted"}, {"lenses", {"repo-functional.md"}}}};
|
||||
const std::vector<Json> rowsR = {{{"id", "r"}, {"status", "in-force"}}};
|
||||
Check("refuted entry hidden from other lenses, shown to its own", Dispositions::Block(e2, rowsR, "repo-bug-prover.md", "H1").contains("(none)")
|
||||
&& Dispositions::Block(e2, rowsR, Plan::FunctionalLens, "H1").contains("- r ["));
|
||||
fs::remove_all(td);
|
||||
return Failures ? 1 : 0;
|
||||
}
|
||||
Loading…
Reference in a new issue