Mercurial > vim
diff src/testdir/screendump.vim @ 30519:4a88061200c2 v9.0.0595
patch 9.0.0595: extra newline in messages after a verbose shell message
Commit: https://github.com/vim/vim/commit/1190139ed01c27539615beea9559a88b2551daf3
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 26 19:50:44 2022 +0100
patch 9.0.0595: extra newline in messages after a verbose shell message
Problem: Extra newline in messages after a verbose shell message.
Solution: Output the newline with msg_putchar_attr(). (closes https://github.com/vim/vim/issues/11233)
Make it possible to filter a screendump before comparing it.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 26 Sep 2022 21:00:04 +0200 |
parents | 9dce192d1ac2 |
children | 9d1ff79eebbb |
line wrap: on
line diff
--- a/src/testdir/screendump.vim +++ b/src/testdir/screendump.vim @@ -13,16 +13,43 @@ if !has('terminal') finish endif +" Read a dump file "fname" and if "filter" exists apply it to the text. +def ReadAndFilter(fname: string, filter: string): list<string> + var contents = readfile(fname) + + if filereadable(filter) + # do this in the bottom window so that the terminal window is unaffected + wincmd j + enew + setline(1, contents) + exe "source " .. filter + contents = getline(1, '$') + enew! + wincmd k + redraw + endif + + return contents +enddef + + " Verify that Vim running in terminal buffer "buf" matches the screen dump. " "options" is passed to term_dumpwrite(). " Additionally, the "wait" entry can specify the maximum time to wait for the " screen dump to match in msec (default 1000 msec). " The file name used is "dumps/{filename}.dump". +" +" To ignore part of the dump, provide a "dumps/{filename}.vim" file with +" Vim commands to be applied to both the reference and the current dump, so +" that parts that are irrelevant are not used for the comparison. The result +" is NOT written, thus "term_dumpdiff()" shows the difference anyway. +" " Optionally an extra argument can be passed which is prepended to the error " message. Use this when using the same dump file with different options. " Returns non-zero when verification fails. func VerifyScreenDump(buf, filename, options, ...) let reference = 'dumps/' . a:filename . '.dump' + let filter = 'dumps/' . a:filename . '.vim' let testfile = 'failed/' . a:filename . '.dump' let max_loops = get(a:options, 'wait', 1000) / 10 @@ -37,6 +64,13 @@ func VerifyScreenDump(buf, filename, opt " text and attributes only from the internal buffer. redraw + if filereadable(reference) + let refdump = ReadAndFilter(reference, filter) + else + " Must be a new screendump, always fail + let refdump = [] + endif + let did_mkdir = 0 if !isdirectory('failed') let did_mkdir = 1 @@ -49,13 +83,7 @@ func VerifyScreenDump(buf, filename, opt sleep 10m call delete(testfile) call term_dumpwrite(a:buf, testfile, a:options) - let testdump = readfile(testfile) - if filereadable(reference) - let refdump = readfile(reference) - else - " Must be a new screendump, always fail - let refdump = [] - endif + let testdump = ReadAndFilter(testfile, filter) if refdump == testdump call delete(testfile) if did_mkdir