Add skip reason to build summary

Add a message to why a step was skipped to the build summary by adding
an optional result_skip_reason field to Step, and setting it whenever
the MakeSkipped error is returned.

Solved https://github.com/ziglang/zig/issues/14965
This commit is contained in:
Nico Elbers 2024-06-05 03:57:11 +02:00
parent 854774d468
commit b6514e8a57
No known key found for this signature in database
GPG key ID: 519CE81FDA71EE73
3 changed files with 25 additions and 5 deletions

View file

@ -1062,6 +1062,10 @@ fn printStepStatus(
.skipped, .skipped_oom => |skip| { .skipped, .skipped_oom => |skip| {
try ttyconf.setColor(stderr, .yellow); try ttyconf.setColor(stderr, .yellow);
try stderr.writeAll(" skipped"); try stderr.writeAll(" skipped");
if (s.result_skip_reason) |reason| {
try stderr.writeAll(": ");
try stderr.writeAll(reason);
}
if (skip == .skipped_oom) { if (skip == .skipped_oom) {
try stderr.writeAll(" (not enough memory)"); try stderr.writeAll(" (not enough memory)");
try ttyconf.setColor(stderr, .dim); try ttyconf.setColor(stderr, .dim);

View file

@ -52,6 +52,7 @@ state: State,
max_rss: usize, max_rss: usize,
result_error_msgs: ArrayList([]const u8), result_error_msgs: ArrayList([]const u8),
result_skip_reason: ?[]const u8 = null,
result_error_bundle: std.zig.ErrorBundle, result_error_bundle: std.zig.ErrorBundle,
result_stderr: []const u8, result_stderr: []const u8,
result_cached: bool, result_cached: bool,

View file

@ -1317,7 +1317,10 @@ fn runCommand(
.link_libc = exe.is_linking_libc, .link_libc = exe.is_linking_libc,
})) { })) {
.native, .rosetta => { .native, .rosetta => {
if (allow_skip) return error.MakeSkipped; if (allow_skip) {
run.step.result_skip_reason = "Invalid binary";
return error.MakeSkipped;
}
break :interpret; break :interpret;
}, },
.wine => |bin_name| { .wine => |bin_name| {
@ -1395,7 +1398,10 @@ fn runCommand(
} }
}, },
.bad_dl => |foreign_dl| { .bad_dl => |foreign_dl| {
if (allow_skip) return error.MakeSkipped; if (allow_skip) {
run.step.result_skip_reason = "Invalid binary";
return error.MakeSkipped;
}
const host_dl = b.graph.host.result.dynamic_linker.get() orelse "(none)"; const host_dl = b.graph.host.result.dynamic_linker.get() orelse "(none)";
@ -1407,7 +1413,10 @@ fn runCommand(
, .{ host_dl, foreign_dl }); , .{ host_dl, foreign_dl });
}, },
.bad_os_or_cpu => { .bad_os_or_cpu => {
if (allow_skip) return error.MakeSkipped; if (allow_skip) {
run.step.result_skip_reason = "Invalid os or cpu";
return error.MakeSkipped;
}
const host_name = try b.graph.host.result.zigTriple(b.allocator); const host_name = try b.graph.host.result.zigTriple(b.allocator);
const foreign_name = try root_target.zigTriple(b.allocator); const foreign_name = try root_target.zigTriple(b.allocator);
@ -1428,8 +1437,12 @@ fn runCommand(
try Step.handleVerbose2(step.owner, cwd, run.env_map, interp_argv.items); try Step.handleVerbose2(step.owner, cwd, run.env_map, interp_argv.items);
break :term spawnChildAndCollect(run, interp_argv.items, &env_map, has_side_effects, options, fuzz_context) catch |e| { break :term spawnChildAndCollect(run, interp_argv.items, &env_map, has_side_effects, options, fuzz_context) catch |e| {
if (!run.failing_to_execute_foreign_is_an_error) return error.MakeSkipped; if (!run.failing_to_execute_foreign_is_an_error) {
run.step.result_skip_reason = "Foreign binary failed";
return error.MakeSkipped;
}
if (e == error.MakeFailed) return error.MakeFailed; // error already reported if (e == error.MakeFailed) return error.MakeFailed; // error already reported
return step.fail("unable to spawn interpreter {s}: {s}", .{ return step.fail("unable to spawn interpreter {s}: {s}", .{
interp_argv.items[0], @errorName(e), interp_argv.items[0], @errorName(e),
}); });
@ -2294,8 +2307,10 @@ fn failForeign(
) error{ MakeFailed, MakeSkipped, OutOfMemory } { ) error{ MakeFailed, MakeSkipped, OutOfMemory } {
switch (run.stdio) { switch (run.stdio) {
.check, .zig_test => { .check, .zig_test => {
if (run.skip_foreign_checks) if (run.skip_foreign_checks) {
run.step.result_skip_reason = "Foreign binary failed";
return error.MakeSkipped; return error.MakeSkipped;
}
const b = run.step.owner; const b = run.step.owner;
const host_name = try b.graph.host.result.zigTriple(b.allocator); const host_name = try b.graph.host.result.zigTriple(b.allocator);