aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/Build/Step.zig')
-rw-r--r--lib/std/Build/Step.zig33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/std/Build/Step.zig b/lib/std/Build/Step.zig
index 45aa635972..05c4faa52d 100644
--- a/lib/std/Build/Step.zig
+++ b/lib/std/Build/Step.zig
@@ -35,11 +35,27 @@ result_cached: bool,
result_duration_ns: ?u64,
/// 0 means unavailable or not reported.
result_peak_rss: usize,
+test_results: TestResults,
/// The return addresss associated with creation of this step that can be useful
/// to print along with debugging messages.
debug_stack_trace: [n_debug_stack_frames]usize,
+pub const TestResults = struct {
+ fail_count: u32 = 0,
+ skip_count: u32 = 0,
+ leak_count: u32 = 0,
+ test_count: u32 = 0,
+
+ pub fn isSuccess(tr: TestResults) bool {
+ return tr.fail_count == 0 and tr.leak_count == 0;
+ }
+
+ pub fn passCount(tr: TestResults) u32 {
+ return tr.test_count - tr.fail_count - tr.skip_count;
+ }
+};
+
pub const MakeFn = *const fn (self: *Step, prog_node: *std.Progress.Node) anyerror!void;
const n_debug_stack_frames = 4;
@@ -134,6 +150,7 @@ pub fn init(options: Options) Step {
.result_cached = false,
.result_duration_ns = null,
.result_peak_rss = 0,
+ .test_results = .{},
};
}
@@ -152,6 +169,10 @@ pub fn make(s: *Step, prog_node: *std.Progress.Node) error{ MakeFailed, MakeSkip
},
};
+ if (!s.test_results.isSuccess()) {
+ return error.MakeFailed;
+ }
+
if (s.max_rss != 0 and s.result_peak_rss > s.max_rss) {
const msg = std.fmt.allocPrint(arena, "memory usage peaked at {d} bytes, exceeding the declared upper bound of {d}", .{
s.result_peak_rss, s.max_rss,
@@ -346,9 +367,7 @@ pub fn evalZigProcess(
s.result_cached = ebp_hdr.flags.cache_hit;
result = try arena.dupe(u8, body[@sizeOf(EbpHdr)..]);
},
- _ => {
- // Unrecognized message.
- },
+ else => {}, // ignore other messages
}
stdout.discard(header_and_msg_len);
}
@@ -475,3 +494,11 @@ fn failWithCacheError(s: *Step, man: *const std.Build.Cache.Manifest, err: anyer
const prefix = man.cache.prefixes()[pp.prefix].path orelse "";
return s.fail("{s}: {s}/{s}", .{ @errorName(err), prefix, pp.sub_path });
}
+
+pub fn writeManifest(s: *Step, man: *std.Build.Cache.Manifest) !void {
+ if (s.test_results.isSuccess()) {
+ man.writeManifest() catch |err| {
+ try s.addError("unable to write cache manifest: {s}", .{@errorName(err)});
+ };
+ }
+}