From 8c2775f665fd4aae603b423362cf0d4d917fc0df Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 10 May 2024 12:04:27 +1000 Subject: [PATCH] Fix tests that were failing on alpine Ensure perl exists for git blame tests, replace timing sensitive `ui_out -ignore ...` with `ui_out -until '...'` --- test/commands/edit-fifo-noscroll/script | 13 ++++++------- test/run | 6 ++++++ test/tools/git/blame-in-diff/enabled | 2 +- test/tools/git/blame-in-diff/script | 7 +++---- test/tools/git/blame-jump-message/enabled | 2 +- test/tools/git/blame-jump-message/script | 7 +++---- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/test/commands/edit-fifo-noscroll/script b/test/commands/edit-fifo-noscroll/script index f64e1a77..3a719e6a 100644 --- a/test/commands/edit-fifo-noscroll/script +++ b/test/commands/edit-fifo-noscroll/script @@ -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 \" \"" ] }' -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": [] }] }' diff --git a/test/run b/test/run index 95f71a9e..e26aea05 100755 --- a/test/run +++ b/test/run @@ -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 diff --git a/test/tools/git/blame-in-diff/enabled b/test/tools/git/blame-in-diff/enabled index a041a9b4..b5b89081 100755 --- a/test/tools/git/blame-in-diff/enabled +++ b/test/tools/git/blame-in-diff/enabled @@ -1,2 +1,2 @@ #!/bin/sh -command -v git >/dev/null +command -v git >/dev/null && command -v perl >/dev/null diff --git a/test/tools/git/blame-in-diff/script b/test/tools/git/blame-in-diff/script index e5ca34b2..6adda922 100644 --- a/test/tools/git/blame-in-diff/script +++ b/test/tools/git/blame-in-diff/script @@ -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" ] }' -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] }' diff --git a/test/tools/git/blame-jump-message/enabled b/test/tools/git/blame-jump-message/enabled index a041a9b4..b5b89081 100755 --- a/test/tools/git/blame-jump-message/enabled +++ b/test/tools/git/blame-jump-message/enabled @@ -1,2 +1,2 @@ #!/bin/sh -command -v git >/dev/null +command -v git >/dev/null && command -v perl >/dev/null diff --git a/test/tools/git/blame-jump-message/script b/test/tools/git/blame-jump-message/script index 67834a40..9f6fb6e0 100644 --- a/test/tools/git/blame-jump-message/script +++ b/test/tools/git/blame-jump-message/script @@ -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