All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 Save g:ale_filename_mappings
4 let g:ale_filename_mappings = {}
13 Execute(FixLocList should map filenames):
14 " Paths converted back into temporary filenames shouldn't be included.
15 let g:ale_filename_mappings = {
16 \ 'linter2': [['/xxx/', '/data/']],
18 \ ['/bar/', '/data/special/'],
19 \ ['/foo/', '/data/'],
21 \ ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h:h')) . '/',
34 \ ale#engine#FixLocList(
39 \ {'text': 'x', 'lnum': 1, 'filename': '/data/file.txt'},
40 \ {'text': 'x', 'lnum': 1, 'filename': '/x-tmp/file.txt'},
41 \ {'text': 'x', 'lnum': 1, 'filename': '/data/special/file.txt'},
44 \ 'get(v:val, ''filename'', v:null)',
48 Given foo (Some file with lines to count):
60 Execute(FixLocList should set all the default values correctly):
67 \ 'bufnr': bufnr('%'),
71 \ 'linter_name': 'foobar',
77 \ 'bufnr': bufnr('%'),
81 \ 'linter_name': 'foobar',
84 \ ale#engine#FixLocList(
88 \ [{'text': 'a', 'lnum': 2}, {'text': 'b', 'lnum': 2}],
91 Execute(FixLocList should use the values we supply):
102 \ 'linter_name': 'foobar',
105 \ ale#engine#FixLocList(
120 Execute(FixLocList should set items with lines beyond the end to the last line):
128 \ 'bufnr': bufnr('%'),
132 \ 'linter_name': 'foobar',
135 \ ale#engine#FixLocList(
139 \ [{'text': 'a', 'lnum': 11, 'end_lnum': 12}],
142 Execute(FixLocList should move line 0 to line 1):
149 \ 'bufnr': bufnr('%'),
153 \ 'linter_name': 'foobar',
156 \ ale#engine#FixLocList(
160 \ [{'text': 'a', 'lnum': 0}],
163 Execute(FixLocList should convert line and column numbers correctly):
164 " The numbers should be 10, not 8 as octals.
171 \ 'bufnr': bufnr('%'),
175 \ 'linter_name': 'foobar',
178 \ ale#engine#FixLocList(
182 \ [{'text': 'a', 'lnum': '010', 'col': '010'}],
185 Execute(FixLocList should pass on end_col values):
186 " The numbers should be 10, not 8 as octals.
194 \ 'bufnr': bufnr('%'),
198 \ 'linter_name': 'foobar',
205 \ 'bufnr': bufnr('%'),
209 \ 'linter_name': 'foobar',
212 \ ale#engine#FixLocList(
217 \ {'text': 'a', 'lnum': '010', 'col': '010', 'end_col': '012'},
218 \ {'text': 'a', 'lnum': '010', 'col': '011', 'end_col': 12},
222 Execute(FixLocList should pass on end_lnum values):
231 \ 'bufnr': bufnr('%'),
235 \ 'linter_name': 'foobar',
243 \ 'bufnr': bufnr('%'),
247 \ 'linter_name': 'foobar',
250 \ ale#engine#FixLocList(
255 \ {'text': 'a', 'lnum': '07', 'col': '010', 'end_col': '012', 'end_lnum': '010'},
256 \ {'text': 'a', 'lnum': '07', 'col': '011', 'end_col': 12, 'end_lnum': 10},
260 Execute(FixLocList should allow subtypes to be set):
267 \ 'bufnr': bufnr('%'),
270 \ 'sub_type': 'style',
272 \ 'linter_name': 'foobar',
275 \ ale#engine#FixLocList(
279 \ [{'text': 'a', 'lnum': 11, 'sub_type': 'style'}],
282 Execute(FixLocList should accept filenames):
283 let b:other_bufnr = bufnr('/foo/bar/baz', 1)
285 " Make sure we actually get another buffer number, or the test is invalid.
286 AssertNotEqual -1, b:other_bufnr
288 call ale#test#SetFilename('test.txt')
296 \ 'bufnr': bufnr('%'),
297 \ 'filename': expand('%:p'),
301 \ 'linter_name': 'foobar',
307 \ 'bufnr': bufnr('%'),
308 \ 'filename': expand('%:p'),
312 \ 'linter_name': 'foobar',
318 \ 'bufnr': b:other_bufnr,
319 \ 'filename': '/foo/bar/baz',
323 \ 'linter_name': 'foobar',
329 \ 'bufnr': b:other_bufnr,
330 \ 'filename': '/foo/bar/baz',
334 \ 'linter_name': 'foobar',
337 \ ale#engine#FixLocList(
342 \ {'text': 'a', 'lnum': 2, 'filename': expand('%:p')},
343 \ {'text': 'a', 'lnum': 3, 'filename': expand('%:p')},
344 \ {'text': 'a', 'lnum': 4, 'filename': '/foo/bar/baz'},
345 \ {'text': 'a', 'lnum': 5, 'filename': '/foo/bar/baz'},
349 Execute(FixLocList should interpret temporary filenames as being the current buffer):
350 let b:temp_name = tempname()
358 \ 'bufnr': bufnr(''),
362 \ 'linter_name': 'foobar',
368 \ 'bufnr': bufnr(''),
372 \ 'linter_name': 'foobar',
375 \ ale#engine#FixLocList(
380 \ {'text': 'a', 'lnum': 2, 'filename': b:temp_name},
381 \ {'text': 'a', 'lnum': 3, 'filename': substitute(b:temp_name, '\\', '/', 'g')},
385 Execute(The error code should be passed on):
392 \ 'bufnr': bufnr('%'),
396 \ 'linter_name': 'foobar',
397 \ 'code': 'some-code'
400 \ ale#engine#FixLocList(
404 \ [{'text': 'a', 'lnum': 11, 'code': 'some-code'}],
407 Execute(FixLocList should mark problems as coming from other sources if requested):
414 \ 'bufnr': bufnr('%'),
418 \ 'linter_name': 'foobar',
419 \ 'from_other_source': 1,
425 \ 'bufnr': bufnr('%'),
429 \ 'linter_name': 'foobar',
430 \ 'from_other_source': 1,
433 \ ale#engine#FixLocList(
437 \ [{'text': 'a', 'lnum': 2}, {'text': 'b', 'lnum': 2}],
440 Given(A file with Japanese multi-byte text):
443 Execute(character positions should be converted to byte positions):
446 \ {'lnum': 1, 'bufnr': bufnr(''), 'col': 0, 'linter_name': 'foobar', 'nr': -1, 'type': 'E', 'vcol': 0, 'text': 'a'},
447 \ {'lnum': 1, 'bufnr': bufnr(''), 'col': 1, 'linter_name': 'foobar', 'nr': -1, 'type': 'E', 'vcol': 0, 'text': 'a'},
448 \ {'lnum': 1, 'bufnr': bufnr(''), 'col': 4, 'linter_name': 'foobar', 'nr': -1, 'type': 'E', 'vcol': 0, 'text': 'a'},
449 \ {'lnum': 1, 'bufnr': bufnr(''), 'col': 7, 'linter_name': 'foobar', 'nr': -1, 'type': 'E', 'vcol': 0, 'text': 'a'},
450 \ {'lnum': 1, 'bufnr': bufnr(''), 'col': 7, 'end_col': 13, 'linter_name': 'foobar', 'nr': -1, 'type': 'E', 'vcol': 0, 'text': 'a'},
451 \ {'lnum': 1, 'bufnr': bufnr(''), 'col': 7, 'end_col': 13, 'end_lnum': 1, 'linter_name': 'foobar', 'nr': -1, 'type': 'E', 'vcol': 0, 'text': 'a'},
452 \ {'lnum': 1, 'bufnr': bufnr(''), 'col': 7, 'end_col': 17, 'end_lnum': 2, 'linter_name': 'foobar', 'nr': -1, 'type': 'E', 'vcol': 0, 'text': 'a'},
453 \ {'lnum': 2, 'bufnr': bufnr(''), 'col': 17, 'linter_name': 'foobar', 'nr': -1, 'type': 'E', 'vcol': 0, 'text': 'a'},
455 \ ale#engine#FixLocList(
460 \ {'text': 'a', 'lnum': 1, 'col': 0, 'vcol': 1},
461 \ {'text': 'a', 'lnum': 1, 'col': 1, 'vcol': 1},
462 \ {'text': 'a', 'lnum': 1, 'col': 2, 'vcol': 1},
463 \ {'text': 'a', 'lnum': 1, 'col': 3, 'vcol': 1},
464 \ {'text': 'a', 'lnum': 1, 'col': 3, 'end_col': 5, 'vcol': 1},
465 \ {'text': 'a', 'lnum': 1, 'col': 3, 'end_col': 5, 'end_lnum': 1, 'vcol': 1},
466 \ {'text': 'a', 'lnum': 1, 'col': 3, 'end_col': 7, 'end_lnum': 2, 'vcol': 1},
467 \ {'text': 'a', 'lnum': 2, 'col': 7, 'vcol': 1},