Skip to content

Commit 7dd4850

Browse files
committed
patch 8.0.0489: clipboard and "* register is not tested
Problem: Clipboard and "* register is not tested. Solution: Add a test for Mac and X11. (Kazunobu Kuriyama)
1 parent b4c5572 commit 7dd4850

5 files changed

Lines changed: 144 additions & 0 deletions

File tree

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,6 +2185,7 @@ test_arglist \
21852185
test_pyx2 \
21862186
test_pyx3 \
21872187
test_quickfix \
2188+
test_quotestar \
21882189
test_recover \
21892190
test_regexp_latin \
21902191
test_regexp_utf8 \

src/testdir/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ NEW_TESTS = test_arabic.res \
194194
test_pyx2.res \
195195
test_pyx3.res \
196196
test_quickfix.res \
197+
test_quotestar.res \
197198
test_retab.res \
198199
test_ruby.res \
199200
test_search.res \

src/testdir/runtest.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ let s:flaky = [
228228
\ 'Test_pipe_through_sort_all()',
229229
\ 'Test_pipe_through_sort_some()',
230230
\ 'Test_quoteplus()',
231+
\ 'Test_quotestar()',
231232
\ 'Test_reltime()',
232233
\ ]
233234

src/testdir/test_quotestar.vim

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
" *-register (quotestar) tests
2+
3+
if !has('clipboard')
4+
finish
5+
endif
6+
7+
source shared.vim
8+
9+
let s:where = 0
10+
func Abort(id)
11+
call assert_report('Test timed out at ' . s:where)
12+
call FinishTesting()
13+
endfunc
14+
15+
func Do_test_quotestar_for_macunix()
16+
if empty(exepath('pbcopy')) || empty(exepath('pbpaste'))
17+
return 'Test requires pbcopy(1) and pbpaste(1)'
18+
endif
19+
20+
let @* = ''
21+
22+
" Test #1: Pasteboard to Vim
23+
let test_msg = "text from pasteboard to vim via quotestar"
24+
" Write a piece of text to the pasteboard.
25+
call system('/bin/echo -n "' . test_msg . '" | pbcopy')
26+
" See if the *-register is changed as expected.
27+
call assert_equal(test_msg, @*)
28+
29+
" Test #2: Vim to Pasteboard
30+
let test_msg = "text from vim to pasteboard via quotestar"
31+
" Write a piece of text to the *-register.
32+
let @* = test_msg
33+
" See if the pasteboard is changed as expected.
34+
call assert_equal(test_msg, system('pbpaste'))
35+
36+
return ''
37+
endfunc
38+
39+
func Do_test_quotestar_for_x11()
40+
if !has('clientserver') || !has('job')
41+
return 'Test requires the client-server and job features'
42+
endif
43+
44+
let cmd = GetVimCommand()
45+
if cmd == ''
46+
return 'GetVimCommand() failed'
47+
endif
48+
49+
" Some of these commands may hang when failing.
50+
call timer_start(10000, 'Abort')
51+
52+
let s:where = 1
53+
let name = 'XVIMCLIPBOARD'
54+
let cmd .= ' --servername ' . name
55+
let g:job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'})
56+
call WaitFor('job_status(g:job) == "run"')
57+
if job_status(g:job) != 'run'
58+
call assert_report('Cannot run the Vim server')
59+
return ''
60+
endif
61+
let s:where = 2
62+
63+
" Takes a short while for the server to be active.
64+
call WaitFor('serverlist() =~ "' . name . '"')
65+
call assert_match(name, serverlist())
66+
let s:where = 3
67+
68+
" Clear the *-register of this vim instance.
69+
let @* = ''
70+
71+
" Try to change the *-register of the server.
72+
call remote_foreground(name)
73+
let s:where = 4
74+
call remote_send(name, ":let @* = 'yes'\<CR>")
75+
let s:where = 5
76+
call WaitFor('remote_expr("' . name . '", "@*") == "yes"')
77+
let s:where = 6
78+
call assert_equal('yes', remote_expr(name, "@*"))
79+
let s:where = 7
80+
81+
" Check that the *-register of this vim instance is changed as expected.
82+
call assert_equal('yes', @*)
83+
84+
if has('unix') && has('gui') && !has('gui_running')
85+
let @* = ''
86+
87+
" Running in a terminal and the GUI is avaiable: Tell the server to open
88+
" the GUI and check that the remote command still works.
89+
" Need to wait for the GUI to start up, otherwise the send hangs in trying
90+
" to send to the terminal window.
91+
if has('gui_athena') || has('gui_motif')
92+
" For those GUIs, ignore the 'failed to create input context' error.
93+
call remote_send(name, ":call test_ignore_error('E285') | gui -f\<CR>")
94+
else
95+
call remote_send(name, ":gui -f\<CR>")
96+
endif
97+
let s:where = 8
98+
sleep 500m
99+
call remote_send(name, ":let @* = 'maybe'\<CR>")
100+
let s:where = 9
101+
call WaitFor('remote_expr("' . name . '", "@*") == "maybe"')
102+
let s:where = 10
103+
call assert_equal('maybe', remote_expr(name, "@*"))
104+
let s:where = 11
105+
106+
call assert_equal('maybe', @*)
107+
endif
108+
109+
call remote_send(name, ":qa!\<CR>")
110+
let s:where = 12
111+
call WaitFor('job_status(g:job) == "dead"')
112+
let s:where = 13
113+
if job_status(g:job) != 'dead'
114+
call assert_report('Server did not exit')
115+
call job_stop(g:job, 'kill')
116+
endif
117+
118+
return ''
119+
endfunc
120+
121+
func Test_quotestar()
122+
let skipped = ''
123+
124+
let quotestar_saved = @*
125+
126+
if has('macunix')
127+
let skipped = Do_test_quotestar_for_macunix()
128+
elseif !empty("$DISPLAY")
129+
let skipped = Do_test_quotestar_for_x11()
130+
else
131+
let skipped = "Test is not implemented yet for this platform."
132+
endif
133+
134+
let @* = quotestar_saved
135+
136+
if !empty(skipped)
137+
throw skipped
138+
endif
139+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
489,
767769
/**/
768770
488,
769771
/**/

0 commit comments

Comments
 (0)