Mercurial > vim
annotate src/testdir/test_system.vim @ 19449:f8408ba21982 v8.2.0282
patch 8.2.0282: Vim9: setting number option not tested
Commit: https://github.com/vim/vim/commit/401d9ffb5a8a40102c000c2d2614aa043f541f90
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 19 18:14:44 2020 +0100
patch 8.2.0282: Vim9: setting number option not tested
Problem: Vim9: setting number option not tested.
Solution: Add more tests. Fix assigning to global variable.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 19 Feb 2020 18:15:05 +0100 |
parents | 0eeaa9a6e4e7 |
children | 244eb8d8d100 |
rev | line source |
---|---|
10522
7232cd9f8a7c
commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for system() and systemlist() |
7232cd9f8a7c
commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
17698
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
3 source shared.vim |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
4 source check.vim |
17698
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
5 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11637
diff
changeset
|
6 func Test_System() |
18195
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
7 if !has('win32') |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
8 call assert_equal("123\n", system('echo 123')) |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
9 call assert_equal(['123'], systemlist('echo 123')) |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
10 call assert_equal('123', system('cat', '123')) |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
11 call assert_equal(['123'], systemlist('cat', '123')) |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
12 call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"])) |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
13 else |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
14 call assert_equal("123\n", system('echo 123')) |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
15 call assert_equal(["123\r"], systemlist('echo 123')) |
18197
78d4902b22df
patch 8.1.2093: MS-Windows: system() test fails
Bram Moolenaar <Bram@vim.org>
parents:
18195
diff
changeset
|
16 call assert_equal("123\n", system('more', '123')) |
78d4902b22df
patch 8.1.2093: MS-Windows: system() test fails
Bram Moolenaar <Bram@vim.org>
parents:
18195
diff
changeset
|
17 call assert_equal(["123\r"], systemlist('more', '123')) |
78d4902b22df
patch 8.1.2093: MS-Windows: system() test fails
Bram Moolenaar <Bram@vim.org>
parents:
18195
diff
changeset
|
18 call assert_equal(["as\r", "df\r"], systemlist('more', ["as\<NL>df"])) |
18195
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
19 endif |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
20 |
10522
7232cd9f8a7c
commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 new Xdummy |
7232cd9f8a7c
commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 call setline(1, ['asdf', "pw\<NL>er", 'xxxx']) |
18473
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
23 |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
24 if executable('wc') |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
25 let out = system('wc -l', bufnr('%')) |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
26 " On OS/X we get leading spaces |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
27 let out = substitute(out, '^ *', '', '') |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
28 call assert_equal("3\n", out) |
10526
06724e21d8c1
commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents:
10522
diff
changeset
|
29 |
18473
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
30 let out = systemlist('wc -l', bufnr('%')) |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
31 " On Windows we may get a trailing CR. |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
32 if out != ["3\r"] |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
33 " On OS/X we get leading spaces |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
34 if type(out) == v:t_list |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
35 let out[0] = substitute(out[0], '^ *', '', '') |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
36 endif |
0eeaa9a6e4e7
patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
37 call assert_equal(['3'], out) |
10528
3ea703795a4f
commit https://github.com/vim/vim/commit/31f19ce0a052f7c76d44a9a190e468c79cf5d56d
Christian Brabandt <cb@256bit.org>
parents:
10526
diff
changeset
|
38 endif |
10526
06724e21d8c1
commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents:
10522
diff
changeset
|
39 endif |
06724e21d8c1
commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents:
10522
diff
changeset
|
40 |
18195
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
41 if !has('win32') |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
42 let out = systemlist('cat', bufnr('%')) |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
43 call assert_equal(['asdf', "pw\<NL>er", 'xxxx'], out) |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
44 else |
a81f0c936112
patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
45 let out = systemlist('more', bufnr('%')) |
18197
78d4902b22df
patch 8.1.2093: MS-Windows: system() test fails
Bram Moolenaar <Bram@vim.org>
parents:
18195
diff
changeset
|
46 call assert_equal(["asdf\r", "pw\r", "er\r", "xxxx\r"], out) |
10526
06724e21d8c1
commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents:
10522
diff
changeset
|
47 endif |
10522
7232cd9f8a7c
commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 bwipe! |
7232cd9f8a7c
commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 |
7232cd9f8a7c
commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 call assert_fails('call system("wc -l", 99999)', 'E86:') |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11637
diff
changeset
|
51 endfunc |
10589
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
52 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11637
diff
changeset
|
53 func Test_system_exmode() |
10615
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
54 if has('unix') " echo $? only works on Unix |
17698
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
55 let cmd = ' -es -c "source Xscript" +q; echo "result=$?"' |
10615
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
56 " Need to put this in a script, "catch" isn't found after an unknown |
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
57 " function. |
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
58 call writefile(['try', 'call doesnotexist()', 'catch', 'endtry'], 'Xscript') |
17698
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
59 let a = system(GetVimCommand() . cmd) |
11637
bcab4e804c20
patch 8.0.0701: system test failing when using X11 forwarding
Christian Brabandt <cb@256bit.org>
parents:
10615
diff
changeset
|
60 call assert_match('result=0', a) |
10615
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
61 call assert_equal(0, v:shell_error) |
10591
234da476c4fd
patch 8.0.0185: system() test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10589
diff
changeset
|
62 endif |
234da476c4fd
patch 8.0.0185: system() test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10589
diff
changeset
|
63 |
10589
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
64 " Error before try does set error flag. |
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
65 call writefile(['call nosuchfunction()', 'try', 'call doesnotexist()', 'catch', 'endtry'], 'Xscript') |
10615
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
66 if has('unix') " echo $? only works on Unix |
17698
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
67 let a = system(GetVimCommand() . cmd) |
10615
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
68 call assert_notequal('0', a[0]) |
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
69 endif |
10589
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
70 |
17698
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
71 let cmd = ' -es -c "source Xscript" +q' |
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
72 let a = system(GetVimCommand() . cmd) |
10589
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
73 call assert_notequal(0, v:shell_error) |
10615
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
74 call delete('Xscript') |
10589
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
75 |
10615
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
76 if has('unix') " echo $? only works on Unix |
17698
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
77 let cmd = ' -es -c "call doesnotexist()" +q; echo $?' |
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
78 let a = system(GetVimCommand() . cmd) |
10615
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
79 call assert_notequal(0, a[0]) |
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
80 endif |
10589
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
81 |
17698
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
82 let cmd = ' -es -c "call doesnotexist()" +q' |
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
83 let a = system(GetVimCommand(). cmd) |
10589
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
84 call assert_notequal(0, v:shell_error) |
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
85 |
10615
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
86 if has('unix') " echo $? only works on Unix |
17698
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
87 let cmd = ' -es -c "call doesnotexist()|let a=1" +q; echo $?' |
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
88 let a = system(GetVimCommand() . cmd) |
10615
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
89 call assert_notequal(0, a[0]) |
de4aae865134
patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10591
diff
changeset
|
90 endif |
10589
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
91 |
17698
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
92 let cmd = ' -es -c "call doesnotexist()|let a=1" +q' |
131f1d8c5860
patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents:
17624
diff
changeset
|
93 let a = system(GetVimCommand() . cmd) |
10589
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
94 call assert_notequal(0, v:shell_error) |
b0c9c1a05054
patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents:
10528
diff
changeset
|
95 endfunc |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
96 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
97 func Test_system_with_shell_quote() |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
98 CheckMSWindows |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
99 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
100 call mkdir('Xdir with spaces', 'p') |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
101 call system('copy "%COMSPEC%" "Xdir with spaces\cmd.exe"') |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
102 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
103 let shell_save = &shell |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
104 let shellxquote_save = &shellxquote |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
105 try |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
106 " Set 'shell' always needs noshellslash. |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
107 let shellslash_save = &shellslash |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
108 set noshellslash |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
109 let shell_tests = [ |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
110 \ expand('$COMSPEC'), |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
111 \ '"' . fnamemodify('Xdir with spaces\cmd.exe', ':p') . '"', |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
112 \] |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
113 let &shellslash = shellslash_save |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
114 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
115 let sxq_tests = ['', '(', '"'] |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
116 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
117 " Matrix tests: 'shell' * 'shellxquote' |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
118 for shell in shell_tests |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
119 let &shell = shell |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
120 for sxq in sxq_tests |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
121 let &shellxquote = sxq |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
122 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
123 let msg = printf('shell=%s shellxquote=%s', &shell, &shellxquote) |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
124 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
125 try |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
126 let out = 'echo 123'->system() |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
127 catch |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
128 call assert_report(printf('%s: %s', msg, v:exception)) |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
129 continue |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
130 endtry |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
131 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
132 " On Windows we may get a trailing space and CR. |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
133 if out != "123 \n" |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
134 call assert_equal("123\n", out, msg) |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
135 endif |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
136 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
137 endfor |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
138 endfor |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
139 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
140 finally |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
141 let &shell = shell_save |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
142 let &shellxquote = shellxquote_save |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
143 call delete('Xdir with spaces', 'rf') |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
144 endtry |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18197
diff
changeset
|
145 endfunc |