Mercurial > vim
annotate src/testdir/test_file_size.vim @ 34379:37b4c89ba420 v9.1.0116
patch 9.1.0116: win_split_ins may not check available room
Commit: https://github.com/vim/vim/commit/0fd44a5ad81ade342cb54d8984965bdedd2272c8
Author: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Date: Tue Feb 20 20:28:15 2024 +0100
patch 9.1.0116: win_split_ins may not check available room
Problem: win_split_ins has no check for E36 when moving an existing
window
Solution: check for room and fix the issues in f_win_splitmove()
(Sean Dewar)
win_split_ins has no check for E36 when moving an existing window,
allowing for layouts with many overlapping zero-sized windows to be
created (which may also cause drawing issues with tablines and such).
f_win_splitmove also has some bugs.
So check for room and fix the issues in f_win_splitmove. Handle failure
in the two relevant win_split_ins callers by restoring the original
layout, and factor the common logic into win_splitmove.
Don't check for room when opening an autocommand window, as it's a
temporary window that's rarely interacted with or drawn anyhow, and is
rather important for some autocommands.
Issues fixed in f_win_splitmove:
- Error if splitting is disallowed.
- Fix heap-use-after-frees if autocommands fired from switching to "targetwin"
close "wp" or "oldwin".
- Fix splitting the wrong window if autocommands fired from switching to
"targetwin" switch to a different window.
- Ensure -1 is returned for all errors.
Also handle allocation failure a bit earlier in make_snapshot (callers,
except win_splitmove, don't really care if a snapshot can't be made, so
just ignore the return value).
Note: Test_smoothscroll_in_zero_width_window failed after these changes with
E36, as it was using the previous behaviour to create a zero-width window.
I've fixed the test such that it fails with UBSAN as expected when v9.0.1367 is
reverted (and simplified it too).
related: #14042
Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 20 Feb 2024 22:30:04 +0100 |
parents | 08940efa6b4e |
children |
rev | line source |
---|---|
11961
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Inserts 2 million lines with consecutive integers starting from 1 |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " (essentially, the output of GNU's seq 1 2000000), writes them to Xtest |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " and writes its cksum to test.out. |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 " |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 " We need 2 million lines to trigger a call to mf_hash_grow(). If it would mess |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 " up the lines the checksum would differ. |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 " |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 " cksum is part of POSIX and so should be available on most Unixes. |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 " If it isn't available then the test will be skipped. |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
12644
diff
changeset
|
10 |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
12644
diff
changeset
|
11 source check.vim |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
12644
diff
changeset
|
12 |
11961
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 func Test_File_Size() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
12644
diff
changeset
|
14 CheckExecutable cksum |
11961
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 new |
12644
1fad9675d8fd
patch 8.0.1200: tests switch the bell off twice
Christian Brabandt <cb@256bit.org>
parents:
12560
diff
changeset
|
17 set fileformat=unix undolevels=-1 |
11961
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 for i in range(1, 2000000, 100) |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
12644
diff
changeset
|
19 call append(i, range(i, i + 99)) |
11961
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 endfor |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 1delete |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 w! Xtest |
11963
f1635be0e963
patch 8.0.0862: file size test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11961
diff
changeset
|
24 let res = systemlist('cksum Xtest')[0] |
f1635be0e963
patch 8.0.0862: file size test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11961
diff
changeset
|
25 let res = substitute(res, "\r", "", "") |
f1635be0e963
patch 8.0.0862: file size test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11961
diff
changeset
|
26 call assert_equal('3678979763 14888896 Xtest', res) |
11961
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 enew! |
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 call delete('Xtest') |
12644
1fad9675d8fd
patch 8.0.1200: tests switch the bell off twice
Christian Brabandt <cb@256bit.org>
parents:
12560
diff
changeset
|
30 set fileformat& undolevels& |
11961
0240e7e3d736
patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 endfunc |
12560
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
32 |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
33 " Test for writing and reading a file of over 100 Kbyte |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
34 func Test_File_Read_Write() |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
35 enew! |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
36 |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
37 " Create a file with the following contents |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
38 " 1 line: "This is the start" |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
39 " 3001 lines: "This is the leader" |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
40 " 1 line: "This is the middle" |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
41 " 3001 lines: "This is the trailer" |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
42 " 1 line: "This is the end" |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
43 call append(0, "This is the start") |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
44 call append(1, repeat(["This is the leader"], 3001)) |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
45 call append(3002, "This is the middle") |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
46 call append(3003, repeat(["This is the trailer"], 3001)) |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
47 call append(6004, "This is the end") |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
48 |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
49 write! Xtest |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
50 enew! |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
51 edit! Xtest |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
52 |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
53 call assert_equal("This is the start", getline(1)) |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
54 call assert_equal("This is the middle", getline(3003)) |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
55 call assert_equal("This is the end", getline(6005)) |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
56 |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
57 enew! |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
58 call delete("Xtest") |
44aa2997239d
patch 8.0.1158: still old style tests
Christian Brabandt <cb@256bit.org>
parents:
11963
diff
changeset
|
59 endfunc |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
12644
diff
changeset
|
60 |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
12644
diff
changeset
|
61 " vim: shiftwidth=2 sts=2 expandtab |