Fix tests that were failing on alpine

Ensure perl exists for git blame tests, replace timing sensitive
`ui_out -ignore ...` with `ui_out -until '...'`
This commit is contained in:
Maxime Coste 2024-05-10 12:04:27 +10:00
parent b4a485a1e4
commit 8c2775f665
6 changed files with 20 additions and 17 deletions

View File

@ -1,19 +1,18 @@
ui_out -ignore 7
ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [true] }'
exec 5>fifo
ui_out '{ "jsonrpc": "2.0", "method": "refresh", "params": [true] }'
echo '* line1' >&5
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "*" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " line1\u000a" }]], { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }] }'
ui_out -ignore 2
ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [false] }'
echo '* line2' >&5
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "*" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " line1\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "* line2\u000a" }]], { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }] }'
ui_out -ignore 2
ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [false] }'
dd if=/dev/zero bs=2049 count=1 2>/dev/null | sed s/././g >&5
ui_out -ignore 3
ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [false] }'
ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "gjxH|wc -c | tr -d \" \"<ret>" ] }'
ui_out -ignore 6
ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [false] }'
exec 5>&-
ui_out '{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "*fifo* 3:4 " }, { "face": { "fg": "black", "bg": "yellow", "underline": "default", "attributes": [] }, "contents": "[scratch]" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " - client0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "underline": "default", "attributes": [] }] }'
ui_out -until '{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "*fifo* 3:4 " }, { "face": { "fg": "black", "bg": "yellow", "underline": "default", "attributes": [] }, "contents": "[scratch]" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " - client0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "underline": "default", "attributes": [] }] }'

View File

@ -190,6 +190,12 @@ ui_out() {
skip_count=$(( skip_count - 1 ))
done
;;
-until)
shift
while read -r event <&4; do
[ "$event" == "$1" ] && break
done
;;
-until-grep)
shift
while

View File

@ -1,2 +1,2 @@
#!/bin/sh
command -v git >/dev/null
command -v git >/dev/null && command -v perl >/dev/null

View File

@ -1,11 +1,10 @@
ui_out -ignore 7
ui_out -ignore 11
ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [true] }'
# We've jumped to the new version of line 2. Move to the old version so we
# can annotate the old file.
ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "k:git blame<ret>" ] }'
ui_out -ignore 11
ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [false] }'
# We should have jumped to the old version of line 2, assert on kak_selection.
ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "x" ] }'
ui_out -ignore 5
ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [false] }'

View File

@ -1,2 +1,2 @@
#!/bin/sh
command -v git >/dev/null
command -v git >/dev/null && command -v perl >/dev/null

View File

@ -1,6 +1,5 @@
while ! ui_out -until-grep draw_status | grep -v '\[fifo\]' >/dev/null;
do
:
while true; do
ui_out -until-grep draw_status | grep -v '\[fifo\]' >/dev/null && break
done
actual_draw_status=$(ui_out -until-grep draw_status)
@ -11,5 +10,5 @@ EOF
expected_subject_json=\"$(printf '%s' "$expected_subject" | sed 's/"/\\"/g')\"
expected_draw_status='{ "jsonrpc": "2.0", "method": "draw_status", "params": [[{ "face": { "fg": "black", "bg": "yellow", "underline": "default", "attributes": [] }, "contents": '"$expected_subject_json"' }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "*git* 13:2 " }, { "face": { "fg": "black", "bg": "yellow", "underline": "default", "attributes": [] }, "contents": "[scratch]" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " - client0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "underline": "default", "attributes": [] }] }'
assert_eq "$actual_draw_status" "$expected_draw_status"
assert_eq "$expected_draw_status" "$actual_draw_status"
ui_out -ignore 2