annotate src/testdir/shared.vim @ 29234:96ff6c230a66 v8.2.5136

patch 8.2.5136: debugger test fails when run with valgrind Commit: https://github.com/vim/vim/commit/e366ed4f2c6fa8cb663f1b9599b39d57ddbd8a2a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 19 20:13:56 2022 +0100 patch 8.2.5136: debugger test fails when run with valgrind Problem: Debugger test fails when run with valgrind. Solution: Wait longer when using valgrind.
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 Jun 2022 21:15:03 +0200
parents d8a962d7b008
children 17c46a3d0ef5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Functions shared by several tests.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
3 " Only load this script once.
17164
7927cf327396 patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
4 if exists('*PythonProg')
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
5 finish
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
6 endif
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
7
17164
7927cf327396 patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
8 source view_util.vim
7927cf327396 patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
9
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 " Get the name of the Python executable.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 " Also keeps it in s:python.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 func PythonProg()
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 " This test requires the Python command to run the test server.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 " This most likely only works on Unix and Windows.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 if has('unix')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 " We also need the job feature or the pkill command to make sure the server
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 " can be stopped.
28317
d32dc906dd2c patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents: 24570
diff changeset
18 if !(has('job') || executable('pkill'))
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 return ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 endif
28317
d32dc906dd2c patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents: 24570
diff changeset
21 if executable('python')
d32dc906dd2c patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents: 24570
diff changeset
22 let s:python = 'python'
d32dc906dd2c patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents: 24570
diff changeset
23 elseif executable('python3')
d32dc906dd2c patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents: 24570
diff changeset
24 let s:python = 'python3'
d32dc906dd2c patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents: 24570
diff changeset
25 else
d32dc906dd2c patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents: 24570
diff changeset
26 return ''
d32dc906dd2c patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents: 24570
diff changeset
27 end
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 elseif has('win32')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 " Use Python Launcher for Windows (py.exe) if available.
24570
27033b8bba0e patch 8.2.2824: MS-Windows: build failure with MSVC
Bram Moolenaar <Bram@vim.org>
parents: 22827
diff changeset
30 " NOTE: if you get a "Python was not found" error, disable the Python
27033b8bba0e patch 8.2.2824: MS-Windows: build failure with MSVC
Bram Moolenaar <Bram@vim.org>
parents: 22827
diff changeset
31 " shortcuts in "Windows menu / Settings / Manage App Execution Aliases".
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 if executable('py.exe')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 let s:python = 'py.exe'
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 elseif executable('python.exe')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 let s:python = 'python.exe'
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 return ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 return ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 return s:python
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 " Run "cmd". Returns the job if using a job.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 func RunCommand(cmd)
20309
cae01dabd78e patch 8.2.0710: Netbeans test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 20221
diff changeset
47 " Running an external command can occasionally be slow or fail.
cae01dabd78e patch 8.2.0710: Netbeans test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 20221
diff changeset
48 let g:test_is_flaky = 1
cae01dabd78e patch 8.2.0710: Netbeans test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 20221
diff changeset
49
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 let job = 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 if has('job')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 let job = job_start(a:cmd, {"stoponexit": "hup"})
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 call job_setoptions(job, {"stoponexit": "kill"})
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 elseif has('win32')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 exe 'silent !start cmd /c start "test_channel" ' . a:cmd
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 exe 'silent !' . a:cmd . '&'
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 return job
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 " Read the port number from the Xportnr file.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 func GetPort()
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 let l = []
14919
7ad55ed0a4f3 patch 8.1.0471: some tests are flaky or fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 13843
diff changeset
65 " with 200 it sometimes failed
7ad55ed0a4f3 patch 8.1.0471: some tests are flaky or fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 13843
diff changeset
66 for i in range(400)
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 try
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 let l = readfile("Xportnr")
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 catch
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 endtry
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 if len(l) >= 1
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 break
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 sleep 10m
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 endfor
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 call delete("Xportnr")
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 if len(l) == 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 " Can't make the connection, give up.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 return 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 return l[0]
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 " Run a Python server for "cmd" and call "testfunc".
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 " Always kills the server before returning.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 func RunServer(cmd, testfunc, args)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 " The Python program writes the port number in Xportnr.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 call delete("Xportnr")
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 if len(a:args) == 1
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 let arg = ' ' . a:args[0]
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 let arg = ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 let pycmd = s:python . " " . a:cmd . arg
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 try
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 let g:currentJob = RunCommand(pycmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 " Wait for up to 2 seconds for the port number to be there.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 let port = GetPort()
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 if port == 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 call assert_false(1, "Can't start " . a:cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 return
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 call call(function(a:testfunc), [port])
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 catch
10422
e664ee056a84 commit https://github.com/vim/vim/commit/4b785f69c0616dba5d3f38e8ce4b5398cec89407
Christian Brabandt <cb@256bit.org>
parents: 10309
diff changeset
110 call assert_false(1, 'Caught exception: "' . v:exception . '" in ' . v:throwpoint)
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 finally
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 call s:kill_server(a:cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 endtry
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 func s:kill_server(cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 if has('job')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 if exists('g:currentJob')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 call job_stop(g:currentJob)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 unlet g:currentJob
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 elseif has('win32')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 let cmd = substitute(a:cmd, ".py", '', '')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 call system('taskkill /IM ' . s:python . ' /T /F /FI "WINDOWTITLE eq ' . cmd . '"')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 call system("pkill -f " . a:cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129
13650
87ffb7f85b28 patch 8.0.1697: various tests are still a bit flaky
Christian Brabandt <cb@256bit.org>
parents: 13460
diff changeset
130 " Wait for up to five seconds for "expr" to become true. "expr" can be a
12763
7f27e9769f62 patch 8.0.1259: search test can be flaky
Christian Brabandt <cb@256bit.org>
parents: 12742
diff changeset
131 " stringified expression to evaluate, or a funcref without arguments.
13798
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
132 " Using a lambda works best. Example:
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
133 " call WaitFor({-> status == "ok"})
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
134 "
13351
33a2277b8d4d patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents: 13304
diff changeset
135 " A second argument can be used to specify a different timeout in msec.
12763
7f27e9769f62 patch 8.0.1259: search test can be flaky
Christian Brabandt <cb@256bit.org>
parents: 12742
diff changeset
136 "
13798
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
137 " When successful the time slept is returned.
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
138 " When running into the timeout an exception is thrown, thus the function does
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
139 " not return.
11709
c3227699ad4d patch 8.0.0737: crash when X11 selection is very big
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
140 func WaitFor(expr, ...)
13650
87ffb7f85b28 patch 8.0.1697: various tests are still a bit flaky
Christian Brabandt <cb@256bit.org>
parents: 13460
diff changeset
141 let timeout = get(a:000, 0, 5000)
13798
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
142 let slept = s:WaitForCommon(a:expr, v:null, timeout)
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
143 if slept < 0
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
144 throw 'WaitFor() timed out after ' . timeout . ' msec'
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
145 endif
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
146 return slept
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
147 endfunc
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
148
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
149 " Wait for up to five seconds for "assert" to return zero. "assert" must be a
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
150 " (lambda) function containing one assert function. Example:
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
151 " call WaitForAssert({-> assert_equal("dead", job_status(job)})
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
152 "
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
153 " A second argument can be used to specify a different timeout in msec.
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
154 "
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
155 " Return zero for success, one for failure (like the assert function).
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
156 func WaitForAssert(assert, ...)
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
157 let timeout = get(a:000, 0, 5000)
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
158 if s:WaitForCommon(v:null, a:assert, timeout) < 0
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
159 return 1
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
160 endif
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
161 return 0
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
162 endfunc
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
163
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
164 " Common implementation of WaitFor() and WaitForAssert().
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
165 " Either "expr" or "assert" is not v:null
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
166 " Return the waiting time for success, -1 for failure.
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
167 func s:WaitForCommon(expr, assert, timeout)
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
168 " using reltime() is more accurate, but not always available
13798
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
169 let slept = 0
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 18829
diff changeset
170 if exists('*reltimefloat')
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
171 let start = reltime()
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
172 endif
13798
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
173
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
174 while 1
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
175 if type(a:expr) == v:t_func
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
176 let success = a:expr()
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
177 elseif type(a:assert) == v:t_func
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
178 let success = a:assert() == 0
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
179 else
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
180 let success = eval(a:expr)
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
181 endif
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
182 if success
12742
af961e38e508 patch 8.0.1249: no error when WaitFor() gets an invalid wrong expression
Christian Brabandt <cb@256bit.org>
parents: 12734
diff changeset
183 return slept
af961e38e508 patch 8.0.1249: no error when WaitFor() gets an invalid wrong expression
Christian Brabandt <cb@256bit.org>
parents: 12734
diff changeset
184 endif
13798
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
185
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
186 if slept >= a:timeout
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
187 break
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
188 endif
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
189 if type(a:assert) == v:t_func
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
190 " Remove the error added by the assert function.
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
191 call remove(v:errors, -1)
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
192 endif
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
193
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
194 sleep 10m
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 18829
diff changeset
195 if exists('*reltimefloat')
13798
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
196 let slept = float2nr(reltimefloat(reltime(start)) * 1000)
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
197 else
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
198 let slept += 10
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
199 endif
13798
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
200 endwhile
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
201
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
202 return -1 " timed out
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 endfunc
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
204
13798
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
205
10309
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
206 " Wait for up to a given milliseconds.
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
207 " With the +timers feature this waits for key-input by getchar(), Resume()
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
208 " feeds key-input and resumes process. Return time waited in milliseconds.
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
209 " Without +timers it uses simply :sleep.
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
210 func Standby(msec)
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 18829
diff changeset
211 if has('timers') && exists('*reltimefloat')
10309
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
212 let start = reltime()
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
213 let g:_standby_timer = timer_start(a:msec, function('s:feedkeys'))
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
214 call getchar()
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
215 return float2nr(reltimefloat(reltime(start)) * 1000)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
216 else
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
217 execute 'sleep ' a:msec . 'm'
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
218 return a:msec
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
219 endif
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
220 endfunc
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
221
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
222 func Resume()
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
223 if exists('g:_standby_timer')
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
224 call timer_stop(g:_standby_timer)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
225 call s:feedkeys(0)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
226 unlet g:_standby_timer
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
227 endif
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
228 endfunc
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
229
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
230 func s:feedkeys(timer)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
231 call feedkeys('x', 'nt')
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
232 endfunc
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
233
22827
20ccf5f7dc6d patch 8.2.1961: various comments can be improved
Bram Moolenaar <Bram@vim.org>
parents: 21343
diff changeset
234 " Get $VIMPROG to run the Vim executable.
12602
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
235 " The Makefile writes it as the first line in the "vimcmd" file.
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
236 func GetVimProg()
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
237 if !filereadable('vimcmd')
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
238 " Assume the script was sourced instead of running "make".
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
239 return '../vim'
12602
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
240 endif
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
241 return readfile('vimcmd')[0]
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
242 endfunc
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
243
13843
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
244 let g:valgrind_cnt = 1
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
245
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
246 " Get the command to run Vim, with -u NONE and --not-a-term arguments.
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
247 " If there is an argument use it instead of "NONE".
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
248 func GetVimCommand(...)
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
249 if !filereadable('vimcmd')
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
250 echo 'Cannot read the "vimcmd" file, falling back to ../vim.'
28704
e1aff2f300be patch 8.2.4876: MS-Windows: Shift-BS results in strange char in powershell
Bram Moolenaar <Bram@vim.org>
parents: 28317
diff changeset
251 if !has("win32")
e1aff2f300be patch 8.2.4876: MS-Windows: Shift-BS results in strange char in powershell
Bram Moolenaar <Bram@vim.org>
parents: 28317
diff changeset
252 let lines = ['../vim']
e1aff2f300be patch 8.2.4876: MS-Windows: Shift-BS results in strange char in powershell
Bram Moolenaar <Bram@vim.org>
parents: 28317
diff changeset
253 else
e1aff2f300be patch 8.2.4876: MS-Windows: Shift-BS results in strange char in powershell
Bram Moolenaar <Bram@vim.org>
parents: 28317
diff changeset
254 let lines = ['..\vim.exe']
e1aff2f300be patch 8.2.4876: MS-Windows: Shift-BS results in strange char in powershell
Bram Moolenaar <Bram@vim.org>
parents: 28317
diff changeset
255 endif
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
256 else
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
257 let lines = readfile('vimcmd')
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
258 endif
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
259 if a:0 == 0
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
260 let name = 'NONE'
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
261 else
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
262 let name = a:1
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
263 endif
12602
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
264 " For Unix Makefile writes the command to use in the second line of the
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
265 " "vimcmd" file, including environment options.
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
266 " Other Makefiles just write the executable in the first line, so fall back
13843
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
267 " to that if there is no second line or it is empty.
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
268 if len(lines) > 1 && lines[1] != ''
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
269 let cmd = lines[1]
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
270 else
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
271 let cmd = lines[0]
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
272 endif
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
273
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
274 let cmd = substitute(cmd, '-u \f\+', '-u ' . name, '')
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
275 if cmd !~ '-u '. name
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
276 let cmd = cmd . ' -u ' . name
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
277 endif
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
278 let cmd .= ' --not-a-term'
29128
d8a962d7b008 patch 8.2.5084: when the GUI shows a dialog tests get stuck
Bram Moolenaar <Bram@vim.org>
parents: 28704
diff changeset
279 let cmd .= ' --gui-dialog-file guidialogfile'
17391
8a43873df941 patch 8.1.1694: the RUN_VIM variable is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17249
diff changeset
280 let cmd = substitute(cmd, 'VIMRUNTIME=\S\+', '', '')
13843
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
281
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
282 " If using valgrind, make sure every run uses a different log file.
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
283 if cmd =~ 'valgrind.*--log-file='
21343
d265b908c802 patch 8.2.1222: using valgrind in Vim command started by test doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 21190
diff changeset
284 let cmd = substitute(cmd, '--log-file=\(\S*\)', '--log-file=\1.' . g:valgrind_cnt, '')
13843
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
285 let g:valgrind_cnt += 1
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
286 endif
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
287
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
288 return cmd
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
289 endfunc
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
290
29234
96ff6c230a66 patch 8.2.5136: debugger test fails when run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 29128
diff changeset
291 " Return one when it looks like the tests are run with valgrind, which means
96ff6c230a66 patch 8.2.5136: debugger test fails when run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 29128
diff changeset
292 " that everything is much slower.
96ff6c230a66 patch 8.2.5136: debugger test fails when run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 29128
diff changeset
293 func RunningWithValgrind()
96ff6c230a66 patch 8.2.5136: debugger test fails when run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 29128
diff changeset
294 return GetVimCommand() =~ '\<valgrind\>'
96ff6c230a66 patch 8.2.5136: debugger test fails when run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 29128
diff changeset
295 endfunc
96ff6c230a66 patch 8.2.5136: debugger test fails when run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 29128
diff changeset
296
17910
f084f846442a patch 8.1.1951: mouse double click test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 17686
diff changeset
297 " Get the command to run Vim, with --clean instead of "-u NONE".
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
298 func GetVimCommandClean()
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
299 let cmd = GetVimCommand()
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
300 let cmd = substitute(cmd, '-u NONE', '--clean', '')
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
301 let cmd = substitute(cmd, '--not-a-term', '', '')
14919
7ad55ed0a4f3 patch 8.1.0471: some tests are flaky or fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 13843
diff changeset
302
17920
233e316c0b5a patch 8.1.1956: screenshot tests may use a different encoding
Bram Moolenaar <Bram@vim.org>
parents: 17910
diff changeset
303 " Force using utf-8, Vim may pick up something else from the environment.
233e316c0b5a patch 8.1.1956: screenshot tests may use a different encoding
Bram Moolenaar <Bram@vim.org>
parents: 17910
diff changeset
304 let cmd ..= ' --cmd "set enc=utf8" '
233e316c0b5a patch 8.1.1956: screenshot tests may use a different encoding
Bram Moolenaar <Bram@vim.org>
parents: 17910
diff changeset
305
14919
7ad55ed0a4f3 patch 8.1.0471: some tests are flaky or fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 13843
diff changeset
306 " Optionally run Vim under valgrind
7ad55ed0a4f3 patch 8.1.0471: some tests are flaky or fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 13843
diff changeset
307 " let cmd = 'valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind ' . cmd
7ad55ed0a4f3 patch 8.1.0471: some tests are flaky or fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 13843
diff changeset
308
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
309 return cmd
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
310 endfunc
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
311
17249
3e2e998ce0db patch 8.1.1624: when testing in the GUI may try to run gvim in a terminal
Bram Moolenaar <Bram@vim.org>
parents: 17164
diff changeset
312 " Get the command to run Vim, with --clean, and force to run in terminal so it
3e2e998ce0db patch 8.1.1624: when testing in the GUI may try to run gvim in a terminal
Bram Moolenaar <Bram@vim.org>
parents: 17164
diff changeset
313 " won't start a new GUI.
3e2e998ce0db patch 8.1.1624: when testing in the GUI may try to run gvim in a terminal
Bram Moolenaar <Bram@vim.org>
parents: 17164
diff changeset
314 func GetVimCommandCleanTerm()
3e2e998ce0db patch 8.1.1624: when testing in the GUI may try to run gvim in a terminal
Bram Moolenaar <Bram@vim.org>
parents: 17164
diff changeset
315 " Add -v to have gvim run in the terminal (if possible)
3e2e998ce0db patch 8.1.1624: when testing in the GUI may try to run gvim in a terminal
Bram Moolenaar <Bram@vim.org>
parents: 17164
diff changeset
316 return GetVimCommandClean() .. ' -v '
3e2e998ce0db patch 8.1.1624: when testing in the GUI may try to run gvim in a terminal
Bram Moolenaar <Bram@vim.org>
parents: 17164
diff changeset
317 endfunc
3e2e998ce0db patch 8.1.1624: when testing in the GUI may try to run gvim in a terminal
Bram Moolenaar <Bram@vim.org>
parents: 17164
diff changeset
318
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
319 " Run Vim, using the "vimcmd" file and "-u NORC".
9806
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
320 " "before" is a list of Vim commands to be executed before loading plugins.
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
321 " "after" is a list of Vim commands to be executed after loading plugins.
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
322 " Plugins are not loaded, unless 'loadplugins' is set in "before".
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
323 " Return 1 if Vim could be executed.
9794
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
324 func RunVim(before, after, arguments)
9818
5c288e5e1493 commit https://github.com/vim/vim/commit/7a9a5f4019ce332cb11ce5370e3fa609299ce737
Christian Brabandt <cb@256bit.org>
parents: 9810
diff changeset
325 return RunVimPiped(a:before, a:after, a:arguments, '')
9806
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
326 endfunc
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
327
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
328 func RunVimPiped(before, after, arguments, pipecmd)
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
329 let cmd = GetVimCommand()
9804
4ef933b816e7 commit https://github.com/vim/vim/commit/ba98bef1910094179bf90b9467b6e2d2f9462601
Christian Brabandt <cb@256bit.org>
parents: 9794
diff changeset
330 let args = ''
9794
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
331 if len(a:before) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
332 call writefile(a:before, 'Xbefore.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
333 let args .= ' --cmd "so Xbefore.vim"'
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
334 endif
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
335 if len(a:after) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
336 call writefile(a:after, 'Xafter.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
337 let args .= ' -S Xafter.vim'
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
338 endif
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
339
18829
eff8d8f72a82 patch 8.1.2402: typos and other small things
Bram Moolenaar <Bram@vim.org>
parents: 18277
diff changeset
340 " Optionally run Vim under valgrind
eff8d8f72a82 patch 8.1.2402: typos and other small things
Bram Moolenaar <Bram@vim.org>
parents: 18277
diff changeset
341 " let cmd = 'valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind ' . cmd
eff8d8f72a82 patch 8.1.2402: typos and other small things
Bram Moolenaar <Bram@vim.org>
parents: 18277
diff changeset
342
9806
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
343 exe "silent !" . a:pipecmd . cmd . args . ' ' . a:arguments
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
344
9794
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
345 if len(a:before) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
346 call delete('Xbefore.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
347 endif
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
348 if len(a:after) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
349 call delete('Xafter.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
350 endif
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
351 return 1
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
352 endfunc
18277
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
353
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
354 func IsRoot()
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
355 if !has('unix')
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
356 return v:false
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
357 elseif $USER == 'root' || system('id -un') =~ '\<root\>'
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
358 return v:true
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
359 endif
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
360 return v:false
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
361 endfunc
19906
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
362
20221
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
363 " Get all messages but drop the maintainer entry.
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
364 func GetMessages()
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
365 redir => result
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
366 redraw | messages
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
367 redir END
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
368 let msg_list = split(result, "\n")
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
369 if msg_list->len() > 0 && msg_list[0] =~ 'Messages maintainer:'
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
370 return msg_list[1:]
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
371 endif
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
372 return msg_list
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
373 endfunc
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
374
21190
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
375 " Run the list of commands in 'cmds' and look for 'errstr' in exception.
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
376 " Note that assert_fails() cannot be used in some places and this function
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
377 " can be used.
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
378 func AssertException(cmds, errstr)
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
379 let save_exception = ''
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
380 try
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
381 for cmd in a:cmds
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
382 exe cmd
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
383 endfor
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
384 catch
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
385 let save_exception = v:exception
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
386 endtry
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
387 call assert_match(a:errstr, save_exception)
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
388 endfunc
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
389
19906
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
390 " vim: shiftwidth=2 sts=2 expandtab