2017-09-10 23:47:27 +00:00
|
|
|
Before:
|
|
|
|
function! CheckPath(path) abort
|
2017-12-19 18:23:09 +00:00
|
|
|
return ale#path#IsBufferPath(bufnr(''), ale#path#Simplify(a:path))
|
2017-09-10 23:47:27 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
After:
|
|
|
|
delfunction CheckPath
|
|
|
|
|
2019-06-05 13:16:43 +00:00
|
|
|
Execute(ale#path#Simplify should adjust paths correctly):
|
|
|
|
if has('unix')
|
|
|
|
" Multiple slashes should be removed correctly.
|
|
|
|
AssertEqual '/foo/bar/baz', ale#path#Simplify('////foo///bar///baz')
|
|
|
|
" Back slashes should be converted to forward slashes.
|
|
|
|
" This means some valid filenames are adjusted incorrectly, but in practice
|
|
|
|
" no filenames for code should contain back slashes, and adjusting slashes
|
|
|
|
" like this makes ALE work in MSYS.
|
|
|
|
AssertEqual 'foo/bar/baz', ale#path#Simplify('foo\bar\baz')
|
|
|
|
else
|
|
|
|
" Multiple slashes should be removed correctly.
|
|
|
|
AssertEqual '\foo\bar\baz', ale#path#Simplify('\\\foo\bar\baz')
|
|
|
|
" Forward slashes should be replaced with back slashes.
|
|
|
|
AssertEqual 'foo\bar\baz', ale#path#Simplify('foo/bar/baz')
|
|
|
|
endif
|
|
|
|
|
2017-04-29 17:03:08 +00:00
|
|
|
Execute(ale#path#IsBufferPath should match simple relative paths):
|
2017-06-25 12:56:51 +00:00
|
|
|
call ale#test#SetFilename('app/foo.txt')
|
|
|
|
|
2017-09-10 23:47:27 +00:00
|
|
|
Assert CheckPath('app/foo.txt'), 'No match for foo.txt'
|
|
|
|
Assert !CheckPath('app/bar.txt'), 'Bad match for bar.txt'
|
2017-06-25 12:56:51 +00:00
|
|
|
|
|
|
|
Execute(ale#path#IsBufferPath should match relative paths with dots):
|
|
|
|
call ale#test#SetFilename('app/foo.txt')
|
2017-04-29 17:03:08 +00:00
|
|
|
|
2017-09-10 23:47:27 +00:00
|
|
|
" Skip these checks on Windows.
|
|
|
|
if !has('win32')
|
|
|
|
Assert CheckPath('../../app/foo.txt'), 'No match for ../../app/foo.txt'
|
|
|
|
endif
|
2017-04-29 17:03:08 +00:00
|
|
|
|
|
|
|
Execute(ale#path#IsBufferPath should match absolute paths):
|
|
|
|
silent file! foo.txt
|
|
|
|
|
2017-09-10 23:47:27 +00:00
|
|
|
Assert CheckPath(getcwd() . '/foo.txt'), 'No match for foo.txt'
|
|
|
|
Assert !CheckPath(getcwd() . '/bar.txt'), 'Bad match for bar.txt'
|
2017-04-29 17:03:08 +00:00
|
|
|
|
2017-06-06 19:08:19 +00:00
|
|
|
Execute(ale#path#IsBufferPath should match paths beginning with ./):
|
|
|
|
silent file! foo.txt
|
|
|
|
|
2017-09-10 23:47:27 +00:00
|
|
|
if !has('win32')
|
|
|
|
Assert ale#path#IsBufferPath(bufnr(''), './foo.txt'), 'No match for ./foo.txt'
|
|
|
|
endif
|
2017-06-06 19:08:19 +00:00
|
|
|
|
|
|
|
Execute(ale#path#IsBufferPath should match if our path ends with the test path):
|
|
|
|
silent file! foo/bar/baz.txt
|
|
|
|
|
2017-09-10 23:47:27 +00:00
|
|
|
Assert CheckPath('bar/baz.txt'), 'No match for bar/baz.txt'
|
2017-06-06 19:08:19 +00:00
|
|
|
|
|
|
|
Execute(ale#path#IsBufferPath should match paths with redundant slashes):
|
2017-04-29 17:03:08 +00:00
|
|
|
silent file! foo.txt
|
|
|
|
|
2017-09-10 23:47:27 +00:00
|
|
|
Assert CheckPath(getcwd() . '////foo.txt'), 'No match for foo.txt'
|
2017-06-22 11:37:08 +00:00
|
|
|
|
|
|
|
Execute(ale#path#IsBufferPath should accept various names for stdin):
|
|
|
|
Assert ale#path#IsBufferPath(bufnr(''), '-')
|
|
|
|
Assert ale#path#IsBufferPath(bufnr(''), 'stdin')
|
|
|
|
Assert ale#path#IsBufferPath(bufnr(''), '<stdin>')
|
|
|
|
Assert ale#path#IsBufferPath(bufnr(''), '<somethingelse>')
|
2017-06-25 12:56:51 +00:00
|
|
|
|
|
|
|
Execute(ale#path#IsBufferPath should match files in /tmp):
|
|
|
|
call ale#test#SetFilename('app/test.ts')
|
|
|
|
|
2017-09-13 23:11:17 +00:00
|
|
|
Assert ale#path#IsBufferPath(bufnr(''), tempname() . '/test.ts')
|
2019-06-05 13:16:43 +00:00
|
|
|
|
|
|
|
Execute(ale#path#IsBufferPath should match Windows paths on Unix):
|
|
|
|
" This test should pass Unix.
|
|
|
|
"
|
|
|
|
" Back slashes in paths should be replaced with forward slashes, even though
|
|
|
|
" back slashes are valid in filenames on Unix.
|
|
|
|
if has('unix')
|
|
|
|
call ale#test#SetFilename('app/foo/test.ts')
|
|
|
|
|
|
|
|
Assert ale#path#IsBufferPath(bufnr(''), 'foo\test.ts')
|
|
|
|
endif
|