Skip to content

Commit 233d54d

Browse files
committed
Fix Vim tests
Broken by ycm-core/ycmd#1720 - Add diagnostic type to output Inexplicable syntax errors Missing semantic_highlighting groups lead to unexpected output Improve diagnostic test failure messages - print the popup positions
1 parent 39a9974 commit 233d54d

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

python/ycm/semantic_highlighting.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
'regexp': 'String',
5252
'operator': 'Operator',
5353
'unknown': 'Normal',
54+
55+
# These are not part of the spec, but are used by clangd
56+
'bracket': 'Normal',
57+
# These are not part of the spec, but are used by jdt.ls
58+
'annotation': 'Macro',
5459
}
5560
REPORTED_MISSING_TYPES = set()
5661

test/diagnostics.test.vim

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function! Test_Disable_Diagnostics_Update_In_insert_Mode()
9090
call WaitForAssert( {-> assert_true( len( sign_getplaced(
9191
\ '%',
9292
\ { 'group': 'ycm_signs' } )[ 0 ][ 'signs' ] ) ) } )
93-
call FeedAndCheckAgain( "A\<CR>", funcref( 'CheckNoPropsAfterNewLine' )
93+
call FeedAndCheckAgain( "A\<CR>", funcref( 'CheckNoPropsAfterNewLine' ) )
9494
endfunction
9595

9696
function! CheckNoPropsAfterNewLine( id ) closure
@@ -103,7 +103,7 @@ function! Test_Disable_Diagnostics_Update_In_insert_Mode()
103103
\ 1, { 'end_lnum': -1,
104104
\ 'types': [ 'YcmVirtDiagWarning',
105105
\ 'YcmVirtDiagError',
106-
\ 'YcmVirtDiagPadding' ] } ) ) ) )
106+
\ 'YcmVirtDiagPadding' ] } ) ) ) } )
107107
endfunction
108108

109109
call FeedAndCheckMain( 'imain(',
@@ -121,14 +121,14 @@ function! Test_Changing_Filetype_Refreshes_Diagnostics()
121121
\ '/test/testdata/diagnostics/foo.xml',
122122
\ { 'native_ft': 0 } )
123123

124-
call assert_equal( 'xml', &ft )
124+
call assert_equal( 'xml', &filetype )
125125
call assert_false(
126126
\ pyxeval( 'ycm_state._buffers[' . bufnr( '%' ) . ']._async_diags' ) )
127127
call assert_true( empty( sign_getplaced(
128128
\ '%',
129129
\ { 'group': 'ycm_signs' } )[ 0 ][ 'signs' ] ) )
130130
setf typescript
131-
call assert_equal( 'typescript', &ft )
131+
call assert_equal( 'typescript', &filetype )
132132
call assert_false(
133133
\ pyxeval( 'ycm_state._buffers[' . bufnr( '%' ) . ']._async_diags' ) )
134134
" Diagnostics are async, so wait for the assert to return 0 for a while.
@@ -151,7 +151,7 @@ function! Test_MessagePoll_After_LocationList()
151151
\ '/test/testdata/diagnostics/foo.cpp', {} )
152152

153153
setf cpp
154-
call assert_equal( 'cpp', &ft )
154+
call assert_equal( 'cpp', &filetype )
155155
call WaitForAssert( {-> assert_equal( 2, len( sign_getplaced(
156156
\ '%',
157157
\ { 'group': 'ycm_signs' } )[ 0 ][ 'signs' ] ) ) } )
@@ -251,7 +251,7 @@ function! Test_ShowDetailedDiagnostic_CmdLine()
251251

252252
call assert_equal(
253253
\ "Format specifies type 'char *' but the argument has type 'int' "
254-
\ . '(fix available)',
254+
\ . '(fix available) [-Wformat]',
255255
\ trim( output ) )
256256

257257
%bwipe!
@@ -264,8 +264,11 @@ function! Test_ShowDetailedDiagnostic_PopupAtCursor()
264264
call cursor( [ 3, 1 ] )
265265
YcmShowDetailedDiagnostic popup
266266

267-
let id = popup_locate( 4, 1 )
268-
call assert_notequal( 0, id, "Couldn't find popup!" )
267+
let id = popup_locate( 4, 16 )
268+
call assert_notequal(
269+
\ 0,
270+
\ id,
271+
\ "Couldn't find popup! " .. youcompleteme#test#popup#DumpPopups() )
269272

270273
if exists( '*popup_list' )
271274
let popups = popup_list()
@@ -274,13 +277,13 @@ function! Test_ShowDetailedDiagnostic_PopupAtCursor()
274277

275278
call youcompleteme#test#popup#CheckPopupPosition( id, {
276279
\ 'visible': 1,
277-
\ 'col': 1,
280+
\ 'col': 16,
278281
\ 'line': 4,
279282
\ } )
280283
call assert_equal(
281284
\ [
282285
\ "Format specifies type 'char *' but the argument has type 'int' "
283-
\ . '(fix available)',
286+
\ . '(fix available) [-Wformat]',
284287
\ ],
285288
\ getbufline( winbufnr(id), 1, '$' ) )
286289

@@ -315,8 +318,11 @@ function! Test_ShowDetailedDiagnostic_Popup_WithCharacters()
315318
call cursor( [ 4, 1 ] )
316319
YcmShowDetailedDiagnostic popup
317320

318-
let id = popup_locate( 5, 1 )
319-
call assert_notequal( 0, id, "Couldn't find popup!" )
321+
let id = popup_locate( 5, 7 )
322+
call assert_notequal(
323+
\ 0,
324+
\ id,
325+
\ "Couldn't find popup! " .. youcompleteme#test#popup#DumpPopups() )
320326

321327
if exists( '*popup_list' )
322328
let popups = popup_list()
@@ -325,7 +331,7 @@ function! Test_ShowDetailedDiagnostic_Popup_WithCharacters()
325331

326332
call youcompleteme#test#popup#CheckPopupPosition( id, {
327333
\ 'visible': 1,
328-
\ 'col': 1,
334+
\ 'col': 7,
329335
\ 'line': 5,
330336
\ } )
331337
call assert_match(

test/lib/autoload/youcompleteme/test/popup.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,21 @@ function! youcompleteme#test#popup#ScreenPos( winid, row, col )
4040
let [ w_row, w_col ] = win_screenpos( a:winid )
4141
return { 'row': w_row + a:row, 'col': w_col + a:col }
4242
endfunction
43+
44+
45+
function! youcompleteme#test#popup#DumpPopups() abort
46+
if !exists( 'popup_list' )
47+
# Old vim..
48+
return ''
49+
endif
50+
51+
let output = 'Popups:'
52+
for winid in popup_list()
53+
let output .= ' ['
54+
\ . string( winid )
55+
\ . '@'
56+
\ . string( popup_getpos( winid ) )
57+
\ . ']'
58+
endfor
59+
return output
60+
endfunction

0 commit comments

Comments
 (0)