patch 7.4.1514
Problem: Channel output to file not implemented yet.
Solution: Implement it for Unix.
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index dd7ef4e..0885500 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -555,6 +555,97 @@
endtry
endfunc
+func Test_nl_write_out_file()
+ if !has('job')
+ return
+ endif
+ " TODO: make this work for MS-Windows
+ if !has('unix')
+ return
+ endif
+ call ch_log('Test_nl_write_out_file()')
+ let job = job_start(s:python . " test_channel_pipe.py",
+ \ {'out-io': 'file', 'out-name': 'Xoutput'})
+ call assert_equal("run", job_status(job))
+ try
+ let handle = job_getchannel(job)
+ call ch_sendraw(handle, "echo line one\n")
+ call ch_sendraw(handle, "echo line two\n")
+ call ch_sendraw(handle, "double this\n")
+ for i in range(50)
+ sleep 10m
+ if len(readfile('Xoutput')) > 2
+ break
+ endif
+ endfor
+ call assert_equal(['line one', 'line two', 'this', 'AND this'], readfile('Xoutput'))
+ finally
+ call job_stop(job)
+ call delete('Xoutput')
+ endtry
+endfunc
+
+func Test_nl_write_err_file()
+ if !has('job')
+ return
+ endif
+ " TODO: make this work for MS-Windows
+ if !has('unix')
+ return
+ endif
+ call ch_log('Test_nl_write_err_file()')
+ let job = job_start(s:python . " test_channel_pipe.py",
+ \ {'err-io': 'file', 'err-name': 'Xoutput'})
+ call assert_equal("run", job_status(job))
+ try
+ let handle = job_getchannel(job)
+ call ch_sendraw(handle, "echoerr line one\n")
+ call ch_sendraw(handle, "echoerr line two\n")
+ call ch_sendraw(handle, "doubleerr this\n")
+ for i in range(50)
+ sleep 10m
+ if len(readfile('Xoutput')) > 2
+ break
+ endif
+ endfor
+ call assert_equal(['line one', 'line two', 'this', 'AND this'], readfile('Xoutput'))
+ finally
+ call job_stop(job)
+ call delete('Xoutput')
+ endtry
+endfunc
+
+func Test_nl_write_both_file()
+ if !has('job')
+ return
+ endif
+ " TODO: make this work for MS-Windows
+ if !has('unix')
+ return
+ endif
+ call ch_log('Test_nl_write_both_file()')
+ let job = job_start(s:python . " test_channel_pipe.py",
+ \ {'out-io': 'file', 'out-name': 'Xoutput', 'err-io': 'out'})
+ call assert_equal("run", job_status(job))
+ try
+ let handle = job_getchannel(job)
+ call ch_sendraw(handle, "echoerr line one\n")
+ call ch_sendraw(handle, "echo line two\n")
+ call ch_sendraw(handle, "double this\n")
+ call ch_sendraw(handle, "doubleerr that\n")
+ for i in range(50)
+ sleep 10m
+ if len(readfile('Xoutput')) > 5
+ break
+ endif
+ endfor
+ call assert_equal(['line one', 'line two', 'this', 'AND this', 'that', 'AND that'], readfile('Xoutput'))
+ finally
+ call job_stop(job)
+ call delete('Xoutput')
+ endtry
+endfunc
+
func Test_pipe_to_buffer()
if !has('job')
return
diff --git a/src/testdir/test_channel_pipe.py b/src/testdir/test_channel_pipe.py
index 2097d3e..d5da687 100644
--- a/src/testdir/test_channel_pipe.py
+++ b/src/testdir/test_channel_pipe.py
@@ -21,10 +21,13 @@
if typed.startswith("echo "):
print(typed[5:-1])
sys.stdout.flush()
- if typed.startswith("echoerr"):
- print(typed[8:-1], file=sys.stderr)
- sys.stderr.flush()
- if typed.startswith("double"):
+ if typed.startswith("double "):
print(typed[7:-1] + "\nAND " + typed[7:-1])
sys.stdout.flush()
+ if typed.startswith("echoerr "):
+ print(typed[8:-1], file=sys.stderr)
+ sys.stderr.flush()
+ if typed.startswith("doubleerr "):
+ print(typed[10:-1] + "\nAND " + typed[10:-1], file=sys.stderr)
+ sys.stderr.flush()