comparison 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
comparison
equal deleted inserted replaced
10525:80f969a6cae2 10526:06724e21d8c1
2 2
3 function! Test_System() 3 function! Test_System()
4 if !executable('echo') || !executable('cat') || !executable('wc') 4 if !executable('echo') || !executable('cat') || !executable('wc')
5 return 5 return
6 endif 6 endif
7 call assert_equal("123\n", system('echo 123')) 7 let out = system('echo 123')
8 call assert_equal(['123'], systemlist('echo 123')) 8 " On Windows we may get a trailing space.
9 if out != "123 \n"
10 call assert_equal("123\n", out)
11 endif
12
13 let out = systemlist('echo 123')
14 " On Windows we may get a trailing space and CR.
15 if out != ["123 \r"]
16 call assert_equal(['123'], out)
17 endif
18
9 call assert_equal('123', system('cat', '123')) 19 call assert_equal('123', system('cat', '123'))
10 call assert_equal(['123'], systemlist('cat', '123')) 20 call assert_equal(['123'], systemlist('cat', '123'))
11 call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"])) 21 call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"]))
12 new Xdummy 22 new Xdummy
13 call setline(1, ['asdf', "pw\<NL>er", 'xxxx']) 23 call setline(1, ['asdf', "pw\<NL>er", 'xxxx'])
14 call assert_equal("3\n", system('wc -l', bufnr('%'))) 24 call assert_equal("3\n", system('wc -l', bufnr('%')))
15 call assert_equal(['3'], systemlist('wc -l', bufnr('%'))) 25
16 call assert_equal(['asdf', "pw\<NL>er", 'xxxx'], systemlist('cat', bufnr('%'))) 26 let out = systemlist('wc -l', bufnr('%'))
27 " On Windows we may get a trailing CR.
28 if out != ["3\r"]
29 call assert_equal(['3'], out)
30 endif
31
32 let out = systemlist('cat', bufnr('%'))
33 " On Windows we may get a trailing CR.
34 if out != ["asdf\r", "pw\<NL>er\r", "xxxx\r"]
35 call assert_equal(['asdf', "pw\<NL>er", 'xxxx'], out)
36 endif
17 bwipe! 37 bwipe!
18 38
19 call assert_fails('call system("wc -l", 99999)', 'E86:') 39 call assert_fails('call system("wc -l", 99999)', 'E86:')
20 endfunction 40 endfunction