From bf588efbe671be17f28623fcc903cc4763f56050 Mon Sep 17 00:00:00 2001 From: Nico Elbers Date: Wed, 5 Jun 2024 03:57:11 +0200 Subject: [PATCH 1/3] Add skip reason to Step --- lib/std/Build/Step.zig | 1 + lib/std/Build/Step/Run.zig | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/std/Build/Step.zig b/lib/std/Build/Step.zig index 346ab2c9b3..90530f6ad6 100644 --- a/lib/std/Build/Step.zig +++ b/lib/std/Build/Step.zig @@ -39,6 +39,7 @@ state: State, /// total system memory available. max_rss: usize, +result_skip_reason: ?[]const u8 = null, result_error_msgs: std.ArrayListUnmanaged([]const u8), result_error_bundle: std.zig.ErrorBundle, result_stderr: []const u8, diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index 0c011e25ed..a087ee1f4e 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -1017,7 +1017,10 @@ fn runCommand( .link_libc = exe.is_linking_libc, })) { .native, .rosetta => { - if (allow_skip) return error.MakeSkipped; + if (allow_skip) { + run.step.result_skip_reason = "Invalid binary"; + return error.MakeSkipped; + } break :interpret; }, .wine => |bin_name| { @@ -1098,7 +1101,10 @@ fn runCommand( } }, .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)"; @@ -1110,7 +1116,10 @@ fn runCommand( , .{ host_dl, foreign_dl }); }, .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 foreign_name = try exe.rootModuleTarget().zigTriple(b.allocator); @@ -1129,7 +1138,10 @@ fn runCommand( try Step.handleVerbose2(step.owner, cwd, run.env_map, interp_argv.items); break :term spawnChildAndCollect(run, interp_argv.items, has_side_effects, prog_node, 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; + } return step.fail("unable to spawn interpreter {s}: {s}", .{ interp_argv.items[0], @errorName(e), @@ -1732,8 +1744,10 @@ fn failForeign( ) error{ MakeFailed, MakeSkipped, OutOfMemory } { switch (run.stdio) { .check, .zig_test => { - if (run.skip_foreign_checks) + if (run.skip_foreign_checks) { + run.step.result_skip_reason = "Foreign binary failed"; return error.MakeSkipped; + } const b = run.step.owner; const host_name = try b.graph.host.result.zigTriple(b.allocator); From fc6ff3af118d2a652a2040d5312f48cd4749ecc8 Mon Sep 17 00:00:00 2001 From: Nico Elbers Date: Wed, 5 Jun 2024 03:57:38 +0200 Subject: [PATCH 2/3] Show skip reason in build summary --- lib/compiler/build_runner.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/compiler/build_runner.zig b/lib/compiler/build_runner.zig index 690c937545..b8fb7740ff 100644 --- a/lib/compiler/build_runner.zig +++ b/lib/compiler/build_runner.zig @@ -839,7 +839,12 @@ fn printStepStatus( }, .skipped, .skipped_oom => |skip| { try ttyconf.setColor(stderr, .yellow); - try stderr.writeAll(" skipped"); + try stderr.writeAll(" skipped: "); + if (s.result_skip_reason) |reason| { + try stderr.writeAll(reason); + } else { + try stderr.writeAll("Unspecified"); + } if (skip == .skipped_oom) { try stderr.writeAll(" (not enough memory)"); try ttyconf.setColor(stderr, .dim); From fa5006819fe2098c5b455c121c9db6d24ef7d4eb Mon Sep 17 00:00:00 2001 From: Nico Elbers Date: Wed, 5 Jun 2024 23:56:15 +0200 Subject: [PATCH 3/3] Remove reason when none is specified --- lib/compiler/build_runner.zig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/compiler/build_runner.zig b/lib/compiler/build_runner.zig index b8fb7740ff..0ba42cc966 100644 --- a/lib/compiler/build_runner.zig +++ b/lib/compiler/build_runner.zig @@ -839,11 +839,10 @@ fn printStepStatus( }, .skipped, .skipped_oom => |skip| { 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); - } else { - try stderr.writeAll("Unspecified"); } if (skip == .skipped_oom) { try stderr.writeAll(" (not enough memory)");