From f786fceb7392faf7aa4d053ffda5737e0630d4df Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 18 Feb 2024 01:16:53 +0100 Subject: Fix flaky blame-jump-message test This test fails occasionally[1] because the order of events and the number of events varies across runs. We should always call draw_status exactly 3 times: [*git*][fifo] [*git*] Commit subject etc. [*git*] Let's check it this way. This seems to work; this time I took the time to run it a couple hundred times and in Cirrus CI. [1] https://builds.sr.ht/~mawww/job/1151239 --- test/tools/git/blame-jump-message/script | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'test/tools/git') diff --git a/test/tools/git/blame-jump-message/script b/test/tools/git/blame-jump-message/script index 33e01b6f..5edea930 100644 --- a/test/tools/git/blame-jump-message/script +++ b/test/tools/git/blame-jump-message/script @@ -1,10 +1,14 @@ -ui_out -ignore 7 -ui_out -ignore 4 +for _ in fifo-opened fifo-closed blame-info +do + actual_draw_status=$(ui_out -until-grep draw_status) +done -ui_out -ignore 3 -subject=$(cat <<'EOF' +expected_subject=$(cat <<'EOF' 2017-07-14 A U Thor "Don't break on single quotes or unbalanced {" EOF ) -json_quoted_subject=\"$(printf '%s' "$subject" | sed 's/"/\\"/g')\" -ui_out -within-next 3 '{ "jsonrpc": "2.0", "method": "draw_status", "params": [[{ "face": { "fg": "black", "bg": "yellow", "underline": "default", "attributes": [] }, "contents": '"$json_quoted_subject"' }], [{ "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": [] }] }' +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" +ui_out -ignore 2 -- cgit v1.2.3