summaryrefslogtreecommitdiff
path: root/test/process
diff options
context:
space:
mode:
Diffstat (limited to 'test/process')
-rw-r--r--test/process/look_and_exec.zig14
-rw-r--r--test/process/terminals.zig17
2 files changed, 4 insertions, 27 deletions
diff --git a/test/process/look_and_exec.zig b/test/process/look_and_exec.zig
index 9829797b..8ba52534 100644
--- a/test/process/look_and_exec.zig
+++ b/test/process/look_and_exec.zig
@@ -118,18 +118,8 @@ fn canary(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
// A terminal: pty/run failing then passing.
const term = try f.madeBy(1, "Term\n");
- {
- const deadline = process.nowMs() + 10_000;
- while (true) {
- const answer = try f.run(term, "true\n");
- if (std.mem.eql(u8, answer, "exit 0\n")) break;
- if (process.nowMs() > deadline) {
- std.debug.print("pty/run answered {s}\n", .{answer});
- return error.Timeout;
- }
- process.nap(50);
- }
- }
+ // Asked at once: a run waits for its first prompt and its greeting.
+ try std.testing.expectEqualStrings("exit 0\n", try f.run(term, "true\n"));
try std.testing.expectEqualStrings("exit 1\n", try f.run(term, "false\n"));
try std.testing.expectEqualStrings("exit 0\npassed\n", try f.run(term, "echo passed\n"));
// (A run's answer is its record: the log has no err for these.)
diff --git a/test/process/terminals.zig b/test/process/terminals.zig
index 151b221b..8d595120 100644
--- a/test/process/terminals.zig
+++ b/test/process/terminals.zig
@@ -111,15 +111,6 @@ fn sizeLines(a: std.mem.Allocator, c: *process.Conn, n: u32) ![]const []const u8
return out.items;
}
-/// A shell takes runs: its first prompt, or the one started again.
-fn prompted(a: std.mem.Allocator, c: *process.Conn, term: u32) !void {
- const deadline = eh.nowMs() + 10_000;
- while (!std.mem.eql(u8, try run(a, c, term, "true\n"), "exit 0\n")) {
- if (eh.nowMs() > deadline) return error.NoPrompt;
- process.sleep(50);
- }
-}
-
fn sizedFork(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
var d = try process.Detached.start(gpa, exe, "sized", .{});
defer d.deinit();
@@ -135,7 +126,7 @@ fn sizedFork(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
// the screen's 160x50.
try c.write("/exec", "Term\n");
const term = try c.newest(gpa);
- try prompted(a, c, term);
+ // Asked at once: a run waits for its first prompt and its greeting.
var got = try sttySize(a, c, term);
try expect(!std.mem.eql(u8, got[1], "50 160"));
try expectEqualStrings(got[1], got[0]);
@@ -200,11 +191,7 @@ fn runFile(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
const serial = try std.fmt.parseInt(u32, w.next().?, 10);
if (std.mem.eql(u8, w.next().?, "term")) term = @max(term, serial);
}
- const deadline = eh.nowMs() + 10_000;
- while (std.mem.eql(u8, try run(a, c, term, "true\n"), "busy\n")) { // deadline its first prompt
- if (eh.nowMs() > deadline) return error.NoPrompt;
- process.sleep(50);
- }
+ try expectEqualStrings("exit 0\n", try run(a, c, term, "true\n")); // asked at once: it waits for the first prompt, and the greeting's
try expectEqualStrings("exit 1\n", try run(a, c, term, "false\n"));
try expectEqualStrings("exit 0\none\ntwo\n", try run(a, c, term, "printf \"one\\ntwo\\n\"\n")); // then what it printed
try expectEqualStrings("exit 7\n", try run(a, c, term, "sh -c \"exit 7\"\n"));