On Mi, 04 Sep 2019, Bram Moolenaar wrote:

> Hmm, since nobody runs the tests manually that doesn't help much.
> How about using a screendump?  That makes these things a lot easier to
> write.

Okay, how about the attached patch then? That fails with v8.1.1965 and 
should work with v8.1.1970

Best,
Christian
-- 
Sargdeckel fällt - die Witwe kichert, der Bauer war wohl gut versichert.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/20190904120126.GQ25942%40256bit.org.
From b6f44bc8cef68df3baf291ed6957eb3a61b50412 Mon Sep 17 00:00:00 2001
From: Christian Brabandt <c...@256bit.org>
Date: Wed, 4 Sep 2019 13:54:09 +0200
Subject: [PATCH] Add screendump test

---
 src/testdir/dumps/Test_searchstat_1.dump | 10 +++++++
 src/testdir/dumps/Test_searchstat_2.dump | 10 +++++++
 src/testdir/test_search_stat.vim         | 35 ++++++++++++++++++++----
 3 files changed, 50 insertions(+), 5 deletions(-)
 create mode 100644 src/testdir/dumps/Test_searchstat_1.dump
 create mode 100644 src/testdir/dumps/Test_searchstat_2.dump

diff --git a/src/testdir/dumps/Test_searchstat_1.dump b/src/testdir/dumps/Test_searchstat_1.dump
new file mode 100644
index 000000000..52b13f2dc
--- /dev/null
+++ b/src/testdir/dumps/Test_searchstat_1.dump
@@ -0,0 +1,10 @@
+|f+0&#ffffff0|o@1|b|a|r| @68
+>f|i|n|d| |t|h|i|s| @65
+|f|o@4|b|a|r| @65
+|f|o|b|a| @70
+|f|o@1|b|a|r| @68
+|f|o@1|b|a|r| @68
+|f|o@1| @71
+|f|o@4|b|a|r| @65
+|f|o|b|a| @70
+|/|f|i|n|d| |t|h|i|s| @29|[|1|/|2|]| @11|2|,|1| @10|T|o|p| 
diff --git a/src/testdir/dumps/Test_searchstat_2.dump b/src/testdir/dumps/Test_searchstat_2.dump
new file mode 100644
index 000000000..a6ced4fd0
--- /dev/null
+++ b/src/testdir/dumps/Test_searchstat_2.dump
@@ -0,0 +1,10 @@
+|f+0&#ffffff0|o@1|b|a|r| @68
+>f|i|n|d| |t|h|i|s| @65
+|f|o@4|b|a|r| @65
+|f|o|b|a| @70
+|f|o@1|b|a|r| @68
+|f|o@1|b|a|r| @68
+|f|o@1| @71
+|f|o@4|b|a|r| @65
+|f|o|b|a| @70
+@40|[|1|/|2|]| @11|2|,|1| @10|T|o|p| 
diff --git a/src/testdir/test_search_stat.vim b/src/testdir/test_search_stat.vim
index d5d50ff1d..9290c2f87 100644
--- a/src/testdir/test_search_stat.vim
+++ b/src/testdir/test_search_stat.vim
@@ -1,9 +1,7 @@
 " Tests for search_stats, when "S" is not in 'shortmess'
-"
-" This test is fragile, it might not work interactively, but it works when run
-" as test!
 
-source shared.vim
+source check.vim
+source screendump.vim
 
 func! Test_search_stat()
   new
@@ -181,7 +179,34 @@ func! Test_search_stat()
 
   " Clean up
   set shortmess+=S
-
   " close the window
   bwipe!
 endfunc
+
+func! Test_search_stat_screendump()
+  CheckScreendump
+
+  let lines =<< trim END
+    set shortmess-=S
+    " Append 50 lines with text to search for, "foobar" appears 20 times
+    call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 20))
+    call setline(2, 'find this')
+    call setline(70, 'find this')
+    nnoremap n n
+    let @/ = 'find this'
+    call cursor(1,1)
+    norm n
+  END
+  call writefile(lines, 'Xsearchstat')
+  let buf = RunVimInTerminal('-S Xsearchstat', #{rows: 10})
+  call term_wait(buf)
+  call VerifyScreenDump(buf, 'Test_searchstat_1', {})
+
+  call term_sendkeys(buf, ":nnoremap <silent> n n\<cr>")
+  call term_sendkeys(buf, "gg0n")
+  call term_wait(buf)
+  call VerifyScreenDump(buf, 'Test_searchstat_2', {})
+
+  call StopVimInTerminal(buf)
+  call delete('XscriptMatchCommon')
+endfunc
-- 
2.20.1

Reply via email to