Use YCM python style

This commit is contained in:
Ben Jackson 2020-02-08 18:09:13 +00:00
commit 8052484cc7
14 changed files with 82 additions and 49 deletions

View file

@ -275,7 +275,7 @@ function! Test_Insert_Code_Above_Breakpoint()
" CHeck that we break at the right point
call setpos( '.', [ 0, 1, 1 ] )
call vimspector#LaunchWithSettings( { "configuration": "run" } )
call vimspector#LaunchWithSettings( { 'configuration': 'run' } )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 26, 1 )
call vimspector#Reset()
call vimspector#test#setup#WaitForReset()

View file

@ -28,7 +28,7 @@ function! Test_Python_Simple()
call setpos( '.', [ 0, 1, 1 ] )
" Here we go. Start Debugging
call vimspector#LaunchWithSettings( { "configuration": "run" } )
call vimspector#LaunchWithSettings( { 'configuration': 'run' } )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 )
" Step

View file

@ -28,7 +28,7 @@ endif
func RunVimInTerminal(arguments, options)
" If Vim doesn't exit a swap file remains, causing other tests to fail.
" Remove it here.
call delete(".swp")
call delete('.swp')
if exists('$COLORFGBG')
" Clear $COLORFGBG to avoid 'background' being set to "dark", which will
@ -61,7 +61,7 @@ func RunVimInTerminal(arguments, options)
\ 'term_rows': rows,
\ 'term_cols': cols,
\ })
if &termwinsize == ''
if &termwinsize ==# ''
" in the GUI we may end up with a different size, try to set it.
if term_getsize(buf) != [rows, cols]
call term_setsize(buf, rows, cols)
@ -80,7 +80,7 @@ func RunVimInTerminal(arguments, options)
call WaitFor({-> len(term_getline(buf, rows)) >= cols - 1 || len(term_getline(buf, rows - statusoff)) >= cols - 1})
catch /timed out after/
let lines = map(range(1, rows), {key, val -> term_getline(buf, val)})
call assert_report('RunVimInTerminal() failed, screen contents: ' . join(lines, "<NL>"))
call assert_report('RunVimInTerminal() failed, screen contents: ' . join(lines, '<NL>'))
endtry
return buf
@ -88,7 +88,7 @@ endfunc
" Stop a Vim running in terminal buffer "buf".
func StopVimInTerminal(buf)
call assert_equal("running", term_getstatus(a:buf))
call assert_equal('running', term_getstatus(a:buf))
" CTRL-O : works both in Normal mode and Insert mode to start a command line.
" In Command-line it's inserted, the CTRL-U removes it again.

View file

