summaryrefslogtreecommitdiff
path: root/test/session.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/session.zig')
-rw-r--r--test/session.zig14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/session.zig b/test/session.zig
index 056966b9..06cd3a32 100644
--- a/test/session.zig
+++ b/test/session.zig
@@ -43,6 +43,8 @@ pub const Session = struct {
/// meanwhile (a reload).
hold_jobs: bool = false,
held: std.ArrayList(*pardes.host_io.KindJob) = .empty,
+ /// Of `held`, those run already (`runJobs`), their answers still held.
+ ran: usize = 0,
/// The files the core asked to watch, watched as a host watches them
/// (file_watch.zig, inotify): `filesChanged` wakes them.
watch_fd: c_int = -1,
@@ -308,14 +310,22 @@ pub const Session = struct {
return true;
}
+ /// 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 {
+ for (s.held.items[s.ran..]) |j| j.run();
+ s.ran = s.held.items.len;
+ }
+
/// The jobs held, run now and answered as the host's workers would.
pub fn releaseJobs(s: *Session) void {
s.hold_jobs = false;
- for (s.held.items) |j| {
- j.run();
+ for (s.held.items, 0..) |j, i| {
+ if (i >= s.ran) j.run();
j.land(pardesOf(s));
}
s.held.clearRetainingCapacity();
+ s.ran = 0;
s.drain();
}