annotate src/testdir/test_system.vim @ 10526:06724e21d8c1 v8.0.0153

commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 8 13:55:06 2017 +0100 patch 8.0.0153: system() test fails on MS-Windows Problem: system() test fails on MS-Windows. Solution: Deal when extra space and CR.
author Christian Brabandt <cb@256bit.org>
date Sun, 08 Jan 2017 14:00:04 +0100
parents 7232cd9f8a7c
children 3ea703795a4f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 function! Test_System()
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 if !executable('echo') || !executable('cat') || !executable('wc')
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 return
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 endif
10526
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
7 let out = system('echo 123')
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
8 " On Windows we may get a trailing space.
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
9 if out != "123 \n"
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
10 call assert_equal("123\n", out)
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
11 endif
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
12
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
13 let out = systemlist('echo 123')
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
14 " On Windows we may get a trailing space and CR.
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
15 if out != ["123 \r"]
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
16 call assert_equal(['123'], out)
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
17 endif
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
18
10522
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal('123', system('cat', '123'))
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal(['123'], systemlist('cat', '123'))
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"]))
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 new Xdummy
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call setline(1, ['asdf', "pw\<NL>er", 'xxxx'])
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 call assert_equal("3\n", system('wc -l', bufnr('%')))
10526
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
25
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
26 let out = systemlist('wc -l', bufnr('%'))
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
27 " On Windows we may get a trailing CR.
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
28 if out != ["3\r"]
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
29 call assert_equal(['3'], out)
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
30 endif
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
31
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
32 let out = systemlist('cat', bufnr('%'))
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
33 " On Windows we may get a trailing CR.
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
34 if out != ["asdf\r", "pw\<NL>er\r", "xxxx\r"]
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
35 call assert_equal(['asdf', "pw\<NL>er", 'xxxx'], out)
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
36 endif
10522
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 bwipe!
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call assert_fails('call system("wc -l", 99999)', 'E86:')
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 endfunction