@ -37,8 +37,8 @@ endfunc
func RunCommand(cmd)
let job = 0
if has('job')
let job = job_start(a:cmd, {"stoponexit": "hup"})
call job_setoptions(job, {"stoponexit": "kill"})
let job = job_start(a:cmd, {'stoponexit': 'hup'})
call job_setoptions(job, {'stoponexit': 'kill'})
elseif has('win32')
exe 'silent !start cmd /c start "test_channel" ' . a:cmd
else
@ -53,7 +53,7 @@ func GetPort()
" with 200 it sometimes failed
for i in range(400)
try
let l = readfile("Xportnr")
let l = readfile('Xportnr')
catch
endtry
if len(l) >= 1
@ -61,7 +61,7 @@ func GetPort()
endif
sleep 10m
endfor
call delete("Xportnr")
call delete('Xportnr')
if len(l) == 0
" Can't make the connection, give up.
@ -74,14 +74,14 @@ endfunc
" Always kills the server before returning.
func RunServer(cmd, testfunc, args)
" The Python program writes the port number in Xportnr.
call delete("Xportnr")
call delete('Xportnr')
if len(a:args) == 1
let arg = ' ' . a:args[0]
else
let arg = ''
endif
let pycmd = s:python . " " . a:cmd . arg
let pycmd = s:python . ' ' . a:cmd . arg
try
let g:currentJob = RunCommand(pycmd)
@ -108,10 +108,10 @@ func s:kill_server(cmd)
unlet g:currentJob
endif
elseif has('win32')
let cmd = substitute(a:cmd, ".py", '', '')
let cmd = substitute(a:cmd, '.py', '', '')
call system('taskkill /IM ' . s:python . ' /T /F /FI "WINDOWTITLE eq ' . cmd . '"')
else
call system("pkill -f " . a:cmd)
call system('pkill -f ' . a:cmd)
endif
endfunc
@ -253,7 +253,7 @@ func GetVimCommand(...)
" "vimcmd" file, including environment options.
" Other Makefiles just write the executable in the first line, so fall back
" to that if there is no second line or it is empty.
if len(lines) > 1 && lines[1] != ''
if len(lines) > 1 && lines[1] !=# ''
let cmd = lines[1]
else
let cmd = lines[0]
@ -267,7 +267,7 @@ func GetVimCommand(...)
let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '')
" If using valgrind, make sure every run uses a different log file.
if cmd =~ 'valgrind.*--log-file='
if cmd =~# 'valgrind.*--log-file='
let cmd = substitute(cmd, '--log-file=\(^\s*\)', '--log-file=\1.' . g:valgrind_cnt, '')
let g:valgrind_cnt += 1
endif
@ -308,7 +308,7 @@ func RunVimPiped(before, after, arguments, pipecmd)
let args .= ' -S Xafter.vim'
endif
exe "silent !" . a:pipecmd . cmd . args . ' ' . a:arguments
exe 'silent !' . a:pipecmd . cmd . args . ' ' . a:arguments
if len(a:before) > 0
call delete('Xbefore.vim')
@ -320,7 +320,7 @@ func RunVimPiped(before, after, arguments, pipecmd)
endfunc
func CanRunGui()
return has('gui') && ($DISPLAY != "" || has('gui_running'))
return has('gui') && ($DISPLAY !=# '' || has('gui_running'))
endfunc
func WorkingClipboard()
@ -328,7 +328,7 @@ func WorkingClipboard()
return 0
endif
if has('x11')
return $DISPLAY != ""
return $DISPLAY !=# ''
endif
return 1
endfunc

View file

@ -36,16 +36,18 @@
let s:single_test_timeout = 60000
" Restrict the runtimepath to the exact minimum needed for testing
set rtp=$PWD/lib,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after
set runtimepath=$PWD/lib,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after
if has('packages')
let &packpath = &rtp
let &packpath = &runtimepath
endif
call ch_logfile( 'debuglog', 'w' )
" For consistency run all tests with 'nocompatible' set.
" This also enables use of line continuation.
set nocp
" vint: -ProhibitSetNoCompatible
set nocompatible
" vint: +ProhibitSetNoCompatible
" Use utf-8 by default, instead of whatever the system default happens to be.
" Individual tests can overrule this at the top of the file.
@ -93,7 +95,7 @@ func RunTheTest(test)
" directory after executing the test.
let save_cwd = getcwd()
if exists("*SetUp_" . a:test)
if exists('*SetUp_' . a:test)
try
exe 'call SetUp_' . a:test
catch
@ -109,7 +111,7 @@ func RunTheTest(test)
endtry
endif
if exists("*SetUp")
if exists('*SetUp')
try
call SetUp()
catch
@ -136,9 +138,14 @@ func RunTheTest(test)
let test_filesafe = substitute( a:test, '[)(,:]', '_', 'g' )
let s:testid_filesafe = g:testpath . '_' . test_filesafe
au VimLeavePre * call EarlyExit(s:test)
augroup EarlyExit
au!
au VimLeavePre * call EarlyExit(s:test)
augroup END
exe 'call ' . a:test
au! VimLeavePre
au! EarlyExit
catch /^\cskipped/
call add(s:messages, ' Skipped')
call add(s:skipped,
@ -164,7 +171,7 @@ func RunTheTest(test)
" reset to avoid trouble with anything else.
set noinsertmode
if exists("*TearDown")
if exists('*TearDown')
try
call TearDown()
catch
@ -179,7 +186,7 @@ func RunTheTest(test)
endtry
endif
if exists("*TearDown_" . a:test)
if exists('*TearDown_' . a:test)
try
exe 'call TearDown_' . a:test
catch
@ -252,10 +259,9 @@ func FinishTesting()
if filereadable( 'test.log' )
let l = readfile( 'test.log' )
endif
call writefile( l->extend( [ '', 'From ' . g:testpath . ':' ] )
\ ->extend( s:errors ),
\ 'test.log',
\ 's' )
call extend( l, [ '', 'From ' . g:testpath . ':' ] )
call extend( l, s:errors )
call writefile( l, 'test.log', 's' )
endif
if s:done == 0
@ -280,10 +286,9 @@ func FinishTesting()
if filereadable( 'messages' )
let l = readfile( 'messages' )
endif
call writefile( l->extend( [ '', 'From ' . g:testpath . ':' ] )
\ ->extend( s:messages ),
\ 'messages',
\ 's' )
call extend( l, [ '', 'From ' . g:testpath . ':' ] )
call extend( l, s:messages )
call writefile( l, 'messages', 's' )
if s:fail > 0
cquit!

View file

@ -28,7 +28,7 @@ function! Test_Step_With_Different_Tabpage()
call assert_equal( 1, col( '.' ), 'Current column' )
" Switch to the other tab
normal gt
normal! gt
call assert_notequal( vimspector_tabnr, tabpagenr() )