annotate src/testdir/test_memory_usage.vim @ 31888:b374dfaa8645 v9.0.1276

patch 9.0.1276: some mappings with Meta and Shift do not work Commit: https://github.com/vim/vim/commit/4be18e77ff2d9a85d01e9d62335542755b26d5d5 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 3 12:28:07 2023 +0000 patch 9.0.1276: some mappings with Meta and Shift do not work Problem: Some mappings with Meta and Shift do not work. Solution: Apply the Shift modifier to the key. (issue https://github.com/vim/vim/issues/11913)
author Bram Moolenaar <Bram@vim.org>
date Fri, 03 Feb 2023 13:30:05 +0100
parents 72245f9c9405
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
23766
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
7 " Skip tests on Travis CI ASAN build because it's difficult to estimate memory
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
8 " usage.
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
9 CheckNotAsan
16003
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 source shared.vim
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 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
14 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
15 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 if has('win32')
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 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
19 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
20 endif
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 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
22 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
23 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
24 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 elseif has('unix')
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 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
27 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
28 endif
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 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
30 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
31 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 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
33 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
34 endif
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 " 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
37 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
38 let proc = {}
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 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
40 let proc.hist = []
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 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
42
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 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
44 " 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
45 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
46 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
47 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
48 endif
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 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
50 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
51 return 0
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 endif
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 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
54 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
55 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 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
58 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
59 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 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
62
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 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
64 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
65 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
66 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
67 let self.pid = job_info(self.job).process
29161
198a44d40394 patch 8.2.5100: memory usage tests are not retried
Bram Moolenaar <Bram@vim.org>
parents: 24120
diff changeset
68
198a44d40394 patch 8.2.5100: memory usage tests are not retried
Bram Moolenaar <Bram@vim.org>
parents: 24120
diff changeset
69 " running an external command may fail once in a while
198a44d40394 patch 8.2.5100: memory usage tests are not retried
Bram Moolenaar <Bram@vim.org>
parents: 24120
diff changeset
70 let g:test_is_flaky = 1
16003
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 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
74 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
75 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
76 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
77 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 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
80 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
81 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 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
84 " 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
85 " 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
86 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
87 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
88 func s:f(...)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
89 let x = a:000
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
90 endfunc
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
91 for _ in range(10000)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
92 call s:f(0)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
93 endfor
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
94 END
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 29161
diff changeset
95 call writefile(lines, testfile, 'D')
16003
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 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
98 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
99 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
100
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 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
102 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
103 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
104
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 " 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
106 " 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
107 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
108
b951bea7d11e patch 8.1.1058: memory usage test may still fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 16064
diff changeset
109 " 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
110 " 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
111 " 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
112 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
113 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
114 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
115
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 call vim.stop()
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
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 29161
diff changeset
132 call writefile(lines, testfile, 'D')
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
24120
b926b24684c1 patch 8.2.2601: memory usage test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
152 " be even much more permissive.
19021
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')
24120
b926b24684c1 patch 8.2.2601: memory usage test often fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
154 let multiplier = 19
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 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19023
diff changeset
164
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19023
diff changeset
165 " vim: shiftwidth=2 sts=2 expandtab