annotate src/testdir/shared.vim @ 32182:d53f7be86b38 v9.0.1422

patch 9.0.1422: Sage files are not recognized Commit: https://github.com/vim/vim/commit/d0639d717ba7cf8b04b588aadd0b379ed43a5f1f Author: Amaan Qureshi <amaanq12@gmail.com> Date: Tue Mar 21 21:31:55 2023 +0000 patch 9.0.1422: Sage files are not recognized Problem: Sage files are not recognized. Solution: Add a pattern for Sage files. (Amaan Qureshi, closes https://github.com/vim/vim/issues/12176)
author Bram Moolenaar <Bram@vim.org>
date Tue, 21 Mar 2023 22:45:03 +0100
parents ee50174810ac
children b08d31805a75
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
31241
ee50174810ac patch 9.0.0954: cannot detect whether modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents: 31043
diff changeset
10 " When 'term' is changed some status requests may be sent. The responses may
ee50174810ac patch 9.0.0954: cannot detect whether modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents: 31043
diff changeset
11 " interfere with what is being tested. A short sleep is used to process any of
ee50174810ac patch 9.0.0954: cannot detect whether modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents: 31043
diff changeset
12 " those responses first.
ee50174810ac patch 9.0.0954: cannot detect whether modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents: 31043
diff changeset
13 func WaitForResponses()
ee50174810ac patch 9.0.0954: cannot detect whether modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents: 31043
diff changeset
14 sleep 50m
ee50174810ac patch 9.0.0954: cannot detect whether modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents: 31043
diff changeset
15 endfunc
ee50174810ac patch 9.0.0954: cannot detect whether modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents: 31043
diff changeset
16
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 " Get the name of the Python executable.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 " Also keeps it in s:python.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 func PythonProg()
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 " 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
21 " 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
22 if has('unix')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 " 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
24 " 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
25 if !(has('job') || executable('pkill'))
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 return ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 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
28 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
29 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
30 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
31 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
32 else
d32dc906dd2c patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents: 24570
diff changeset
33 return ''
d32dc906dd2c patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents: 24570
diff changeset
34 end
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 elseif has('win32')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 " 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
37 " 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
38 " 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
39 if executable('py.exe')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 let s:python = 'py.exe'
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 elseif executable('python.exe')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 let s:python = 'python.exe'
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 return ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 return ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 return s:python
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 " 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
53 func RunCommand(cmd)
20309
cae01dabd78e patch 8.2.0710: Netbeans test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 20221
diff changeset
54 " 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
55 let g:test_is_flaky = 1
cae01dabd78e patch 8.2.0710: Netbeans test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 20221
diff changeset
56
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 let job = 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 if has('job')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 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
60 call job_setoptions(job, {"stoponexit": "kill"})
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 elseif has('win32')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 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
63 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 exe 'silent !' . a:cmd . '&'
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 return job
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 " 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
70 func GetPort()
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 let l = []
30033
17c46a3d0ef5 patch 9.0.0354: MS-Windows: starting a python server for test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 29234
diff changeset
72 " with 200 it sometimes failed, with 400 is rarily failed
17c46a3d0ef5 patch 9.0.0354: MS-Windows: starting a python server for test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 29234
diff changeset
73 for i in range(600)
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 try
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 let l = readfile("Xportnr")
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 catch
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 endtry
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 if len(l) >= 1
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 break
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 sleep 10m
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 endfor
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 call delete("Xportnr")
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 if len(l) == 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 " Can't make the connection, give up.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 return 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 return l[0]
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 " 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
93 " Always kills the server before returning.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 func RunServer(cmd, testfunc, args)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 " 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
96 call delete("Xportnr")
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 if len(a:args) == 1
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 let arg = ' ' . a:args[0]
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 let arg = ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 let pycmd = s:python . " " . a:cmd . arg
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 try
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 let g:currentJob = RunCommand(pycmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107
30063
72c8fbb9e242 patch 9.0.0369: a failing flaky test doesn't mention the time
Bram Moolenaar <Bram@vim.org>
parents: 30033
diff changeset
108 " Wait for some time for the port number to be there.
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 let port = GetPort()
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 if port == 0
30069
cb21745cbbab patch 9.0.0372: MS-Windows: "%T" time format does not appear to work
Bram Moolenaar <Bram@vim.org>
parents: 30063
diff changeset
111 call assert_report(strftime("%H:%M:%S") .. " Can't start " .. a:cmd)
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 return
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 call call(function(a:testfunc), [port])
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 catch
30063
72c8fbb9e242 patch 9.0.0369: a failing flaky test doesn't mention the time
Bram Moolenaar <Bram@vim.org>
parents: 30033
diff changeset
117 call assert_report('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
118 finally
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 call s:kill_server(a:cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 endtry
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 func s:kill_server(cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 if has('job')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 if exists('g:currentJob')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 call job_stop(g:currentJob)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 unlet g:currentJob
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 elseif has('win32')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 let cmd = substitute(a:cmd, ".py", '', '')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 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
132 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 call system("pkill -f " . a:cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136
13650
87ffb7f85b28 patch 8.0.1697: various tests are still a bit flaky
Christian Brabandt <cb@256bit.org>
parents: 13460
diff changeset
137 " 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
138 " 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
139 " 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
140 " 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
141 "
13351
33a2277b8d4d patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents: 13304
diff changeset
142 " 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
143 "
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
144 " 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
145 " 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
146 " not return.
11709
c3227699ad4d patch 8.0.0737: crash when X11 selection is very big
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
147 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
148 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
149 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
150 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
151 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
152 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
153 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
154 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
155
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 " 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
157 " (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
158 " 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
159 "
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 " 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
161 "
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 " 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
171 " 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
172 " 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
173 " 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
174 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
175 " 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
176 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
177 if exists('*reltimefloat')
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
178 let start = reltime()
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
179 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
180
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 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
182 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
183 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
184 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
185 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
186 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
187 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
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 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
190 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
191 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
192
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 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
194 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
195 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
196 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
197 " 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
198 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
199 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
200
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 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
202 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
203 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
204 else
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
205 let slept += 10
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
206 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
207 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
208
415185e2c970 patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents: 13650
diff changeset
209 return -1 " timed out
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 endfunc
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
211
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
212
10309
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
213 " 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
214 " 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
215 " 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
216 " Without +timers it uses simply :sleep.
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
217 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
218 if has('timers') && exists('*reltimefloat')
10309
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
219 let start = reltime()
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
220 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
221 call getchar()
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
222 return float2nr(reltimefloat(reltime(start)) * 1000)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
223 else
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
224 execute 'sleep ' a:msec . 'm'
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
225 return a:msec
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
226 endif
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
227 endfunc
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
228
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
229 func Resume()
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
230 if exists('g:_standby_timer')
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
231 call timer_stop(g:_standby_timer)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
232 call s:feedkeys(0)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
233 unlet g:_standby_timer
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
234 endif
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
235 endfunc
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
236
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
237 func s:feedkeys(timer)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
238 call feedkeys('x', 'nt')
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
239 endfunc
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
240
31043
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
241 " Get the name of the Vim executable that we expect has been build in the src
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
242 " directory.
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
243 func s:GetJustBuildVimExe()
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
244 if has("win32")
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
245 if !filereadable('..\vim.exe') && filereadable('..\vimd.exe')
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
246 " looks like the debug executable was intentionally build, so use it
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
247 return '..\vimd.exe'
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
248 endif
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
249 return '..\vim.exe'
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
250 endif
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
251 return '../vim'
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
252 endfunc
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
253
22827
20ccf5f7dc6d patch 8.2.1961: various comments can be improved
Bram Moolenaar <Bram@vim.org>
parents: 21343
diff changeset
254 " 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
255 " The Makefile writes it as the first line in the "vimcmd" file.
31043
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
256 " Falls back to the Vim executable in the src directory.
12602
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
257 func GetVimProg()
31043
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
258 if filereadable('vimcmd')
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
259 return readfile('vimcmd')[0]
12602
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
260 endif
31043
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
261 echo 'Cannot read the "vimcmd" file, falling back to ../vim.'
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
262
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
263 " Probably the script was sourced instead of running "make".
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
264 " We assume Vim was just build in the src directory then.
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
265 return s:GetJustBuildVimExe()
12602
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
266 endfunc
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
267
13843
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
268 let g:valgrind_cnt = 1
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
269
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
270 " 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
271 " 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
272 func GetVimCommand(...)
31043
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
273 if filereadable('vimcmd')
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
274 let lines = readfile('vimcmd')
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
275 else
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
276 echo 'Cannot read the "vimcmd" file, falling back to ../vim.'
31043
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
277 let lines = [s:GetJustBuildVimExe()]
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
278 endif
31043
61db3a2a0e78 patch 9.0.0856: MS-Windows: executable not found when running test
Bram Moolenaar <Bram@vim.org>
parents: 30069
diff changeset
279
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
280 if a:0 == 0
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
281 let name = 'NONE'
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
282 else
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
283 let name = a:1
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
284 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
285 " 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
286 " "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
287 " 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
288 " 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
289 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
290 let cmd = lines[1]
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
291 else
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
292 let cmd = lines[0]
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
293 endif
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
294
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
295 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
296 if cmd !~ '-u '. name
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
297 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
298 endif
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
299 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
300 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
301 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
302
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
303 " 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
304 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
305 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
306 let g:valgrind_cnt += 1
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
307 endif
619730d0d864 patch 8.0.1793: no test for "vim -g"
Christian Brabandt <cb@256bit.org>
parents: 13798
diff changeset
308
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
309 return cmd
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
310 endfunc
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
311
29234
96ff6c230a66 patch 8.2.5136: debugger test fails when run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 29128
diff changeset
312 " 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
313 " 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
314 func RunningWithValgrind()
96ff6c230a66 patch 8.2.5136: debugger test fails when run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 29128
diff changeset
315 return GetVimCommand() =~ '\<valgrind\>'
96ff6c230a66 patch 8.2.5136: debugger test fails when run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 29128
diff changeset
316 endfunc
96ff6c230a66 patch 8.2.5136: debugger test fails when run with valgrind
Bram Moolenaar <Bram@vim.org>
parents: 29128
diff changeset
317
17910
f084f846442a patch 8.1.1951: mouse double click test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 17686
diff changeset
318 " 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
319 func GetVimCommandClean()
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
320 let cmd = GetVimCommand()
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
321 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
322 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
323
17920
233e316c0b5a patch 8.1.1956: screenshot tests may use a different encoding
Bram Moolenaar <Bram@vim.org>
parents: 17910
diff changeset
324 " 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
325 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
326
14919
7ad55ed0a4f3 patch 8.1.0471: some tests are flaky or fail on some systems
Bram Moolenaar <Bram@vim.org>
parents: 13843
diff changeset
327 " 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
328 " 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
329
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
330 return cmd
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
331 endfunc
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 12763
diff changeset
332
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
333 " 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
334 " 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
335 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
336 " 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
337 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
338 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
339
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
340 " 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
341 " "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
342 " "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
343 " 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
344 " 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
345 func RunVim(before, after, arguments)
9818
5c288e5e1493 commit https://github.com/vim/vim/commit/7a9a5f4019ce332cb11ce5370e3fa609299ce737
Christian Brabandt <cb@256bit.org>
parents: 9810
diff changeset
346 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
347 endfunc
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
348
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
349 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
350 let cmd = GetVimCommand()
9804
4ef933b816e7 commit https://github.com/vim/vim/commit/ba98bef1910094179bf90b9467b6e2d2f9462601
Christian Brabandt <cb@256bit.org>
parents: 9794
diff changeset
351 let args = ''
9794
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
352 if len(a:before) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
353 call writefile(a:before, 'Xbefore.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
354 let args .= ' --cmd "so Xbefore.vim"'
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
355 endif
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
356 if len(a:after) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
357 call writefile(a:after, 'Xafter.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
358 let args .= ' -S Xafter.vim'
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
359 endif
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
360
18829
eff8d8f72a82 patch 8.1.2402: typos and other small things
Bram Moolenaar <Bram@vim.org>
parents: 18277
diff changeset
361 " Optionally run Vim under valgrind
eff8d8f72a82 patch 8.1.2402: typos and other small things
Bram Moolenaar <Bram@vim.org>
parents: 18277
diff changeset
362 " 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
363
9806
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
364 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
365
9794
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
366 if len(a:before) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
367 call delete('Xbefore.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
368 endif
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
369 if len(a:after) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
370 call delete('Xafter.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
371 endif
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
372 return 1
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
373 endfunc
18277
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
374
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
375 func IsRoot()
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
376 if !has('unix')
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
377 return v:false
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
378 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
379 return v:true
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
380 endif
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
381 return v:false
f6dcf7eabd26 patch 8.1.2133: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
382 endfunc
19906
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
383
20221
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
384 " 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
385 func GetMessages()
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
386 redir => result
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
387 redraw | messages
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
388 redir END
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
389 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
390 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
391 return msg_list[1:]
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
392 endif
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
393 return msg_list
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
394 endfunc
ec0ace1ddc20 patch 8.2.0666: Ruby test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
395
21190
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
396 " 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
397 " 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
398 " can be used.
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
399 func AssertException(cmds, errstr)
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
400 let save_exception = ''
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
401 try
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
402 for cmd in a:cmds
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
403 exe cmd
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
404 endfor
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
405 catch
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
406 let save_exception = v:exception
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
407 endtry
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
408 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
409 endfunc
10eb6c38938c patch 8.2.1146: not enough testing for Python
Bram Moolenaar <Bram@vim.org>
parents: 20309
diff changeset
410
19906
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
411 " vim: shiftwidth=2 sts=2 expandtab