diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-02-20 15:51:40 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-02-20 15:51:40 +0100 |
commit | da65058a9c4774dc534c7ae98d24c58b5db669fa (patch) | |
tree | 3b9c05511fd12c806a8cbec528b30f073c24cbe5 /src/testdir/screendump.vim | |
parent | 7a76092a51fc5446426a4bfd9eb6503ec61bf9e9 (diff) | |
download | vim-git-da65058a9c4774dc534c7ae98d24c58b5db669fa.tar.gz |
patch 8.0.1526: no test using a screen dump yetv8.0.1526
Problem: No test using a screen dump yet.
Solution: Add a test for C syntax highlighting. Add helper functions.
Diffstat (limited to 'src/testdir/screendump.vim')
-rw-r--r-- | src/testdir/screendump.vim | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/testdir/screendump.vim b/src/testdir/screendump.vim new file mode 100644 index 000000000..5131b935a --- /dev/null +++ b/src/testdir/screendump.vim @@ -0,0 +1,65 @@ +" Functions shared by tests making screen dumps. + +" Only load this script once. +if exists('*RunVimInTerminal') + finish +endif + +source shared.vim + +" Run Vim with "arguments" in a new terminal window. +" By default uses a size of 20 lines and 75 columns. +" Returns the buffer number of the terminal. +" +" Options is a dictionary (not used yet). +func RunVimInTerminal(arguments, options) + " Make a horizontal and vertical split, so that we can get exactly the right + " size terminal window. Works only when we currently have one window. + call assert_equal(1, winnr('$')) + split + vsplit + + " Always doo this with 256 colors and a light background. + set t_Co=256 + hi Normal ctermfg=0 ctermbg=15 + + let cmd = GetVimCommandClean() + let cmd .= ' ' . a:arguments + let buf = term_start(cmd, {'curwin': 1, 'term_rows': 20, 'term_cols': 75}) + call assert_equal([20, 75], term_getsize(buf)) + + return buf +endfunc + +" Stop a Vim running in terminal buffer "buf". +func StopVimInTerminal(buf) + call assert_equal("running", term_getstatus(a:buf)) + call term_sendkeys(a:buf, ":qa!\<cr>") + call WaitFor('term_getstatus(' . a:buf . ') == "finished"') + only! +endfunc + +" Verify that Vim running in terminal buffer "buf" matches the screen dump. +" The file name used is "dumps/{filename}.dump". +" Will wait for up to a second for the screen dump to match. +func VerifyScreenDump(buf, filename) + let reference = 'dumps/' . a:filename . '.dump' + let testfile = a:filename . '.dump.failed' + + let i = 0 + while 1 + call delete(testfile) + call term_dumpwrite(a:buf, testfile) + if readfile(reference) == readfile(testfile) + call delete(testfile) + break + endif + if i == 100 + " Leave the test file around for inspection. + call assert_report('See dump file difference: call term_dumpdiff("' . testfile . '", "' . reference . '")') + break + endif + sleep 10m + let i += 1 + endwhile +endfunc |