1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
//! The process tests (T2 of docs/next-tests.md): each case starts a real
//! pardes through test/process.zig and drives it over its socket. A file
//! in test/process/ a section of the book, as test/behaviour/'s are.
//!
//! pardes-process-test <pardes> [filter]
const std = @import("std");
const files = .{
@import("process/builtins.zig"),
@import("process/flags.zig"),
@import("process/look_and_exec.zig"),
@import("process/mounts.zig"),
@import("process/other_files.zig"),
@import("process/repls.zig"),
@import("process/root_ctl.zig"),
@import("process/tree.zig"),
};
pub fn main(init: std.process.Init) !void {
const args = try init.minimal.args.toSlice(init.arena.allocator());
if (args.len < 2) return error.Usage;
const exe = args[1];
const filter: []const u8 = if (args.len > 2) args[2] else "";
const gpa = std.heap.page_allocator;
var failed: usize = 0;
var ran: usize = 0;
inline for (files) |file| inline for (file.cases) |case| {
if (std.mem.indexOf(u8, case[0], filter) != null) {
ran += 1;
if (case[1](gpa, exe)) {
std.debug.print("PASS {s}\n", .{case[0]});
} else |err| {
failed += 1;
std.debug.print("FAIL {s}: {t}\n", .{ case[0], err });
}
}
};
std.debug.print("{d} of {d} process tests failed\n", .{ failed, ran });
if (failed > 0 or ran == 0) std.process.exit(1);
}
|