Skip to content

Commit ffd597c

Browse files
Ram-ZSamir Benmendil
authored and
Samir Benmendil
committed
Attempt at fixing unit tests
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: #61
1 parent 77bea8c commit ffd597c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

t/clang_format_spec.vim

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ function! ClangFormat(line1, line2, ...) abort
4848
let opt .= "}'"
4949

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

0 commit comments

Comments
 (0)