annotate src/testdir/test_memory_usage.vim @ 24882:4c1b6f3eb96b v8.2.2979

patch 8.2.2979: not all options code is covered by tests Commit: https://github.com/vim/vim/commit/5958549760652c173b703613b9cbf09b25a4eddb Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Jun 12 13:46:41 2021 +0200 patch 8.2.2979: not all options code is covered by tests Problem: Not all options code is covered by tests. Solution: Add more tests for options. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8369)
author Bram Moolenaar <Bram@vim.org>
date Sat, 12 Jun 2021 14:00:04 +0200
parents b926b24684c1
children 198a44d40394
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
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 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
71 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
72 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
73 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
74 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 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
77 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
78 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 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
81 " 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
82 " 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
83 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
84 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
85 func s:f(...)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
86 let x = a:000
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
87 endfunc
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
88 for _ in range(10000)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
89 call s:f(0)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
90 endfor
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
91 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
92 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
93
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 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
95 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
96 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
97
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 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
99 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
100 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
101
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 " 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
103 " 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
104 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
105
b951bea7d11e patch 8.1.1058: memory usage test may still fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 16064
diff changeset
106 " 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
107 " 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
108 " 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
109 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
110 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
111 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
112
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 call vim.stop()
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 call delete(testfile)
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 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
118 " 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
119 " 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
120 " 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
121 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
122 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
123 func s:f()
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
124 let x = l:
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
125 endfunc
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
126 for _ in range(10000)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
127 call s:f()
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
128 endfor
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
129 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
130 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
131
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 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
133 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
134 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
135
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 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
137 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
138 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
139
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 " Rerun Xtest.vim.
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 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
142 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
143 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
144 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
145 endfor
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146
16052
853d73097325 patch 8.1.1031: memory usage test may still fail
Bram Moolenaar <Bram@vim.org>
parents: 16044
diff changeset
147 " 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
148 " 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
149 " 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
150 " 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
151 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
152 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
153 else
fa3e63666acb patch 8.2.0071: memory test often fails on Cirrus CI
Bram Moolenaar <Bram@vim.org>
parents: 19003
diff changeset
154 let multiplier = 12
fa3e63666acb patch 8.2.0071: memory test often fails on Cirrus CI
Bram Moolenaar <Bram@vim.org>
parents: 19003
diff changeset
155 endif
16044
f4a206d7a04d patch 8.1.1027: memory usage test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 16003
diff changeset
156 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
157 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
158 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
159
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 call vim.stop()
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 call delete(testfile)
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19023
diff changeset
163
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19023
diff changeset
164 " vim: shiftwidth=2 sts=2 expandtab