Implement the VLS roadmap on the native VBS build
Native VBS and CMake builds of the server and every registered suite: protocol and document sync, VBS/compdb providers, stock GCC diagnostics (including in-process default profile preparation), the stock occurrence observer and hover/definition, the bounded Scheduler, C++ module graph, scan and artifact cache with real CMI production, the context-aware symbol index with schema-2 snapshot migration, navigation and guarded rename, reflection provenance with splice-origin extraction, index-backed completion and signature help, live GCC worker control with a registered DAP suite, and the Neovim and VS Code clients. VoidLibrary follows main. The private GCC 16.2.0 frontend is reproduced from the versioned patches and verified stepping reflection/template code with projected values 17/34 and 41/82.
This commit is contained in:
1 parent
ca04975d54
commit
da8003f6d4
310 files changed
+47552
-480
No files matched your search
@@ -0,0 +1,593 @@
|
||||
#include <vls/modules/ModuleGraph.hpp>
|
||||
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace {
|
||||
using namespace vls::modules;
|
||||
using Void::Testing::expect;
|
||||
using Void::Testing::require;
|
||||
|
||||
const ExpectedOutput invocation{"/project/private", "same.o"};
|
||||
|
||||
// The extra rule fields are literal JSON from small scanner fixtures.
|
||||
std::string wire(std::string_view fields = {}) {
|
||||
std::string json = R"({"version":0,"revision":0,"rules":[{"primary-output":"same.o")";
|
||||
if (!fields.empty()) {
|
||||
json += ',';
|
||||
json += fields;
|
||||
}
|
||||
return json + "}]}";
|
||||
}
|
||||
|
||||
std::string named(std::string_view provision, std::vector<std::string> imports = {},
|
||||
bool is_interface = true) {
|
||||
std::string fields = R"("provides":[)";
|
||||
if (!provision.empty()) {
|
||||
fields += R"({"logical-name":")" + std::string(provision) + R"(","is-interface":)" +
|
||||
(is_interface ? "true}" : "false}");
|
||||
}
|
||||
fields += R"(],"requires":[)";
|
||||
for (std::size_t i = 0; i < imports.size(); ++i) {
|
||||
if (i)
|
||||
fields += ',';
|
||||
fields += R"({"logical-name":")" + imports[i] + R"("})";
|
||||
}
|
||||
return fields + ']';
|
||||
}
|
||||
|
||||
struct Fixture {
|
||||
ModuleCensus census;
|
||||
std::vector<ScanEvidence> scans;
|
||||
|
||||
explicit Fixture(std::size_t count) {
|
||||
std::vector<Build::BuildContext> records;
|
||||
for (std::size_t i = 0; i < count; ++i) {
|
||||
const auto name = "unit" + std::to_string(i);
|
||||
Build::BuildContext record;
|
||||
record.key = {"debug", "app", Build::ContextRole::target, name,
|
||||
std::filesystem::path("/project") / (name + ".cpp")};
|
||||
record.working_directory = invocation.working_directory;
|
||||
record.sources.push_back({record.key.owning_tu,
|
||||
{},
|
||||
Build::SourceOrigin::workspace,
|
||||
Build::Editability::editable,
|
||||
{}});
|
||||
CensusMember member{record.key,
|
||||
invocation,
|
||||
{"command:" + name, "source:" + name, "closure:" + name, {}},
|
||||
"pass-0",
|
||||
{}};
|
||||
census.members.push_back(member);
|
||||
records.push_back(std::move(record));
|
||||
}
|
||||
const auto generation =
|
||||
Build::BuildGeneration::create({{"/project", "editor"}, "fixture", "gen-1"}, records);
|
||||
require(generation.has_value());
|
||||
census.domain = {*generation, "gcc16/target/stdlib/abi", "lookup-v1"};
|
||||
census.revision = "app-members-v1";
|
||||
census.closed = true;
|
||||
for (const auto &member : census.members) {
|
||||
ScanEvidence scan;
|
||||
scan.domain = census.domain;
|
||||
scan.context = member.context;
|
||||
scan.inputs = member.inputs;
|
||||
scan.scan_revision = member.scan_revision;
|
||||
scan.exit_status = 0;
|
||||
scan.rule = decode_scan(wire(), member.output);
|
||||
scan.method = ScanMethod::preprocess_md;
|
||||
scan.complete = true;
|
||||
scan.header_uses.emplace();
|
||||
scan.writers = {"private-output:" + member.context.alternative};
|
||||
scans.push_back(std::move(scan));
|
||||
}
|
||||
}
|
||||
|
||||
void record(std::size_t n, std::string_view fields) {
|
||||
auto &member = census.members[n];
|
||||
member.scan_revision += '+';
|
||||
auto &scan = scans[n];
|
||||
scan.scan_revision = member.scan_revision;
|
||||
scan.inputs = member.inputs;
|
||||
scan.domain = census.domain;
|
||||
scan.rule = decode_scan(wire(fields), member.output);
|
||||
require(scan.rule->has_value());
|
||||
}
|
||||
void stage(std::size_t n, std::string id, std::string source) {
|
||||
auto &member = census.members[n];
|
||||
member.staged_header = StagedHeader{std::move(id), std::move(source), census.domain,
|
||||
member.context, member.inputs};
|
||||
}
|
||||
ModulePlan plan(std::size_t n) const {
|
||||
return build_module_plan(census, scans, census.members[n].context);
|
||||
}
|
||||
std::vector<Build::ContextKey> keys(std::initializer_list<std::size_t> ids) const {
|
||||
std::vector<Build::ContextKey> result;
|
||||
for (auto i : ids)
|
||||
result.push_back(census.members[i].context);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
bool blocked(const ModulePlan &plan, PlanIssue code) {
|
||||
return !plan.ready() && plan.order.empty() &&
|
||||
std::ranges::any_of(plan.blockers,
|
||||
[code](const auto &issue) { return issue.code == code; });
|
||||
}
|
||||
|
||||
const PlannedUnit &unit(const ModulePlan &plan, const Build::ContextKey &context) {
|
||||
const auto it = std::ranges::find_if(
|
||||
plan.units, [&](const auto &node) { return node.member.context == context; });
|
||||
require(it != plan.units.end());
|
||||
return *it;
|
||||
}
|
||||
|
||||
std::vector<Build::ContextKey> consumers(const ModulePlan &plan, const Build::ContextKey &key) {
|
||||
std::vector<Build::ContextKey> result;
|
||||
for (auto i : unit(plan, key).consumers)
|
||||
result.push_back(plan.units.at(i).member.context);
|
||||
return result;
|
||||
}
|
||||
|
||||
void rejects(std::string_view json, ScanError expected) {
|
||||
auto rule = decode_scan(json, invocation);
|
||||
require(!rule);
|
||||
expect(rule.error() == expected);
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, gcc_dialect_preserves_optional_lookup_and_partition_evidence) {
|
||||
auto rule = decode_scan(wire(R"("work-directory":"/project/private","outputs":["other.o"],
|
||||
"provides":[{"logical-name":"m:p","is-interface":false},{"logical-name":"m"}],
|
||||
"requires":[{"logical-name":"<h>","source-path":"./a/h","unique-on-source-path":true,
|
||||
"lookup-method":"include-angle","compiled-module-path":"slot/opaque"},
|
||||
{"logical-name":"h","lookup-method":"include-quote"},{"logical-name":"m:p"}],
|
||||
"_vendor_advisory":{"more":[true]})"),
|
||||
invocation);
|
||||
require(rule.has_value());
|
||||
expect(rule->output() == invocation);
|
||||
expect(rule->additional_outputs() == std::vector<std::string>{"other.o"});
|
||||
expect(!rule->provides()[0].is_interface && rule->provides()[1].is_interface);
|
||||
const auto &entry = rule->requirements()[0];
|
||||
expect(entry.unique_on_source_path && entry.logical_name == "<h>" &&
|
||||
entry.source_path == "./a/h");
|
||||
expect(entry.compiled_module_path == "slot/opaque" &&
|
||||
entry.lookup == LookupMethod::include_angle);
|
||||
expect(rule->requirements()[1].lookup == LookupMethod::include_quote);
|
||||
expect(rule->requirements()[2].lookup == LookupMethod::by_name);
|
||||
rule = decode_scan(R"({"version":0,"rules":[{"primary-output":"same.o"}]})", invocation);
|
||||
require(rule.has_value());
|
||||
expect(rule->provides().empty() && rule->requirements().empty() &&
|
||||
rule->additional_outputs().empty());
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, decoder_binds_exact_invocation_and_refuses_other_versions) {
|
||||
rejects(R"({"version":1,"revision":0,"rules":[]})", ScanError::unsupported_version);
|
||||
rejects(R"({"version":0,"revision":1,"rules":[]})", ScanError::unsupported_version);
|
||||
rejects(R"({"version":"0","rules":[]})", ScanError::invalid_shape);
|
||||
rejects(R"({"version":0.0,"rules":[]})", ScanError::invalid_shape);
|
||||
rejects(R"({"version":0,"rules":[]})", ScanError::invalid_shape);
|
||||
rejects(R"({"version":0,"rules":[{},{}]})", ScanError::invalid_shape);
|
||||
rejects(R"({"version":0,"rules":[{}]})", ScanError::invalid_shape);
|
||||
rejects(R"({"version":0,"rules":[{"primary-output":"./same.o"}]})", ScanError::wrong_output);
|
||||
rejects(wire(R"("work-directory":"/project/link/../private")"), ScanError::wrong_directory);
|
||||
auto result = decode_scan(wire(), {"relative", "same.o"});
|
||||
require(!result);
|
||||
expect(result.error() == ScanError::invalid_invocation);
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, decoder_rejects_malformed_or_unknown_semantic_fields) {
|
||||
for (auto fields :
|
||||
{R"("provides":null)", R"("requires":[null])", R"("requires":[{}])",
|
||||
R"("requires":[{"logical-name":""}])", R"("outputs":[null])", R"("outputs":["same.o"])",
|
||||
R"("outputs":["x","x"])", R"("provides":[{"logical-name":"m","is-interface":null}])",
|
||||
R"("requires":[{"logical-name":"m","unique-on-source-path":true}])",
|
||||
R"("requires":[{"logical-name":"m","source-path":false}])",
|
||||
R"("requires":[{"logical-name":"m","compiled-module-path":17}])",
|
||||
R"("requires":[{"logical-name":"m"},{"logical-name":"m"}])",
|
||||
R"("requires":[{"logical-name":"m\u0000n"}])"})
|
||||
rejects(wire(fields), ScanError::invalid_shape);
|
||||
for (auto fields : {R"("new-provider-semantics":true)",
|
||||
R"("requires":[{"logical-name":"m","lookup-method":"another"}])",
|
||||
R"("requires":[{"logical-name":"m","is-interface":false}])"})
|
||||
rejects(wire(fields), ScanError::unsupported_field);
|
||||
rejects(wire(R"("requires":[],"requires":[])"), ScanError::invalid_json);
|
||||
rejects("[", ScanError::invalid_json);
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, decoder_bounds_wire_tree_strings_and_aggregate_rule_items) {
|
||||
rejects(std::string(max_scan_bytes + 1, ' '), ScanError::limit);
|
||||
// The envelope, rules array and its rule object account for three open containers.
|
||||
auto nested = [](std::size_t depth) {
|
||||
return wire(R"("_vendor_x":)" + std::string(depth, '[') + "0" + std::string(depth, ']'));
|
||||
};
|
||||
expect(decode_scan(nested(max_scan_depth - 3), invocation).has_value());
|
||||
rejects(nested(max_scan_depth - 2), ScanError::limit);
|
||||
expect(decode_scan(wire(named(std::string(max_field_bytes, 'a'))), invocation).has_value());
|
||||
rejects(wire(named(std::string(max_field_bytes + 1, 'a'))), ScanError::limit);
|
||||
std::vector<std::string> names;
|
||||
for (std::size_t i = 0; i < max_rule_items; ++i)
|
||||
names.push_back("m" + std::to_string(i));
|
||||
expect(decode_scan(wire(named("", names)), invocation).has_value());
|
||||
rejects(wire(named("one_more", names)), ScanError::limit);
|
||||
names.push_back("beyond");
|
||||
rejects(wire(named("", names)), ScanError::limit);
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, orders_transitive_partitions_and_retains_reverse_consumers) {
|
||||
Fixture f{5};
|
||||
f.record(0, named("m:detail", {}, false));
|
||||
f.record(1, named("m:api", {"m:detail"}));
|
||||
f.record(2, named("m", {"m:api"}));
|
||||
f.record(3, named("", {"m", "m:detail"}));
|
||||
f.census.members[4].inputs.command += " -DEXPECT_READY=48 -o importer.o";
|
||||
f.record(4, named("", {"m"}));
|
||||
const auto plan = f.plan(4);
|
||||
require(plan.ready());
|
||||
expect(plan.order == f.keys({0, 1, 2, 4}));
|
||||
expect(consumers(plan, f.scans[0].context) == f.keys({1, 3}));
|
||||
expect(consumers(plan, f.scans[2].context) == f.keys({3, 4}));
|
||||
expect(unit(plan, f.scans[0].context).kind == UnitKind::internal_partition);
|
||||
expect(unit(plan, f.scans[1].context).kind == UnitKind::interface_partition);
|
||||
expect(unit(plan, f.scans[2].context).kind == UnitKind::primary_interface);
|
||||
expect(unit(plan, f.scans[4].context).kind == UnitKind::unknown);
|
||||
expect(f.plan(3).order == f.keys({0, 1, 2, 3}));
|
||||
const auto request = f.scans[4].context;
|
||||
std::ranges::reverse(f.census.members);
|
||||
std::ranges::reverse(f.scans);
|
||||
expect(plan.matches_census(f.census));
|
||||
expect(build_module_plan(f.census, f.scans, request).order == plan.order);
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, noninterface_named_provision_requires_a_partition) {
|
||||
Fixture f{2};
|
||||
f.record(0, named("m", {}, false));
|
||||
f.record(1, named("", {"m"}));
|
||||
const auto invalid = f.plan(1);
|
||||
expect(blocked(invalid, PlanIssue::unproven_mapping));
|
||||
expect(!invalid.claims_complete);
|
||||
f.record(0, named("m:inside", {}, false));
|
||||
f.record(1, named("", {"m:inside"}));
|
||||
const auto partition = f.plan(1);
|
||||
require(partition.ready());
|
||||
expect(unit(partition, f.scans[0].context).kind == UnitKind::internal_partition);
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, import_only_rules_do_not_distinguish_implementation_or_ordinary_tu) {
|
||||
Fixture f{3};
|
||||
f.record(0, named("lib"));
|
||||
f.record(1, named("", {"lib"}));
|
||||
f.record(2, named("", {"lib"}));
|
||||
auto plan = f.plan(2);
|
||||
require(plan.ready());
|
||||
expect(unit(plan, f.scans[1].context).kind == UnitKind::unknown);
|
||||
expect(unit(plan, f.scans[2].context).kind == UnitKind::unknown);
|
||||
f.scans[1].import_only_kind = UnitKind::implementation;
|
||||
f.scans[2].import_only_kind = UnitKind::ordinary;
|
||||
plan = f.plan(1);
|
||||
require(plan.ready());
|
||||
expect(unit(plan, f.scans[1].context).kind == UnitKind::implementation);
|
||||
expect(unit(plan, f.scans[2].context).kind == UnitKind::ordinary);
|
||||
f.scans[0].import_only_kind = UnitKind::implementation;
|
||||
expect(blocked(f.plan(0), PlanIssue::unproven_mapping));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, census_visibility_precedes_name_and_abi_compatibility) {
|
||||
Fixture f{3};
|
||||
f.record(0, named("lib"));
|
||||
f.record(1, named("lib"));
|
||||
f.record(2, named("", {"lib"}));
|
||||
expect(blocked(f.plan(2), PlanIssue::duplicate_provider));
|
||||
auto selected = f.census;
|
||||
selected.members.erase(selected.members.begin() + 1);
|
||||
const auto request = f.scans[2].context;
|
||||
const auto chosen = build_module_plan(selected, f.scans, request);
|
||||
require(chosen.ready());
|
||||
expect(chosen.order == f.keys({0, 2}));
|
||||
expect(!chosen.matches_census(f.census));
|
||||
f.scans[0].domain.compatibility = "different-abi";
|
||||
expect(blocked(build_module_plan(selected, f.scans, request), PlanIssue::wrong_domain));
|
||||
f.scans[0].domain = selected.domain;
|
||||
f.scans[0].domain.generation = Fixture{3}.census.domain.generation;
|
||||
expect(blocked(build_module_plan(selected, f.scans, request), PlanIssue::wrong_domain));
|
||||
selected.members.erase(selected.members.begin());
|
||||
expect(blocked(build_module_plan(selected, f.scans, request), PlanIssue::missing_provider));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, unknown_or_duplicate_eligible_claims_withhold_the_plan) {
|
||||
Fixture f{2};
|
||||
f.record(0, named("known"));
|
||||
f.record(1, named("otherwise_independent"));
|
||||
require(f.plan(0).ready());
|
||||
f.scans[1].exit_status = 1;
|
||||
const auto failed = f.plan(0);
|
||||
expect(blocked(failed, PlanIssue::scan_failed) && !failed.claims_complete);
|
||||
expect(unit(failed, f.scans[1].context).kind == UnitKind::unknown);
|
||||
f.scans[1].exit_status.reset();
|
||||
expect(blocked(f.plan(0), PlanIssue::incomplete_scan));
|
||||
f.scans[1].exit_status = 0;
|
||||
f.scans[1].rule.reset();
|
||||
expect(blocked(f.plan(0), PlanIssue::missing_rule));
|
||||
f.scans[1].rule = decode_scan("not JSON", invocation);
|
||||
const auto invalid = f.plan(0);
|
||||
expect(blocked(invalid, PlanIssue::invalid_rule));
|
||||
expect(std::ranges::any_of(invalid.blockers, [](const auto &issue) {
|
||||
return issue.scan_error == ScanError::invalid_json;
|
||||
}));
|
||||
f.record(1, named("restored"));
|
||||
f.scans.push_back(f.scans[1]);
|
||||
expect(blocked(f.plan(0), PlanIssue::duplicate_scan));
|
||||
f.scans.resize(1);
|
||||
expect(blocked(f.plan(0), PlanIssue::missing_scan));
|
||||
f.census.members[1].inputs.source.clear();
|
||||
expect(blocked(f.plan(0), PlanIssue::missing_source));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, missing_census_authority_and_scan_freshness_are_explicit) {
|
||||
Fixture f{2};
|
||||
f.census.closed = false;
|
||||
expect(blocked(f.plan(0), PlanIssue::incomplete_census));
|
||||
f.census.closed = true;
|
||||
f.census.members.push_back(f.census.members[1]);
|
||||
expect(blocked(f.plan(0), PlanIssue::duplicate_member));
|
||||
f.census.members.pop_back();
|
||||
f.census.members[1].context.alternative = "not in provider generation";
|
||||
expect(blocked(f.plan(0), PlanIssue::invalid_context));
|
||||
f.census.members[1].context = f.scans[1].context;
|
||||
f.scans[1].inputs.command += "-DOTHER";
|
||||
expect(blocked(f.plan(0), PlanIssue::stale_scan));
|
||||
f.scans[1].inputs = f.census.members[1].inputs;
|
||||
f.scans[1].rule = decode_scan(wire(), {"/different/invocation", "same.o"});
|
||||
expect(blocked(f.plan(0), PlanIssue::stale_scan));
|
||||
f.scans[1].rule = decode_scan(wire(), invocation);
|
||||
f.scans[1].scan_revision = "previous pass";
|
||||
expect(blocked(f.plan(0), PlanIssue::stale_scan));
|
||||
f.scans[1].scan_revision = f.census.members[1].scan_revision;
|
||||
f.census.domain.lookup.clear();
|
||||
expect(blocked(f.plan(0), PlanIssue::incomplete_census));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, missing_modules_and_conflicts_only_block_their_known_component) {
|
||||
Fixture f{5};
|
||||
f.record(0, named("one", {"std"}));
|
||||
f.record(1, named("two"));
|
||||
f.record(2, named("duplicate"));
|
||||
f.record(3, named("duplicate"));
|
||||
f.record(4, named("", {"two"}));
|
||||
expect(blocked(f.plan(0), PlanIssue::missing_provider));
|
||||
expect(blocked(f.plan(2), PlanIssue::duplicate_provider));
|
||||
expect(f.plan(4).order == f.keys({1, 4}));
|
||||
f.record(0, named("", {"./include/unit.hpp"}));
|
||||
expect(blocked(f.plan(0), PlanIssue::unproven_mapping));
|
||||
f.scans[0].header_uses = std::vector<HeaderUse>{{0, "header-file", "loaded-cmi"}};
|
||||
expect(blocked(f.plan(0), PlanIssue::missing_provider));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, self_and_multi_node_cycles_leave_independent_tu_buildable) {
|
||||
Fixture f{5};
|
||||
f.record(0, named("a", {"b"}));
|
||||
f.record(1, named("b", {"a"}));
|
||||
f.record(2, named("self", {"self"}));
|
||||
f.record(3, named("healthy"));
|
||||
f.record(4, named("", {"healthy"}));
|
||||
const auto cycle = f.plan(0);
|
||||
expect(blocked(cycle, PlanIssue::cycle) && cycle.claims_complete);
|
||||
expect(blocked(f.plan(1), PlanIssue::cycle));
|
||||
expect(blocked(f.plan(2), PlanIssue::cycle));
|
||||
expect(f.plan(4).order == f.keys({3, 4}));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, renamed_provider_invalidates_an_old_plan_with_identical_membership) {
|
||||
Fixture f{3};
|
||||
f.record(0, named("m"));
|
||||
f.record(1, named("independent"));
|
||||
f.record(2, named("", {"m"}));
|
||||
const auto old = f.plan(2);
|
||||
require(old.ready());
|
||||
expect(consumers(old, f.scans[1].context).empty());
|
||||
f.census.members[1].inputs.source = "edited unrelated declaration";
|
||||
f.record(1, named("m"));
|
||||
expect(!old.matches_census(f.census));
|
||||
expect(blocked(f.plan(2), PlanIssue::duplicate_provider));
|
||||
expect(old.order == f.keys({0, 2}));
|
||||
f.record(1, named("fixed"));
|
||||
require(f.plan(2).ready());
|
||||
std::ranges::reverse(f.census.members);
|
||||
auto duplicate = f.census;
|
||||
duplicate.members[0] = duplicate.members[1];
|
||||
expect(!f.plan(0).matches_census(duplicate));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, new_file_changes_has_include_and_adds_an_import_edge) {
|
||||
Fixture f{2};
|
||||
f.record(0, named("optional"));
|
||||
f.record(1, named(""));
|
||||
const auto before = f.plan(1);
|
||||
expect(before.order == f.keys({1}));
|
||||
// The TU bytes did not change. A previously missing optional.hpp now exists and
|
||||
// activates 'import optional' in the compiler scan.
|
||||
f.census.domain.lookup = "lookup-v2 optional.hpp present";
|
||||
expect(!before.matches_census(f.census));
|
||||
expect(blocked(f.plan(1), PlanIssue::wrong_domain));
|
||||
f.census.members[1].inputs.textual_closure = "closure includes new optional.hpp";
|
||||
f.record(0, named("optional"));
|
||||
f.record(1, named("", {"optional"}));
|
||||
const auto after = f.plan(1);
|
||||
expect(after.order == f.keys({0, 1}));
|
||||
expect(consumers(after, f.scans[0].context) == f.keys({1}));
|
||||
expect(consumers(before, f.scans[0].context).empty());
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, adding_an_eligible_provider_invalidates_the_previous_missing_lookup) {
|
||||
Fixture f{2};
|
||||
f.record(0, named("réseau.узел"));
|
||||
f.record(1, named("", {"réseau.узел"}));
|
||||
auto original = f.census;
|
||||
original.members.erase(original.members.begin());
|
||||
const auto &request = f.scans[1].context;
|
||||
const auto missing = build_module_plan(original, f.scans, request);
|
||||
expect(blocked(missing, PlanIssue::missing_provider) && missing.claims_complete);
|
||||
expect(missing.matches_census(original));
|
||||
expect(!missing.matches_census(f.census));
|
||||
f.census.revision = "app-members-v2";
|
||||
expect(f.plan(1).order == f.keys({0, 1}));
|
||||
f.record(1, named("", {"réseau.Узел"}));
|
||||
expect(blocked(f.plan(1), PlanIssue::missing_provider));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, cold_and_stale_header_cmi_cannot_attest_conditional_imports) {
|
||||
Fixture f{3};
|
||||
f.record(0, named("./h"));
|
||||
f.scans[0].provided_headers = {{0, "physical-header"}};
|
||||
f.record(1, named("conditioned"));
|
||||
f.record(2, named("", {"./h"}));
|
||||
f.scans[2].method = ScanMethod::missing_allowed;
|
||||
f.scans[2].header_uses = std::vector<HeaderUse>{{0, "physical-header", {}}};
|
||||
f.scans[2].complete = false;
|
||||
expect(blocked(f.plan(2), PlanIssue::incomplete_scan));
|
||||
f.scans[2].complete = true;
|
||||
expect(blocked(f.plan(2), PlanIssue::stale_header));
|
||||
f.stage(0, "stage-17", "physical-header");
|
||||
(*f.scans[2].header_uses)[0].loaded_generation = "stage-17";
|
||||
const auto first = f.plan(2);
|
||||
expect(first.order == f.keys({0, 2}));
|
||||
f.census.members[0].inputs.textual_closure = "header and transitive macro changed to true";
|
||||
f.record(0, named("./h"));
|
||||
// The process exited zero with the OLD CMI and missed 'conditioned'.
|
||||
f.record(2, named("", {"./h"}));
|
||||
expect(!first.matches_census(f.census));
|
||||
expect(blocked(f.plan(2), PlanIssue::stale_header));
|
||||
f.stage(0, "stage-41", "physical-header");
|
||||
expect(blocked(f.plan(2), PlanIssue::stale_header));
|
||||
(*f.scans[2].header_uses)[0].loaded_generation = "stage-41";
|
||||
f.record(2, named("", {"./h", "conditioned"}));
|
||||
const auto warm = f.plan(2);
|
||||
expect(warm.order == f.keys({0, 1, 2}));
|
||||
expect(unit(warm, f.scans[0].context).kind == UnitKind::header_unit);
|
||||
expect(first.order == f.keys({0, 2}));
|
||||
f.census.members[0].staged_header->producer = f.scans[1].context;
|
||||
expect(blocked(f.plan(2), PlanIssue::stale_header));
|
||||
f.stage(0, "stage-41", "physical-header");
|
||||
f.census.members[0].staged_header->domain.lookup = "stale lookup";
|
||||
expect(blocked(f.plan(2), PlanIssue::stale_header));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, header_source_bindings_converge_across_spellings_and_distinguish_shadow) {
|
||||
Fixture f{3};
|
||||
const auto provides =
|
||||
R"("provides":[{"logical-name":"h","source-path":"./h","unique-on-source-path":true}])";
|
||||
f.record(0, provides);
|
||||
f.record(1, provides);
|
||||
f.scans[0].provided_headers = {{0, "first/h"}};
|
||||
f.scans[1].provided_headers = {{0, "shadow/h"}};
|
||||
f.stage(0, "first-stage", "first/h");
|
||||
f.stage(1, "shadow-stage", "shadow/h");
|
||||
f.record(2, R"("requires":[{"logical-name":"<h>","source-path":"./selected/h",
|
||||
"unique-on-source-path":true,"lookup-method":"include-angle"},
|
||||
{"logical-name":"h","source-path":"./selected/h","unique-on-source-path":true,
|
||||
"lookup-method":"include-quote"}])");
|
||||
f.scans[2].header_uses =
|
||||
std::vector<HeaderUse>{{0, "first/h", "first-stage"}, {1, "first/h", "first-stage"}};
|
||||
const auto first = f.plan(2);
|
||||
expect(first.order == f.keys({0, 2}));
|
||||
expect(consumers(first, f.scans[0].context) == f.keys({2}));
|
||||
(*f.scans[2].header_uses)[1] = {1, "shadow/h", "shadow-stage"};
|
||||
expect(blocked(f.plan(2), PlanIssue::unproven_mapping));
|
||||
f.census.domain.lookup = "shadow first";
|
||||
for (auto &scan : f.scans)
|
||||
scan.domain = f.census.domain;
|
||||
(*f.scans[2].header_uses)[0] = {0, "shadow/h", "shadow-stage"};
|
||||
expect(blocked(f.plan(2), PlanIssue::stale_header));
|
||||
f.stage(1, "shadow-stage-2", "shadow/h");
|
||||
for (auto &use : *f.scans[2].header_uses)
|
||||
use.loaded_generation = "shadow-stage-2";
|
||||
expect(f.plan(2).order == f.keys({1, 2}));
|
||||
expect(!first.matches_census(f.census));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, missing_header_bindings_or_artifact_path_authority_stays_pending) {
|
||||
Fixture f{1};
|
||||
f.scans[0].header_uses.reset();
|
||||
expect(blocked(f.plan(0), PlanIssue::incomplete_scan));
|
||||
f.scans[0].header_uses.emplace();
|
||||
f.record(0, R"("requires":[{"logical-name":"header","lookup-method":"include-angle"}])");
|
||||
expect(blocked(f.plan(0), PlanIssue::unproven_mapping));
|
||||
f.scans[0].header_uses = std::vector<HeaderUse>{{1, "file", "one"}};
|
||||
expect(blocked(f.plan(0), PlanIssue::unproven_mapping));
|
||||
f.scans[0].header_uses = std::vector<HeaderUse>{{0, "file", "one"}, {0, "other", "two"}};
|
||||
expect(blocked(f.plan(0), PlanIssue::unproven_mapping));
|
||||
f.scans[0].header_uses->clear();
|
||||
f.record(0, R"("provides":[{"logical-name":"m","compiled-module-path":"external/unchecked"}])");
|
||||
expect(blocked(f.plan(0), PlanIssue::unproven_mapping));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, mmd_requires_immutable_system_closure_and_modes_never_imply_completeness) {
|
||||
Fixture f{1};
|
||||
f.scans[0].method = ScanMethod::preprocess_mmd;
|
||||
expect(blocked(f.plan(0), PlanIssue::incomplete_inputs));
|
||||
f.census.members[0].inputs.system_closure = "sealed sysroot contents";
|
||||
f.record(0, named("plain"));
|
||||
require(f.plan(0).ready());
|
||||
for (auto mode :
|
||||
{ScanMethod::preprocess_mmd, ScanMethod::preprocess_md, ScanMethod::missing_allowed}) {
|
||||
f.scans[0].method = mode;
|
||||
f.scans[0].complete = false;
|
||||
expect(blocked(f.plan(0), PlanIssue::incomplete_scan));
|
||||
}
|
||||
f.scans[0].complete = true;
|
||||
f.scans[0].method = ScanMethod::unknown;
|
||||
expect(blocked(f.plan(0), PlanIssue::incomplete_scan));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, actual_writer_identity_distinguishes_private_outputs_from_collisions) {
|
||||
Fixture f{3};
|
||||
f.record(0, R"("outputs":["private-extra"])");
|
||||
f.scans[0].writers.push_back("verified shared destination");
|
||||
const auto private_outputs = f.plan(0);
|
||||
require(private_outputs.ready());
|
||||
expect(f.census.members[0].output == f.census.members[1].output);
|
||||
f.scans[1].writers[0] = "verified shared destination";
|
||||
expect(blocked(f.plan(0), PlanIssue::writer_collision));
|
||||
expect(blocked(f.plan(1), PlanIssue::writer_collision));
|
||||
expect(f.plan(2).order == f.keys({2}));
|
||||
f.scans[0].writers.pop_back();
|
||||
expect(blocked(f.plan(0), PlanIssue::unproven_mapping));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, deep_legal_chain_orders_once_and_graph_limits_fail_closed) {
|
||||
Fixture f{max_units};
|
||||
for (std::size_t i = 0; i < max_units; ++i) {
|
||||
std::vector<std::string> imports;
|
||||
if (i)
|
||||
imports.push_back("m" + std::to_string(i - 1));
|
||||
f.record(i, named("m" + std::to_string(i), imports));
|
||||
}
|
||||
const auto plan = f.plan(max_units - 1);
|
||||
require(plan.ready() && plan.order.size() == max_units);
|
||||
bool ordered = true;
|
||||
for (std::size_t i = 0; i < max_units; ++i)
|
||||
ordered &= plan.order[i] == f.scans[i].context;
|
||||
expect(ordered);
|
||||
f.census.members.push_back(f.census.members[0]);
|
||||
expect(blocked(f.plan(0), PlanIssue::limit));
|
||||
f.census.members.pop_back();
|
||||
f.scans[0].writers.front().resize(max_field_bytes + 1, 'x');
|
||||
expect(blocked(f.plan(0), PlanIssue::limit));
|
||||
f.scans[0].writers.front() = "restored";
|
||||
for (auto &member : f.census.members)
|
||||
member.inputs.textual_closure.resize(max_field_bytes, 'x');
|
||||
expect(blocked(f.plan(0), PlanIssue::limit));
|
||||
}
|
||||
|
||||
VOID_TEST(ModuleGraph, aggregate_edge_budget_is_enforced_before_resolution) {
|
||||
Fixture f{80};
|
||||
std::vector<std::string> names(450);
|
||||
for (std::size_t i = 0; i < names.size(); ++i)
|
||||
names[i] = "m" + std::to_string(i);
|
||||
const auto fields = named("", names);
|
||||
for (std::size_t i = 0; i < f.scans.size(); ++i)
|
||||
f.record(i, fields);
|
||||
expect(blocked(f.plan(0), PlanIssue::limit));
|
||||
}
|
||||
} // namespace
|
||||
Reference in new issue
Block a user