diagnostics.test.vim 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. function! SetUp()
  2. let g:ycm_use_clangd = 1
  3. let g:ycm_confirm_extra_conf = 0
  4. let g:ycm_auto_trigger = 1
  5. let g:ycm_keep_logfiles = 1
  6. let g:ycm_log_level = 'DEBUG'
  7. let g:ycm_always_populate_location_list = 1
  8. call youcompleteme#test#setup#SetUp()
  9. endfunction
  10. function! TearDown()
  11. call youcompleteme#test#setup#CleanUp()
  12. endfunction
  13. function! Test_Changing_Filetype_Refreshes_Diagnostics()
  14. call youcompleteme#test#setup#OpenFile(
  15. \ '/test/testdata/diagnostics/foo.xml',
  16. \ { 'native_ft': 0 } )
  17. call assert_equal( 'xml', &ft )
  18. call assert_true( pyxeval( 'ycm_state._buffers[' . bufnr( '%' ) . ']._async_diags' ) )
  19. call assert_equal( [], sign_getplaced() )
  20. setf typescript
  21. call assert_equal( 'typescript', &ft )
  22. call assert_false( pyxeval( 'ycm_state._buffers[' . bufnr( '%' ) . ']._async_diags' ) )
  23. " Diagnostics are async, so wait for the assert to return 0 for a while.
  24. call WaitForAssert( {-> assert_equal( 1, len( sign_getplaced() ) ) } )
  25. call assert_equal( 1, len( sign_getplaced()[ 0 ][ 'signs' ] ) )
  26. call assert_equal( 'YcmError', sign_getplaced()[ 0 ][ 'signs' ][ 0 ][ 'name' ] )
  27. call assert_false( empty( getloclist( 0 ) ) )
  28. %bwipeout!
  29. endfunction
  30. function! Test_MessagePoll_After_LocationList()
  31. call youcompleteme#test#setup#OpenFile( '/test/testdata/diagnostics/foo.cpp', {} )
  32. setf cpp
  33. call assert_equal( 'cpp', &ft )
  34. call WaitForAssert( {-> assert_equal( 1, len( sign_getplaced() ) ) } )
  35. call setline( 1, '' )
  36. doautocmd TextChanged
  37. call WaitForAssert( {-> assert_true( empty( sign_getplaced() ) ) }, 10000 )
  38. call assert_true( empty( getloclist( 0 ) ) )
  39. %bwipeout!
  40. endfunction