Skip to content

Commit

Permalink
Attempt at fixing unit tests
Browse files Browse the repository at this point in the history
This fixes some of the tests by limiting the output of the ClangFormat
helper function to between `line1` and `line2`. This is similar to what
`clang_format#format` now returns.

There are two problems left:
1. the number of lines returned by `clang_format#format` might not be
   equal to `line2 - line1`, i.e when it splits a line.
2. `clang_format#replace` now handles reidenting the lines correctly, so
   any tests that format a line that is indented will fail.

Ref: rhysd#61
  • Loading branch information
Ram-Z committed Oct 7, 2017
1 parent caac1df commit e520789
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions t/clang_format_spec.vim
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ function! ClangFormat(line1, line2, ...) abort
let opt .= "}'"

let cmd = printf('%s %s ./%st/%s --', g:clang_format#command, opt, s:root_dir, file)
let result = Chomp(system(cmd))
let result = systemlist(cmd)
if v:shell_error
throw "Error on system(): clang-format exited with non-zero.\nCommand: " . cmd . "\nOutput: " . result
endif
return Chomp(system(cmd))
let l = filter(result, { idx -> (idx + 1) >= a:line1 && (idx + 1) <= a:line2 })
return Chomp(join(l, "\n"))
endfunction
"}}}

Expand Down

0 comments on commit e520789

Please sign in to comment.