Exercism에서 Vim script 연습 문제를 테스트하는 방법을 알아봐요
이 트랙은 테스트 스위트를 실행하고 모범 사례를 지키기 위해 두 가지 도구를 사용해요:
$ vim exercise.vim
:source %
:Vader exercise.vader
경로는 다를 수 있어요.
위 단계를 간편하게 실행할 수 있는 단축 방법을 원한다면 vimrc에 다음을 추가해요:
function! s:exercism_tests()
if expand('%:e') == 'vim'
let testfile = printf('%s/%s.vader', expand('%:p:h'),
\ tr(expand('%:p:h:t'), '-', '_'))
if !filereadable(testfile)
echoerr 'File does not exist: '. testfile
return
endif
source %
execute 'Vader' testfile
else
let sourcefile = printf('%s/%s.vim', expand('%:p:h'),
\ tr(expand('%:p:h:t'), '-', '_'))
if !filereadable(sourcefile)
echoerr 'File does not exist: '. sourcefile
return
endif
execute 'source' sourcefile
Vader
endif
endfunction
autocmd BufRead *.{vader,vim}
\ command! -buffer Test call s:exercism_tests()
그런 다음 연습 문제 폴더에 있는 .vim 또는 .vader 파일을 아무거나 열고 :Test 명령을 실행해요.
$ vint .
Vim script 트랙에 대해 더 자세히 알고 싶다면 도움말 페이지를 참고해요.