feat(test,explain,trace): repetition controls, action explanations, Chrome traces
VoidBuildSystem CI / 1 · Requirements (push) Successful in 5s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 1m54s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 1m50s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 3m48s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 4m8s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 4m1s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 40s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 16s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 19s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Successful in 6m56s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Successful in 7m3s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Successful in 4m31s
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Successful in 3m51s
VoidBuildSystem CI / 5 · Release (push) Skipped
VoidBuildSystem CI / 1 · Requirements (push) Successful in 5s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 1m54s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 1m50s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 3m48s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 4m8s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 4m1s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 40s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 16s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 19s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Successful in 6m56s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Successful in 7m3s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Successful in 4m31s
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Successful in 3m51s
VoidBuildSystem CI / 5 · Release (push) Skipped
Test runner gains CTest/Meson parity controls: --repeat until-fail|until-pass|after-timeout[:N], --retry N, --shuffle [--shuffle-seed N] and --stop-on-failure (which also skips the remaining profiles). `vbs explain` answers "why would this action run?" without executing anything: Execution::explain_graph compares each selected action against the CAS record (missing record, changed discovered inputs, changed or missing outputs, restorable outputs, shared-remote-cache hits) and reports text or JSON. `vbs build|test --trace FILE` writes a Chrome trace (JSON) with build phase spans (config, toolchain, eval, snapshot, graph, total) and per-action spans from the scheduler events. Verified: new FullV1Tests cases (repetition/shuffle/stop-on-failure and explain/trace) pass, and the CLI contract suite passes.
This commit is contained in:
1 parent
a3afca0e5f
commit
2dec3e9259
5 files changed
+818
-33
No files matched your search
+127
-2
@@ -130,8 +130,7 @@ bool restore_outputs_from_cache(const Graph::ActionNode &action,
|
||||
|
||||
// Build-path-independent path mapping used for shared remote cache keys and records.
|
||||
// Longest prefix wins so nested build/root prefixes are replaced before their parents.
|
||||
struct PathMapper {
|
||||
std::vector<std::pair<std::string, std::string>> pairs;
|
||||
struct PathMapper { std::vector<std::pair<std::string, std::string>> pairs;
|
||||
|
||||
[[nodiscard]] std::string normalize(std::string_view input) const {
|
||||
std::string out{input};
|
||||
@@ -954,4 +953,130 @@ execute_graph(const Graph::BuildGraph &graph, State::StateStore &state,
|
||||
return report;
|
||||
}
|
||||
|
||||
Void::Result::Result<ExplainReport, Void::Result::Error>
|
||||
explain_graph(const Graph::BuildGraph &graph, State::StateStore &state,
|
||||
const ExecutionOptions &options) {
|
||||
auto selected_indices_res = graph.select_action_closure(options.selected_targets);
|
||||
if (!selected_indices_res) {
|
||||
return std::unexpected{selected_indices_res.error()};
|
||||
}
|
||||
|
||||
const auto label_for = [&](const Graph::ActionNode &act) -> std::string {
|
||||
const auto rel_name = [&](const std::filesystem::path &p) -> std::string {
|
||||
if (p.empty()) {
|
||||
return act.target_name;
|
||||
}
|
||||
if (!graph.project_root.empty() && Platform::path_is_within(graph.project_root, p)) {
|
||||
return p.lexically_relative(graph.project_root).generic_string();
|
||||
}
|
||||
return p.filename().string();
|
||||
};
|
||||
switch (act.kind) {
|
||||
case Graph::ActionKind::Compile:
|
||||
return std::format("Compile {}", rel_name(!act.logical_source_file.empty()
|
||||
? act.logical_source_file
|
||||
: act.logical_output_file));
|
||||
case Graph::ActionKind::PrecompiledHeader:
|
||||
return std::format("PCH {}", rel_name(act.logical_source_file));
|
||||
case Graph::ActionKind::HeaderUnit:
|
||||
return std::format("HdrUnit {}", rel_name(act.logical_source_file));
|
||||
case Graph::ActionKind::ModuleScan:
|
||||
return std::format("ModScan {}", rel_name(act.logical_source_file));
|
||||
case Graph::ActionKind::ModuleBmi:
|
||||
return std::format("BMI {}", rel_name(act.logical_source_file));
|
||||
case Graph::ActionKind::Archive:
|
||||
return std::format("Archive {}", rel_name(act.logical_output_file));
|
||||
case Graph::ActionKind::Link:
|
||||
return std::format("Link {}", rel_name(act.logical_output_file));
|
||||
case Graph::ActionKind::Custom:
|
||||
return std::format("Action {}", act.target_name);
|
||||
}
|
||||
return act.id;
|
||||
};
|
||||
|
||||
ExplainReport report;
|
||||
RunDigestCache digest_cache;
|
||||
const PathMapper path_mapper = make_path_mapper(graph);
|
||||
|
||||
for (const std::size_t idx : *selected_indices_res) {
|
||||
const auto &act = graph.actions[idx];
|
||||
ActionExplanation ex;
|
||||
ex.action_id = act.id;
|
||||
ex.target_name = act.target_name;
|
||||
ex.label = label_for(act);
|
||||
ex.cacheable = act.cacheable && !act.nondeterministic;
|
||||
ex.action_key = compute_effective_action_key(act, digest_cache);
|
||||
ex.command = act.executable.string();
|
||||
for (const auto &arg : act.arguments) {
|
||||
ex.command += ' ';
|
||||
ex.command += arg;
|
||||
}
|
||||
|
||||
if (!ex.cacheable) {
|
||||
ex.would_run = true;
|
||||
ex.reason = act.nondeterministic ? "nondeterministic action (never cached)"
|
||||
: "action is not cacheable";
|
||||
} else {
|
||||
auto cached = state.lookup_action(ex.action_key);
|
||||
if (!cached) {
|
||||
return std::unexpected{cached.error()};
|
||||
}
|
||||
if (!cached->has_value()) {
|
||||
ex.would_run = true;
|
||||
ex.reason = "no cached result for this action key";
|
||||
if (state.has_remote_cache()) {
|
||||
const std::string remote_key =
|
||||
compute_remote_action_key(act, graph, digest_cache, path_mapper);
|
||||
auto remote = state.fetch_remote_action(remote_key);
|
||||
if (remote && remote->has_value()) {
|
||||
ex.remote_hit = true;
|
||||
ex.reason += " (available in the shared remote cache)";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const auto &rec = **cached;
|
||||
for (const auto &[path_str, expected_sha] : rec.discovered_inputs) {
|
||||
const auto actual = digest_cache.hash_file(std::filesystem::path{path_str});
|
||||
if (!actual) {
|
||||
ex.changed_inputs.push_back(path_str + " (missing)");
|
||||
} else if (*actual != expected_sha) {
|
||||
ex.changed_inputs.push_back(path_str + " (modified)");
|
||||
}
|
||||
}
|
||||
for (const auto &out : act.declared_outputs) {
|
||||
const auto it = rec.outputs.find(out.string());
|
||||
if (it == rec.outputs.end()) {
|
||||
ex.changed_outputs.push_back(out.string() + " (not recorded)");
|
||||
continue;
|
||||
}
|
||||
const auto actual = digest_cache.hash_file(out);
|
||||
if (!actual) {
|
||||
ex.changed_outputs.push_back(out.string() + " (missing)");
|
||||
} else if (*actual != it->second.sha256) {
|
||||
ex.changed_outputs.push_back(out.string() + " (modified)");
|
||||
}
|
||||
}
|
||||
if (!ex.changed_inputs.empty()) {
|
||||
ex.would_run = true;
|
||||
ex.reason = "inputs changed";
|
||||
} else if (!ex.changed_outputs.empty()) {
|
||||
ex.restorable = true;
|
||||
ex.reason = "outputs changed or missing (restorable from the cache)";
|
||||
} else {
|
||||
ex.reason = "up to date";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ex.would_run) {
|
||||
++report.would_run;
|
||||
} else {
|
||||
++report.up_to_date;
|
||||
}
|
||||
report.actions.push_back(std::move(ex));
|
||||
}
|
||||
report.total = report.actions.size();
|
||||
return report;
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Execution
|
||||
Reference in new issue
Block a user