summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2024-11-10 19:38:45 +0100
committerMaxime Coste <mawww@kakoune.org>2024-11-11 21:30:01 +1100
commit8c74660ad3ede76107b4a2f450c27a9202b79937 (patch)
treed6ec1587a8a766a971c08f7bd82e6d9577bbd151
parent66aa444c6f94bc539d23d47a8e58b4909accbd64 (diff)
Remove noisy output from tests
"ui_out -until-grep" invocations used to redirect the output from grep, usually to /dev/null. Looks like the intention of 60fcc3443 (Change ui_out -until-grep to check for equality the next argument, 2024-11-02) was that grep no longer needs to print output, since we can assert instead which is mildly better. Unfortunately there are two places where -until-grep might not be powerful enough, which is why we capture the output and check it in the test script. For one of them we can use -until-grep with a small change. Not yet sure about the other one. Let's try to use eval instead, so we can silence the output. I realize -until-eval is not great (the nested quoting is ugly) but I guess it's better than the status quo. Alternatively, we could print output only if the [expected] argument is not given, and add >/dev/null to the other invocations.
-rwxr-xr-xtest/run4
-rw-r--r--test/tools/git/blame-in-diff/script2
-rw-r--r--test/tools/git/blame-jump-message/script7
3 files changed, 4 insertions, 9 deletions
diff --git a/test/run b/test/run
index 99093c10..a26642da 100755
--- a/test/run
+++ b/test/run
@@ -198,11 +198,11 @@ ui_out() {
[ "$event" = "$expected" ] && break
done
;;
- -until-grep)
+ -until-eval | -until-grep)
pattern=$1
shift
while read -r event <&4; do
- if printf %s "$event" | grep "$pattern"; then
+ if printf %s "$event" | "${arg#-until-}" "$pattern" >/dev/null; then
if [ $# -ne 0 ]; then
assert_eq "$1" "$event"
shift
diff --git a/test/tools/git/blame-in-diff/script b/test/tools/git/blame-in-diff/script
index e22b3ec8..0cee0ca7 100644
--- a/test/tools/git/blame-in-diff/script
+++ b/test/tools/git/blame-in-diff/script
@@ -3,7 +3,7 @@ ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [false] }'
# 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>" ] }'
-while ui_out -until-grep '"draw_status"' | grep '\[fifo\]'; do :; done > /dev/null
+ui_out -until-eval 'grep "draw_status" | grep -v "\[fifo\]"'
# We should have jumped to the old version of line 2, assert on kak_selection.
ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "x" ] }'
diff --git a/test/tools/git/blame-jump-message/script b/test/tools/git/blame-jump-message/script
index 9f6fb6e0..92b1f670 100644
--- a/test/tools/git/blame-jump-message/script
+++ b/test/tools/git/blame-jump-message/script
@@ -1,8 +1,3 @@
-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)
-
expected_subject=$(cat <<'EOF'
2017-07-14 A U Thor "Don't break on single quotes or unbalanced {"
EOF
@@ -10,5 +5,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 "$expected_draw_status" "$actual_draw_status"
+ui_out -until-grep 'draw_status.*single quotes' "$expected_draw_status"
ui_out -ignore 2