diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/snapshot.zig | 9 | ||||
| -rw-r--r-- | test/snapshots/wheeldrift.golden | 85 | ||||
| -rw-r--r-- | test/snapshots/wheeldrift.snap | 45 |
3 files changed, 137 insertions, 2 deletions
diff --git a/test/snapshot.zig b/test/snapshot.zig index aeb01187..4344654c 100644 --- a/test/snapshot.zig +++ b/test/snapshot.zig @@ -26,7 +26,7 @@ // // Script commands (line-oriented, # comments): // file <name> <content> create file in the script's cwd (before start) -// lines <name> <n> create file with n numbered lines +// lines <name> <n> [tail] create file with n numbered lines, tail on each // dirmk <name> create a subdirectory // start <rows> <cols> [arg] fork the app in a pty (optional extra CLI arg) // wait <ms> <needle...> pump until needle appears on the grid (fails hard) @@ -346,8 +346,13 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const } else if (std.mem.eql(u8, cmd, "lines")) { const name = tok.next() orelse return error.BadScript; const n = try std.fmt.parseInt(usize, tok.next() orelse return error.BadScript, 10); + // anything after the count is glued onto every line (no separator: + // `rest` eats the delimiter, so spell one in the tail if you want + // one) — a file that is long AND wide, which is what a horizontal + // scroll test needs and `file` can only give as one huge script line + const tail = tok.rest(); var buf: std.ArrayList(u8) = .empty; - for (1..n + 1) |i| try buf.appendSlice(arena, try std.fmt.allocPrint(arena, "line {d}\n", .{i})); + for (1..n + 1) |i| try buf.appendSlice(arena, try std.fmt.allocPrint(arena, "line {d}{s}\n", .{ i, tail })); try eh.writeFile(try arena.dupeZ(u8, name), buf.items); } else if (std.mem.eql(u8, cmd, "ppmdiag")) { // The diagonal-split test PPM from the old e2e (white over blue), diff --git a/test/snapshots/wheeldrift.golden b/test/snapshots/wheeldrift.golden new file mode 100644 index 00000000..44d40eef --- /dev/null +++ b/test/snapshots/wheeldrift.golden @@ -0,0 +1,85 @@ +== snap home grid=70x16 cursor=7,2 +|Kill Newcol Tutor Debug NextColor Dump Find Grep Help +| NOR /tmp/pardes-snap/wheeldrift/c NOR /tmp/pardes-snap/wheeldrift/c +| 1 line 1_0123456789_abcdefghij +| 2 line 2_0123456789_abcdefghij drift.txt +| 3 line 3_0123456789_abcdefghij +| 4 line 4_0123456789_abcdefghij +| 5 line 5_0123456789_abcdefghij +| 6 line 6_0123456789_abcdefghij +| 7 line 7_0123456789_abcdefghij +| 8 line 8_0123456789_abcdefghij +| 9 line 9_0123456789_abcdefghij +| 10 line 10_0123456789_abcdefghi +| 11 line 11_0123456789_abcdefghi +| 12 line 12_0123456789_abcdefghi +| 13 line 13_0123456789_abcdefghi +| 14 line 14_0123456789_abcdefghi +== snap drifted grid=70x16 cursor=7,2 +|Kill Newcol Tutor Debug NextColor Dump Find Grep Help +| NOR /tmp/pardes-snap/wheeldrift/c NOR /tmp/pardes-snap/wheeldrift/c +| 6 line 6_0123456789_abcdefghij +| 7 line 7_0123456789_abcdefghij drift.txt +| 8 line 8_0123456789_abcdefghij +| 9 line 9_0123456789_abcdefghij +| 10 line 10_0123456789_abcdefghi +| 11 line 11_0123456789_abcdefghi +| 12 line 12_0123456789_abcdefghi +| 13 line 13_0123456789_abcdefghi +| 14 line 14_0123456789_abcdefghi +| 15 line 15_0123456789_abcdefghi +| 16 line 16_0123456789_abcdefghi +| 17 line 17_0123456789_abcdefghi +| 18 line 18_0123456789_abcdefghi +| 19 line 19_0123456789_abcdefghi +== snap paying grid=70x16 cursor=7,2 +|Kill Newcol Tutor Debug NextColor Dump Find Grep Help +| NOR /tmp/pardes-snap/wheeldrift/c NOR /tmp/pardes-snap/wheeldrift/c +| 6 line 6_0123456789_abcdefghij +| 7 line 7_0123456789_abcdefghij drift.txt +| 8 line 8_0123456789_abcdefghij +| 9 line 9_0123456789_abcdefghij +| 10 line 10_0123456789_abcdefghi +| 11 line 11_0123456789_abcdefghi +| 12 line 12_0123456789_abcdefghi +| 13 line 13_0123456789_abcdefghi +| 14 line 14_0123456789_abcdefghi +| 15 line 15_0123456789_abcdefghi +| 16 line 16_0123456789_abcdefghi +| 17 line 17_0123456789_abcdefghi +| 18 line 18_0123456789_abcdefghi +| 19 line 19_0123456789_abcdefghi +== snap moved grid=70x16 cursor=7,2 +|Kill Newcol Tutor Debug NextColor Dump Find Grep Help +| NOR /tmp/pardes-snap/wheeldrift/c NOR /tmp/pardes-snap/wheeldrift/c +| 6 123456789_abcdefghij_ZEND +| 7 123456789_abcdefghij_ZEND drift.txt +| 8 123456789_abcdefghij_ZEND +| 9 123456789_abcdefghij_ZEND +| 10 0123456789_abcdefghij_ZEND +| 11 0123456789_abcdefghij_ZEND +| 12 0123456789_abcdefghij_ZEND +| 13 0123456789_abcdefghij_ZEND +| 14 0123456789_abcdefghij_ZEND +| 15 0123456789_abcdefghij_ZEND +| 16 0123456789_abcdefghij_ZEND +| 17 0123456789_abcdefghij_ZEND +| 18 0123456789_abcdefghij_ZEND +| 19 0123456789_abcdefghij_ZEND +== snap rearmed grid=70x16 cursor=7,2 +|Kill Newcol Tutor Debug NextColor Dump Find Grep Help +| NOR /tmp/pardes-snap/wheeldrift/c NOR /tmp/pardes-snap/wheeldrift/c +| 5 123456789_abcdefghij_ZEND +| 6 123456789_abcdefghij_ZEND drift.txt +| 7 123456789_abcdefghij_ZEND +| 8 123456789_abcdefghij_ZEND +| 9 123456789_abcdefghij_ZEND +| 10 0123456789_abcdefghij_ZEND +| 11 0123456789_abcdefghij_ZEND +| 12 0123456789_abcdefghij_ZEND +| 13 0123456789_abcdefghij_ZEND +| 14 0123456789_abcdefghij_ZEND +| 15 0123456789_abcdefghij_ZEND +| 16 0123456789_abcdefghij_ZEND +| 17 0123456789_abcdefghij_ZEND +| 18 0123456789_abcdefghij_ZEND diff --git a/test/snapshots/wheeldrift.snap b/test/snapshots/wheeldrift.snap new file mode 100644 index 00000000..a546d2ff --- /dev/null +++ b/test/snapshots/wheeldrift.snap @@ -0,0 +1,45 @@ +# the touchpad drift guard (config.wheel_guard_ticks). A two-finger swipe that +# is MEANT to be vertical carries a little sideways drift and the pad turns it +# into wheel_left/wheel_right, so the view used to slide sideways under a plain +# scroll. Every vertical tick re-arms the guard; a horizontal tick spends one +# instead of scrolling. SGR codes are vaxis's: 64/65 = wheel up/down (the +# `wheel` command), 66/67 = wheel RIGHT/left, sent raw as hscroll.snap does. +# The drift ticks here are all rightward on purpose: leftward drift at column 0 +# is clamped away and would prove nothing. +lines drift.txt 20 _0123456789_abcdefghij_ZEND +start 16 70 drift.txt +wait 8000 drift.txt +stable 700 20000 +snap home +# a drifting swipe: five ticks down with three sideways ones mixed in. The +# view scrolls DOWN five lines and does not move one column sideways. +wheel down 10 5 +wheel down 10 5 +send \x1b[<66;10;5M +wheel down 10 5 +send \x1b[<66;10;5M +send \x1b[<66;10;5M +wheel down 10 5 +wheel down 10 5 +stable 400 5000 +snap drifted +# the guard is armed at 3 now, so a DELIBERATE horizontal swipe pays it off +# first: these three ticks still move nothing (without the guard they would +# have shifted the text 12 columns) +send \x1b[<66;10;5M +send \x1b[<66;10;5M +send \x1b[<66;10;5M +stable 400 5000 +snap paying +# ...and from the fourth tick on it scrolls freely: two ticks, 8 columns +send \x1b[<66;10;5M +send \x1b[<66;10;5M +stable 400 5000 +snap moved +# vertical again re-arms the guard, so drift is swallowed once more even +# though horizontal was just running +wheel up 10 5 +send \x1b[<66;10;5M +send \x1b[<66;10;5M +stable 400 5000 +snap rearmed |
