SETUP

This track uses two tools to run the test suite and ensure best practices:

  1. vader.vim
  2. vint

Running tests

  1. Install vader.vim.
  2. Open your solution: $ vim exercise.vim
  3. Source the current file to make its global functions available to Vim: :source %
  4. Run the tests: :Vader exercise.vader

Paths may vary.

If you want a convenient shortcut to the above steps, put this in your vimrc:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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()

Afterwards open any .vim or .vader file from an exercise directory and run the :Test command.

Linting Vim files

  1. Install vint.
  2. Recursively lint all Vim files: $ vint .

For more detailed information about the Vim script track, please see the help page.


Help us explain this better! File a GitHub issue at https://github.com/exercism/vimscript/issues if you have suggestions, or submit a patch with improvements to the https://github.com/exercism/vimscript/blob/master/docs/TESTS.md file.