annotate src/testdir/test_memory_usage.vim @ 17395:119a53a4cb0e v8.1.1696

patch 8.1.1696: MSVC: link command line is too long commit https://github.com/vim/vim/commit/cea2a15687c54b8a700f77f3deef35269abb1417 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jul 15 20:44:57 2019 +0200 patch 8.1.1696: MSVC: link command line is too long Problem: MSVC: link command line is too long. Solution: Use the @<< mechanism to pass the arguments via a file. (Christian Brabandt)
author Bram Moolenaar <Bram@vim.org>
date Mon, 15 Jul 2019 21:00:03 +0200
parents 6990c1160ea5
children 0da9bc55c31a
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
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17083
diff changeset
5
17049
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 16867
diff changeset
6 if has('gui_running')
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17083
diff changeset
7 throw 'Skipped: does not work in GUI'
17049
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 16867
diff changeset
8 endif
17083
6641a15f999d patch 8.1.1541: check for ASAN is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
9 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
10 " 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
11 " 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
12 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
13 endif
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 source shared.vim
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 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
18 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
19 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 if has('win32')
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 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
23 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
24 endif
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 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
26 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
27 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
28 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 elseif has('unix')
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 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
31 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
32 endif
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 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
34 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
35 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 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
37 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
38 endif
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 " 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
41 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
42 let proc = {}
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 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
44 let proc.hist = []
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 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
46
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 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
48 " 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
49 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
50 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
51 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
52 endif
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 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
54 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
55 return 0
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 endif
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 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
58 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
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 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
62 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
63 endfunc
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 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
66
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 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
68 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
69 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
70 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
71 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
72 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 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
75 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
76 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
77 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
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 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
81 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
82 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 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
85 " 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
86 " 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
87 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
88 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
89 func s:f(...)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
90 let x = a:000
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
91 endfunc
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
92 for _ in range(10000)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
93 call s:f(0)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
94 endfor
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
95 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
96 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
97
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 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
99 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
100 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
101
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 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
103 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
104 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
105
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 " 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
107 " 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
108 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
109
b951bea7d11e patch 8.1.1058: memory usage test may still fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 16064
diff changeset
110 " 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
111 " 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
112 " 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
113 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
114 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
115 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
116
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 call vim.stop()
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 call delete(testfile)
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 endfunc
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 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
122 " 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
123 " 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
124 " 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
125 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
126 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
127 func s:f()
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
128 let x = l:
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
129 endfunc
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
130 for _ in range(10000)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
131 call s:f()
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
132 endfor
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
133 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
134 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
135
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 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
137 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
138 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
139
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 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
141 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
142 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
143
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 " Rerun Xtest.vim.
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 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
146 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
147 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
148 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
149 endfor
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150
16052
853d73097325 patch 8.1.1031: memory usage test may still fail
Bram Moolenaar <Bram@vim.org>
parents: 16044
diff changeset
151 " 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
152 " Allow for 20% tolerance at the upper limit. That's very permissive, but
e4ba2925b54d patch 8.1.1037: memory usage test may still fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 16056
diff changeset
153 " otherwise the test fails sometimes.
16044
f4a206d7a04d patch 8.1.1027: memory usage test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 16003
diff changeset
154 let lower = before * 8 / 10
16064
e4ba2925b54d patch 8.1.1037: memory usage test may still fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 16056
diff changeset
155 let upper = (after.max + (after.last - before)) * 12 / 10
16052
853d73097325 patch 8.1.1031: memory usage test may still fail
Bram Moolenaar <Bram@vim.org>
parents: 16044
diff changeset
156 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
157
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 call vim.stop()
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 call delete(testfile)
879829e44091 patch 8.1.1007: using closure may consume a lot of memory
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 endfunc