comparison src/testdir/test_terminal.vim @ 12389:d0cf7f71b95b v8.0.1074

patch 8.0.1074: ":term NONE" does not work on MS-Windows commit https://github.com/vim/vim/commit/2dc9d26c14e410c09e538cccfa90da19ae344ba4 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 8 14:39:30 2017 +0200 patch 8.0.1074: ":term NONE" does not work on MS-Windows Problem: ":term NONE" does not work on MS-Windows. Solution: Make it work. Split "pty" into "pty_in" and "pty_out". (Yasuhiro Matsumoto, closes #2058, closes #2045)
author Christian Brabandt <cb@256bit.org>
date Fri, 08 Sep 2017 14:45:05 +0200
parents 9a7fb1d01137
children 6ef5e636f246
comparison
equal deleted inserted replaced
12388:9741eade42c9 12389:d0cf7f71b95b
34 endfunc 34 endfunc
35 35
36 func Test_terminal_basic() 36 func Test_terminal_basic()
37 let buf = Run_shell_in_terminal({}) 37 let buf = Run_shell_in_terminal({})
38 if has("unix") 38 if has("unix")
39 call assert_match("^/dev/", job_info(g:job).tty) 39 call assert_match('^/dev/', job_info(g:job).tty_out)
40 call assert_match("^/dev/", term_gettty('')) 40 call assert_match('^/dev/', term_gettty(''))
41 else 41 else
42 call assert_match("^winpty://", job_info(g:job).tty) 42 call assert_match('^\\\\.\\pipe\\', job_info(g:job).tty_out)
43 call assert_match("^winpty://", term_gettty('')) 43 call assert_match('^\\\\.\\pipe\\', term_gettty(''))
44 endif 44 endif
45 call assert_equal('t', mode()) 45 call assert_equal('t', mode())
46 call assert_match('%aR[^\n]*running]', execute('ls')) 46 call assert_match('%aR[^\n]*running]', execute('ls'))
47 47
48 call Stop_shell_in_terminal(buf) 48 call Stop_shell_in_terminal(buf)
537 537
538 bwipe! 538 bwipe!
539 endfunc 539 endfunc
540 540
541 func Test_terminal_no_cmd() 541 func Test_terminal_no_cmd()
542 " Todo: make this work on all systems.
543 if !has('unix')
544 return
545 endif
546 " Todo: make this work in the GUI 542 " Todo: make this work in the GUI
547 if !has('gui_running') 543 if !has('gui_running')
548 return 544 return
549 endif 545 endif
550 let buf = term_start('NONE', {}) 546 let buf = term_start('NONE', {})
551 call assert_notequal(0, buf) 547 call assert_notequal(0, buf)
552 548
553 let pty = job_info(term_getjob(buf))['tty'] 549 let pty = job_info(term_getjob(buf))['tty_out']
554 call assert_notequal('', pty) 550 call assert_notequal('', pty)
555 call system('echo "look here" > ' . pty) 551 if has('win32')
556 call term_wait(buf) 552 silent exe '!cmd /c "echo look here > ' . pty . '"'
557 call assert_equal('look here', term_getline(buf, 1)) 553 else
554 call system('echo "look here" > ' . pty)
555 endif
556 call term_wait(buf)
557
558 let result = term_getline(buf, 1)
559 if has('win32')
560 let result = substitute(result, '\s\+$', '', '')
561 endif
562 call assert_equal('look here', result)
558 bwipe! 563 bwipe!
559 endfunc 564 endfunc
560 565
561 func Test_terminal_special_chars() 566 func Test_terminal_special_chars()
562 " this file name only works on Unix 567 " this file name only works on Unix
598 let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xfile'}) 603 let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xfile'})
599 call term_wait(buf) 604 call term_wait(buf)
600 call WaitFor('len(readfile("Xfile")) > 0') 605 call WaitFor('len(readfile("Xfile")) > 0')
601 call assert_match('123', readfile('Xfile')[0]) 606 call assert_match('123', readfile('Xfile')[0])
602 call delete('Xfile') 607 call delete('Xfile')
608 bwipe
603 endif 609 endif
604 610
605 if has('unix') 611 if has('unix')
606 let buf = term_start('xyzabc', {'err_io': 'file', 'err_name': 'Xfile'}) 612 let buf = term_start('xyzabc', {'err_io': 'file', 'err_name': 'Xfile'})
607 call term_wait(buf) 613 call term_wait(buf)
608 call WaitFor('len(readfile("Xfile")) > 0') 614 call WaitFor('len(readfile("Xfile")) > 0')
609 call assert_match('executing job failed', readfile('Xfile')[0]) 615 call assert_match('executing job failed', readfile('Xfile')[0])
610 call delete('Xfile') 616 call delete('Xfile')
617 bwipe
611 618
612 call writefile(['one line'], 'Xfile') 619 call writefile(['one line'], 'Xfile')
613 let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xfile'}) 620 let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xfile'})
614 call term_wait(buf) 621 call term_wait(buf)
615 call WaitFor('term_getline(' . buf . ', 1) == "one line"') 622 call WaitFor('term_getline(' . buf . ', 1) == "one line"')