annotate src/testdir/screendump.vim @ 28841:77a00aa3e215 v8.2.4944

patch 8.2.4944: text properties are wrong after "cc" Commit: https://github.com/vim/vim/commit/d0b1a09f44654bb5e29b09de1311845200f17d90 Author: LemonBoy <thatlemon@gmail.com> Date: Thu May 12 18:45:18 2022 +0100 patch 8.2.4944: text properties are wrong after "cc" Problem: Text properties are wrong after "cc". (Axel Forsman) Solution: Pass the deleted byte count to inserted_bytes(). (closes https://github.com/vim/vim/issues/10412, closes #7737, closes #5763)
author Bram Moolenaar <Bram@vim.org>
date Thu, 12 May 2022 20:00:02 +0200
parents 54e33757d1ec
children 9dce192d1ac2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Functions shared by tests making screen dumps.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Only load this script once.
17164
7927cf327396 patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents: 17113
diff changeset
4 if exists('*VerifyScreenDump')
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 finish
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 endif
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
17164
7927cf327396 patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents: 17113
diff changeset
8 source shared.vim
7927cf327396 patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents: 17113
diff changeset
9 source term_util.vim
14019
dc67449d648c patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents: 13845
diff changeset
10
dc67449d648c patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents: 13845
diff changeset
11 " Skip the rest if there is no terminal feature at all.
dc67449d648c patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents: 13845
diff changeset
12 if !has('terminal')
13329
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
13 finish
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
14 endif
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
15
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 " Verify that Vim running in terminal buffer "buf" matches the screen dump.
13329
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
17 " "options" is passed to term_dumpwrite().
28710
54e33757d1ec patch 8.2.4879: screendump test may fail when using valgrind
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
18 " Additionally, the "wait" entry can specify the maximum time to wait for the
54e33757d1ec patch 8.2.4879: screendump test may fail when using valgrind
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
19 " screen dump to match in msec (default 1000 msec).
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 " The file name used is "dumps/{filename}.dump".
14693
156a7c5328a7 patch 8.1.0359: no clue what test failed when using a screendump twice
Christian Brabandt <cb@256bit.org>
parents: 14031
diff changeset
21 " Optionally an extra argument can be passed which is prepended to the error
156a7c5328a7 patch 8.1.0359: no clue what test failed when using a screendump twice
Christian Brabandt <cb@256bit.org>
parents: 14031
diff changeset
22 " message. Use this when using the same dump file with different options.
156a7c5328a7 patch 8.1.0359: no clue what test failed when using a screendump twice
Christian Brabandt <cb@256bit.org>
parents: 14031
diff changeset
23 " Returns non-zero when verification fails.
156a7c5328a7 patch 8.1.0359: no clue what test failed when using a screendump twice
Christian Brabandt <cb@256bit.org>
parents: 14031
diff changeset
24 func VerifyScreenDump(buf, filename, options, ...)
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 let reference = 'dumps/' . a:filename . '.dump'
16150
b23048205589 patch 8.1.1080: when a screendump test fails, moving the file is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 15916
diff changeset
26 let testfile = 'failed/' . a:filename . '.dump'
b23048205589 patch 8.1.1080: when a screendump test fails, moving the file is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 15916
diff changeset
27
28710
54e33757d1ec patch 8.2.4879: screendump test may fail when using valgrind
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
28 let max_loops = get(a:options, 'wait', 1000) / 10
54e33757d1ec patch 8.2.4879: screendump test may fail when using valgrind
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
29
19687
c3f506e24eab patch 8.2.0400: not all tests using a terminal are in the list of flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 17918
diff changeset
30 " Starting a terminal to make a screendump is always considered flaky.
19691
60b5abfc4897 patch 8.2.0402: setting local instead of global flag
Bram Moolenaar <Bram@vim.org>
parents: 19687
diff changeset
31 let g:test_is_flaky = 1
19687
c3f506e24eab patch 8.2.0400: not all tests using a terminal are in the list of flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 17918
diff changeset
32
27626
95d6e3c9aa1e patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents: 19691
diff changeset
33 " wait for the pending updates to be handled.
95d6e3c9aa1e patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents: 19691
diff changeset
34 call TermWait(a:buf)
95d6e3c9aa1e patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents: 19691
diff changeset
35
17918
9606c0adc148 patch 8.1.1955: tests contain typos
Bram Moolenaar <Bram@vim.org>
parents: 17164
diff changeset
36 " Redraw to execute the code that updates the screen. Otherwise we get the
16326
1679b9f54946 patch 8.1.1168: not all screen update code of terminal is executed in tests
Bram Moolenaar <Bram@vim.org>
parents: 16314
diff changeset
37 " text and attributes only from the internal buffer.
1679b9f54946 patch 8.1.1168: not all screen update code of terminal is executed in tests
Bram Moolenaar <Bram@vim.org>
parents: 16314
diff changeset
38 redraw
1679b9f54946 patch 8.1.1168: not all screen update code of terminal is executed in tests
Bram Moolenaar <Bram@vim.org>
parents: 16314
diff changeset
39
16150
b23048205589 patch 8.1.1080: when a screendump test fails, moving the file is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 15916
diff changeset
40 let did_mkdir = 0
b23048205589 patch 8.1.1080: when a screendump test fails, moving the file is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 15916
diff changeset
41 if !isdirectory('failed')
b23048205589 patch 8.1.1080: when a screendump test fails, moving the file is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 15916
diff changeset
42 let did_mkdir = 1
b23048205589 patch 8.1.1080: when a screendump test fails, moving the file is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 15916
diff changeset
43 call mkdir('failed')
b23048205589 patch 8.1.1080: when a screendump test fails, moving the file is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 15916
diff changeset
44 endif
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 let i = 0
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 while 1
15103
9339601e7a31 patch 8.1.0562: parsing of 'diffopt' is slightly wrong
Bram Moolenaar <Bram@vim.org>
parents: 14693
diff changeset
48 " leave some time for updating the original window
9339601e7a31 patch 8.1.0562: parsing of 'diffopt' is slightly wrong
Bram Moolenaar <Bram@vim.org>
parents: 14693
diff changeset
49 sleep 10m
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 call delete(testfile)
13329
424321d6eea7 patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents: 13322
diff changeset
51 call term_dumpwrite(a:buf, testfile, a:options)
15916
95648dc0124f patch 8.1.0964: cannot see in CI why a screenshot test failed
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
52 let testdump = readfile(testfile)
16249
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
53 if filereadable(reference)
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
54 let refdump = readfile(reference)
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
55 else
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
56 " Must be a new screendump, always fail
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
57 let refdump = []
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
58 endif
15916
95648dc0124f patch 8.1.0964: cannot see in CI why a screenshot test failed
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
59 if refdump == testdump
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 call delete(testfile)
16150
b23048205589 patch 8.1.1080: when a screendump test fails, moving the file is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 15916
diff changeset
61 if did_mkdir
b23048205589 patch 8.1.1080: when a screendump test fails, moving the file is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 15916
diff changeset
62 call delete('failed', 'd')
b23048205589 patch 8.1.1080: when a screendump test fails, moving the file is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 15916
diff changeset
63 endif
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 break
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 endif
28710
54e33757d1ec patch 8.2.4879: screendump test may fail when using valgrind
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
66 if i == max_loops
16249
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
67 " Leave the failed dump around for inspection.
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
68 if filereadable(reference)
17113
18ec0b92f431 patch 8.1.1556: command for failing screenshot does not include directory
Bram Moolenaar <Bram@vim.org>
parents: 16477
diff changeset
69 let msg = 'See dump file difference: call term_dumpdiff("testdir/' .. testfile .. '", "testdir/' .. reference .. '")'
16249
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
70 if a:0 == 1
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
71 let msg = a:1 . ': ' . msg
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
72 endif
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
73 if len(testdump) != len(refdump)
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
74 let msg = msg . '; line count is ' . len(testdump) . ' instead of ' . len(refdump)
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
75 endif
67e43b01497f patch 8.1.1129: when making a new screendump test have to create the file
Bram Moolenaar <Bram@vim.org>
parents: 16150
diff changeset
76 else
17113
18ec0b92f431 patch 8.1.1556: command for failing screenshot does not include directory
Bram Moolenaar <Bram@vim.org>
parents: 16477
diff changeset
77 let msg = 'See new dump file: call term_dumpload("testdir/' .. testfile .. '")'
15916
95648dc0124f patch 8.1.0964: cannot see in CI why a screenshot test failed
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
78 endif
95648dc0124f patch 8.1.0964: cannot see in CI why a screenshot test failed
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
79 for i in range(len(refdump))
95648dc0124f patch 8.1.0964: cannot see in CI why a screenshot test failed
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
80 if i >= len(testdump)
95648dc0124f patch 8.1.0964: cannot see in CI why a screenshot test failed
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
81 break
95648dc0124f patch 8.1.0964: cannot see in CI why a screenshot test failed
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
82 endif
95648dc0124f patch 8.1.0964: cannot see in CI why a screenshot test failed
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
83 if testdump[i] != refdump[i]
95648dc0124f patch 8.1.0964: cannot see in CI why a screenshot test failed
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
84 let msg = msg . '; difference in line ' . (i + 1) . ': "' . testdump[i] . '"'
95648dc0124f patch 8.1.0964: cannot see in CI why a screenshot test failed
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
85 endif
95648dc0124f patch 8.1.0964: cannot see in CI why a screenshot test failed
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
86 endfor
14693
156a7c5328a7 patch 8.1.0359: no clue what test failed when using a screendump twice
Christian Brabandt <cb@256bit.org>
parents: 14031
diff changeset
87 call assert_report(msg)
156a7c5328a7 patch 8.1.0359: no clue what test failed when using a screendump twice
Christian Brabandt <cb@256bit.org>
parents: 14031
diff changeset
88 return 1
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 endif
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 let i += 1
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 endwhile
14693
156a7c5328a7 patch 8.1.0359: no clue what test failed when using a screendump twice
Christian Brabandt <cb@256bit.org>
parents: 14031
diff changeset
92 return 0
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 endfunc