summaryrefslogtreecommitdiff
path: root/test/process_test.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/process_test.zig')
-rw-r--r--test/process_test.zig33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/process_test.zig b/test/process_test.zig
new file mode 100644
index 00000000..9924b9dd
--- /dev/null
+++ b/test/process_test.zig
@@ -0,0 +1,33 @@
+//! 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/other_files.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);
+}