summaryrefslogtreecommitdiff
path: root/test/session.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/session.zig')
-rw-r--r--test/session.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/session.zig b/test/session.zig
index 06cd3a32..cd04ecb8 100644
--- a/test/session.zig
+++ b/test/session.zig
@@ -107,6 +107,7 @@ pub const Session = struct {
pub fn deinit(s: *Session) void {
s.held.deinit(pardesOf(s).gpa);
+ if (s.hold_jobs) pardes.Kind.drawer = null;
if (s.watch_fd >= 0) {
pardes.file_watch.unwatchAll(s.watch_fd, &s.watches);
_ = std.c.close(s.watch_fd);
@@ -310,6 +311,19 @@ pub const Session = struct {
return true;
}
+ /// Kinds' jobs and draws held from now on (`hold_jobs`), until
+ /// `releaseJobs`.
+ pub fn holdJobs(s: *Session) void {
+ s.hold_jobs = true;
+ pardes.Kind.drawer = .{ .ctx = s, .go = struct {
+ fn go(ctx: ?*anyopaque, j: *pardes.host_io.KindJob) bool {
+ const ss: *Session = @ptrCast(@alignCast(ctx));
+ ss.held.append(pardesOf(ss).gpa, j) catch return false;
+ return true;
+ }
+ }.go };
+ }
+
/// The jobs held run now, as a worker runs them, their answers held
/// still: what a test does next happens while they are under way.
pub fn runJobs(s: *Session) void {
@@ -320,6 +334,7 @@ pub const Session = struct {
/// The jobs held, run now and answered as the host's workers would.
pub fn releaseJobs(s: *Session) void {
s.hold_jobs = false;
+ pardes.Kind.drawer = null;
for (s.held.items, 0..) |j, i| {
if (i >= s.ran) j.run();
j.land(pardesOf(s));