patch 7.4.1254
Problem: Opening a second channel causes a crash. (Ken Takata)
Solution: Don't re-allocate the array with channels.
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index de64188..b416520 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -17,6 +17,8 @@
finish
endif
+let s:port = -1
+
func s:start_server()
" The Python program writes the port number in Xportnr.
call delete("Xportnr")
@@ -49,9 +51,9 @@
call assert_false(1, "Can't start test_channel.py")
return -1
endif
- let port = l[0]
+ let s:port = l[0]
- let handle = ch_open('localhost:' . port, 'json')
+ let handle = ch_open('localhost:' . s:port, 'json')
return handle
endfunc
@@ -94,6 +96,24 @@
call s:kill_server()
endfunc
+" Test that we can open two channels.
+func Test_two_channels()
+ let handle = s:start_server()
+ if handle < 0
+ return
+ endif
+ call assert_equal('got it', ch_sendexpr(handle, 'hello!'))
+
+ let newhandle = ch_open('localhost:' . s:port, 'json')
+ call assert_equal('got it', ch_sendexpr(newhandle, 'hello!'))
+ call assert_equal('got it', ch_sendexpr(handle, 'hello!'))
+
+ call ch_close(handle)
+ call assert_equal('got it', ch_sendexpr(newhandle, 'hello!'))
+
+ call s:kill_server()
+endfunc
+
" Test that a server crash is handled gracefully.
func Test_server_crash()
let handle = s:start_server()