ReviewOS

also looking at this

zig-utils/zig-test-framework

chore: wip

#1
Merged glennmichael123 wants to merge fix-ci-process into main
3 files +15 -17
build.zigmodified+1-3
Changes to build.zig
@@ -27,9 +27,7 @@ pub fn build(b: *std.Build) void {
2727 const run_cmd = b.addRunArtifact(exe);
2828 run_cmd.step.dependOn(b.getInstallStep());
2929
30 if (b.args) |args| {
31 run_cmd.addArgs(args);
32 }
30 run_cmd.addPassthruArgs();
3331
3432 const run_step = b.step("run", "Run the test framework");
3533 run_step.dependOn(&run_cmd.step);
src/compat.zigmodified+6-6
Changes to src/compat.zig
@@ -113,7 +113,7 @@ fn closeFd(fd: std.posix.fd_t) void {
113113/// Read entire file contents using POSIX APIs.
114114/// Replaces std.fs.cwd().openFile() + file.readToEndAlloc().
115115pub fn readFileAlloc(allocator: std.mem.Allocator, path: []const u8) ![]const u8 {
116 const path_z = try allocator.dupeZ(u8, path);
116 const path_z = try allocator.dupeSentinel(u8, path, 0);
117117 defer allocator.free(path_z);
118118
119119 const fd = std.posix.openatZ(std.posix.AT.FDCWD, path_z, .{}, 0) catch |err| {
@@ -139,7 +139,7 @@ pub fn readFileAlloc(allocator: std.mem.Allocator, path: []const u8) ![]const u8
139139/// Write content to a file using POSIX APIs.
140140/// Replaces std.fs.cwd().createFile() + file.writeAll().
141141pub fn writeFile(allocator: std.mem.Allocator, path: []const u8, content: []const u8) !void {
142 const path_z = try allocator.dupeZ(u8, path);
142 const path_z = try allocator.dupeSentinel(u8, path, 0);
143143 defer allocator.free(path_z);
144144
145145 const fd = std.posix.openatZ(std.posix.AT.FDCWD, path_z, .{
@@ -161,7 +161,7 @@ pub fn writeFile(allocator: std.mem.Allocator, path: []const u8, content: []cons
161161/// Delete a file using POSIX APIs.
162162/// Replaces std.fs.cwd().deleteFile().
163163pub fn deleteFile(allocator: std.mem.Allocator, path: []const u8) !void {
164 const path_z = try allocator.dupeZ(u8, path);
164 const path_z = try allocator.dupeSentinel(u8, path, 0);
165165 defer allocator.free(path_z);
166166 const rc = std.c.unlink(path_z);
167167 if (rc != 0) {
@@ -175,7 +175,7 @@ pub fn deleteFile(allocator: std.mem.Allocator, path: []const u8) !void {
175175/// Create directories recursively using POSIX APIs.
176176/// Replaces std.fs.cwd().makePath().
177177pub fn makePath(allocator: std.mem.Allocator, path: []const u8) !void {
178 const path_z = try allocator.dupeZ(u8, path);
178 const path_z = try allocator.dupeSentinel(u8, path, 0);
179179 defer allocator.free(path_z);
180180
181181 const rc = std.c.mkdir(path_z, 0o755);
@@ -189,7 +189,7 @@ pub fn makePath(allocator: std.mem.Allocator, path: []const u8) !void {
189189 if (sep > 0) {
190190 try makePath(allocator, path[0..sep]);
191191 // Retry creating the directory
192 const retry_z = try allocator.dupeZ(u8, path);
192 const retry_z = try allocator.dupeSentinel(u8, path, 0);
193193 defer allocator.free(retry_z);
194194 const rc2 = std.c.mkdir(retry_z, 0o755);
195195 if (rc2 != 0 and std.c.errno(rc2) != .EXIST) {
@@ -298,7 +298,7 @@ pub fn spawnAndWait(
298298 defer allocator.free(c_argv);
299299
300300 for (argv, 0..) |arg, i| {
301 const z = try allocator.dupeZ(u8, arg);
301 const z = try allocator.dupeSentinel(u8, arg, 0);
302302 c_argv[i] = z.ptr;
303303 }
304304 c_argv[argv.len] = null;
src/snapshot.zigmodified+8-8
Changes to src/snapshot.zig
@@ -251,16 +251,16 @@ pub const Snapshot = struct {
251251 },
252252 .@"struct" => {
253253 try writer.writeAll("{\n");
254 inline for (type_info.@"struct".fields, 0..) |field, i| {
254 inline for (type_info.@"struct".field_names, 0..) |field_name, i| {
255255 if (self.options.pretty_print) {
256256 try writer.writeAll(" ");
257257 }
258 try writer.print("\"{s}\": ", .{field.name});
258 try writer.print("\"{s}\": ", .{field_name});
259259
260 const field_value = @field(value, field.name);
260 const field_value = @field(value, field_name);
261261 try self.formatJsonValue(writer, field_value);
262262
263 if (i < type_info.@"struct".fields.len - 1) {
263 if (i < type_info.@"struct".field_names.len - 1) {
264264 try writer.writeAll(",");
265265 }
266266 if (self.options.pretty_print) {
@@ -307,10 +307,10 @@ pub const Snapshot = struct {
307307
308308 try writer.writeAll("{\n");
309309
310 inline for (type_info.@"struct".fields, 0..) |field, i| {
311 try writer.print(" \"{s}\": ", .{field.name});
310 inline for (type_info.@"struct".field_names, 0..) |field_name, i| {
311 try writer.print(" \"{s}\": ", .{field_name});
312312
313 const field_value = @field(value, field.name);
313 const field_value = @field(value, field_name);
314314 const FieldType = @TypeOf(field_value);
315315 const field_info = @typeInfo(FieldType);
316316
@@ -328,7 +328,7 @@ pub const Snapshot = struct {
328328 else => try writer.print("{any}", .{field_value}),
329329 }
330330
331 if (i < type_info.@"struct".fields.len - 1) {
331 if (i < type_info.@"struct".field_names.len - 1) {
332332 try writer.writeAll(",\n");
333333 } else {
334334 try writer.writeAll("\n");