Mercurial > vim
annotate src/testdir/test_memory_usage.vim @ 19176:be81baeb69f8 v8.2.0147
patch 8.2.0147: block Visual mode operators not correct when 'linebreak' set
Commit: https://github.com/vim/vim/commit/03c3bd9fd094c1aede2e8fe3ad8fd25b9f033053
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 23 20:58:09 2020 +0100
patch 8.2.0147: block Visual mode operators not correct when 'linebreak' set
Problem: Block Visual mode operators not correct when 'linebreak' set.
Solution: Set w_p_lbr to lbr_saved more often. (Ken Takata, closes https://github.com/vim/vim/issues/5524)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 23 Jan 2020 21:00:03 +0100 |
parents | 9afeb0d2c4ab |
children | 08940efa6b4e |
rev | line source |
---|---|
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Tests for memory usage. |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
17089
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17083
diff
changeset
|
3 source check.vim |
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17083
diff
changeset
|
4 CheckFeature terminal |
17657
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17172
diff
changeset
|
5 CheckNotGui |
17089
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17083
diff
changeset
|
6 |
17083
6641a15f999d
patch 8.1.1541: check for ASAN is not reliable
Bram Moolenaar <Bram@vim.org>
parents:
17049
diff
changeset
|
7 if execute('version') =~# '-fsanitize=[a-z,]*\<address\>' |
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 " Skip tests on Travis CI ASAN build because it's difficult to estimate |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 " memory usage. |
17089
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17083
diff
changeset
|
10 throw 'Skipped: does not work with ASAN' |
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 endif |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 source shared.vim |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 func s:pick_nr(str) abort |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 return substitute(a:str, '[^0-9]', '', 'g') * 1 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 endfunc |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 if has('win32') |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 if !executable('wmic') |
17089
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17083
diff
changeset
|
21 throw 'Skipped: wmic program missing' |
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 endif |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 func s:memory_usage(pid) abort |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 let cmd = printf('wmic process where processid=%d get WorkingSetSize', a:pid) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 return s:pick_nr(system(cmd)) / 1024 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 endfunc |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 elseif has('unix') |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 if !executable('ps') |
17089
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17083
diff
changeset
|
29 throw 'Skipped: ps program missing' |
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 endif |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 func s:memory_usage(pid) abort |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 return s:pick_nr(system('ps -o rss= -p ' . a:pid)) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 endfunc |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 else |
17089
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17083
diff
changeset
|
35 throw 'Skipped: not win32 or unix' |
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 endif |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 " Wait for memory usage to level off. |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 func s:monitor_memory_usage(pid) abort |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 let proc = {} |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 let proc.pid = a:pid |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 let proc.hist = [] |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 let proc.max = 0 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 func proc.op() abort |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 " Check the last 200ms. |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 let val = s:memory_usage(self.pid) |
16052
853d73097325
patch 8.1.1031: memory usage test may still fail
Bram Moolenaar <Bram@vim.org>
parents:
16044
diff
changeset
|
48 if self.max < val |
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 let self.max = val |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 endif |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 call add(self.hist, val) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 if len(self.hist) < 20 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 return 0 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 endif |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 let sample = remove(self.hist, 0) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 return len(uniq([sample] + self.hist)) == 1 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 endfunc |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 call WaitFor({-> proc.op()}, 10000) |
16052
853d73097325
patch 8.1.1031: memory usage test may still fail
Bram Moolenaar <Bram@vim.org>
parents:
16044
diff
changeset
|
60 return {'last': get(proc.hist, -1), 'max': proc.max} |
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 endfunc |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 let s:term_vim = {} |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 func s:term_vim.start(...) abort |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 let self.buf = term_start([GetVimProg()] + a:000) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 let self.job = term_getjob(self.buf) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 call WaitFor({-> job_status(self.job) ==# 'run'}) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 let self.pid = job_info(self.job).process |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 endfunc |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 func s:term_vim.stop() abort |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 call term_sendkeys(self.buf, ":qall!\<CR>") |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 call WaitFor({-> job_status(self.job) ==# 'dead'}) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 exe self.buf . 'bwipe!' |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 endfunc |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 func s:vim_new() abort |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 return copy(s:term_vim) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 endfunc |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 func Test_memory_func_capture_vargs() |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 " Case: if a local variable captures a:000, funccall object will be free |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 " just after it finishes. |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 let testfile = 'Xtest.vim' |
17172
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
86 let lines =<< trim END |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
87 func s:f(...) |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
88 let x = a:000 |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
89 endfunc |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
90 for _ in range(10000) |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
91 call s:f(0) |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
92 endfor |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
93 END |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
94 call writefile(lines, testfile) |
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 let vim = s:vim_new() |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 call vim.start('--clean', '-c', 'set noswapfile', testfile) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 let before = s:monitor_memory_usage(vim.pid).last |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 call term_sendkeys(vim.buf, ":so %\<CR>") |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 call WaitFor({-> term_getcursor(vim.buf)[0] == 1}) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 let after = s:monitor_memory_usage(vim.pid) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 " Estimate the limit of max usage as 2x initial usage. |
16867
0baa4c7e057f
patch 8.1.1435: memory usage test is a bit too flaky
Bram Moolenaar <Bram@vim.org>
parents:
16107
diff
changeset
|
105 " The lower limit can fluctuate a bit, use 97%. |
0baa4c7e057f
patch 8.1.1435: memory usage test is a bit too flaky
Bram Moolenaar <Bram@vim.org>
parents:
16107
diff
changeset
|
106 call assert_inrange(before * 97 / 100, 2 * before, after.max) |
16107
b951bea7d11e
patch 8.1.1058: memory usage test may still fail on some systems
Bram Moolenaar <Bram@vim.org>
parents:
16064
diff
changeset
|
107 |
b951bea7d11e
patch 8.1.1058: memory usage test may still fail on some systems
Bram Moolenaar <Bram@vim.org>
parents:
16064
diff
changeset
|
108 " In this case, garbage collecting is not needed. |
16867
0baa4c7e057f
patch 8.1.1435: memory usage test is a bit too flaky
Bram Moolenaar <Bram@vim.org>
parents:
16107
diff
changeset
|
109 " The value might fluctuate a bit, allow for 3% tolerance below and 5% above. |
0baa4c7e057f
patch 8.1.1435: memory usage test is a bit too flaky
Bram Moolenaar <Bram@vim.org>
parents:
16107
diff
changeset
|
110 " Based on various test runs. |
16052
853d73097325
patch 8.1.1031: memory usage test may still fail
Bram Moolenaar <Bram@vim.org>
parents:
16044
diff
changeset
|
111 let lower = after.last * 97 / 100 |
16867
0baa4c7e057f
patch 8.1.1435: memory usage test is a bit too flaky
Bram Moolenaar <Bram@vim.org>
parents:
16107
diff
changeset
|
112 let upper = after.last * 105 / 100 |
16052
853d73097325
patch 8.1.1031: memory usage test may still fail
Bram Moolenaar <Bram@vim.org>
parents:
16044
diff
changeset
|
113 call assert_inrange(lower, upper, after.max) |
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 call vim.stop() |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 call delete(testfile) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 endfunc |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 func Test_memory_func_capture_lvars() |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 " Case: if a local variable captures l: dict, funccall object will not be |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 " free until garbage collector runs, but after that memory usage doesn't |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 " increase so much even when rerun Xtest.vim since system memory caches. |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 let testfile = 'Xtest.vim' |
17172
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
124 let lines =<< trim END |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
125 func s:f() |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
126 let x = l: |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
127 endfunc |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
128 for _ in range(10000) |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
129 call s:f() |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
130 endfor |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
131 END |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
132 call writefile(lines, testfile) |
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 let vim = s:vim_new() |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 call vim.start('--clean', '-c', 'set noswapfile', testfile) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 let before = s:monitor_memory_usage(vim.pid).last |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 call term_sendkeys(vim.buf, ":so %\<CR>") |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 call WaitFor({-> term_getcursor(vim.buf)[0] == 1}) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 let after = s:monitor_memory_usage(vim.pid) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 " Rerun Xtest.vim. |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 for _ in range(3) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 call term_sendkeys(vim.buf, ":so %\<CR>") |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 call WaitFor({-> term_getcursor(vim.buf)[0] == 1}) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 let last = s:monitor_memory_usage(vim.pid).last |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 endfor |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 |
16052
853d73097325
patch 8.1.1031: memory usage test may still fail
Bram Moolenaar <Bram@vim.org>
parents:
16044
diff
changeset
|
149 " The usage may be a bit less than the last value, use 80%. |
16064
e4ba2925b54d
patch 8.1.1037: memory usage test may still fail on some systems
Bram Moolenaar <Bram@vim.org>
parents:
16056
diff
changeset
|
150 " Allow for 20% tolerance at the upper limit. That's very permissive, but |
19021
fa3e63666acb
patch 8.2.0071: memory test often fails on Cirrus CI
Bram Moolenaar <Bram@vim.org>
parents:
19003
diff
changeset
|
151 " otherwise the test fails sometimes. On Cirrus CI with FreeBSD we need to |
fa3e63666acb
patch 8.2.0071: memory test often fails on Cirrus CI
Bram Moolenaar <Bram@vim.org>
parents:
19003
diff
changeset
|
152 " be even more permissive. |
fa3e63666acb
patch 8.2.0071: memory test often fails on Cirrus CI
Bram Moolenaar <Bram@vim.org>
parents:
19003
diff
changeset
|
153 if has('bsd') |
19023
9afeb0d2c4ab
patch 8.2.0072: memory test still fails on Cirrus CI
Bram Moolenaar <Bram@vim.org>
parents:
19021
diff
changeset
|
154 let multiplier = 15 |
19021
fa3e63666acb
patch 8.2.0071: memory test often fails on Cirrus CI
Bram Moolenaar <Bram@vim.org>
parents:
19003
diff
changeset
|
155 else |
fa3e63666acb
patch 8.2.0071: memory test often fails on Cirrus CI
Bram Moolenaar <Bram@vim.org>
parents:
19003
diff
changeset
|
156 let multiplier = 12 |
fa3e63666acb
patch 8.2.0071: memory test often fails on Cirrus CI
Bram Moolenaar <Bram@vim.org>
parents:
19003
diff
changeset
|
157 endif |
16044
f4a206d7a04d
patch 8.1.1027: memory usage test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
16003
diff
changeset
|
158 let lower = before * 8 / 10 |
19021
fa3e63666acb
patch 8.2.0071: memory test often fails on Cirrus CI
Bram Moolenaar <Bram@vim.org>
parents:
19003
diff
changeset
|
159 let upper = (after.max + (after.last - before)) * multiplier / 10 |
16052
853d73097325
patch 8.1.1031: memory usage test may still fail
Bram Moolenaar <Bram@vim.org>
parents:
16044
diff
changeset
|
160 call assert_inrange(lower, upper, last) |
16003
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 call vim.stop() |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 call delete(testfile) |
879829e44091
patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 endfunc |