Fix #1210 - Fix a Windows path issue which broke TSLint
This commit is contained in:
parent
31241e9ed8
commit
fdaac9bd78
7 changed files with 106 additions and 83 deletions
|
@ -12,33 +12,33 @@ Execute(The javac handler should handle cannot find symbol errors):
|
|||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'filename': '/tmp/vLPr4Q5/33/foo.java',
|
||||
\ 'filename': ale#path#Simplify('/tmp/vLPr4Q5/33/foo.java'),
|
||||
\ 'lnum': 1,
|
||||
\ 'text': 'error: some error',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'filename': '/tmp/vLPr4Q5/33/foo.java',
|
||||
\ 'filename': ale#path#Simplify('/tmp/vLPr4Q5/33/foo.java'),
|
||||
\ 'lnum': 2,
|
||||
\ 'col': 5,
|
||||
\ 'text': 'error: cannot find symbol: BadName',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'filename': '/tmp/vLPr4Q5/33/foo.java',
|
||||
\ 'filename': ale#path#Simplify('/tmp/vLPr4Q5/33/foo.java'),
|
||||
\ 'lnum': 34,
|
||||
\ 'col': 5,
|
||||
\ 'text': 'error: cannot find symbol: BadName2',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'filename': '/tmp/vLPr4Q5/33/foo.java',
|
||||
\ 'filename': ale#path#Simplify('/tmp/vLPr4Q5/33/foo.java'),
|
||||
\ 'lnum': 37,
|
||||
\ 'text': 'warning: some warning',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'filename': '/tmp/vLPr4Q5/33/foo.java',
|
||||
\ 'filename': ale#path#Simplify('/tmp/vLPr4Q5/33/foo.java'),
|
||||
\ 'lnum': 42,
|
||||
\ 'col': 11,
|
||||
\ 'text': 'error: cannot find symbol: bar()',
|
||||
|
|
|
@ -287,9 +287,9 @@ Execute(The tslint handler should not report no-implicit-dependencies errors):
|
|||
Execute(The tslint handler should set filename keys for temporary files):
|
||||
" The temporay filename below is hacked into being a relative path so we can
|
||||
" test that we resolve the temporary filename first.
|
||||
let b:relative_to_root = substitute(expand('%:p'), '\v[^/\\]*([/\\])[^/\\]*', has('win32') ? '..\' : '../', 'g')
|
||||
let b:relative_to_root = substitute(expand('%:p'), '\v[^/\\]*([/\\])[^/\\]*', '../', 'g')
|
||||
let b:tempname_suffix = substitute(tempname(), '^\v([A-Z]:)?[/\\]', '', '')
|
||||
let b:relative_tempname = b:relative_to_root . b:tempname_suffix
|
||||
let b:relative_tempname = substitute(b:relative_to_root . b:tempname_suffix, '\\', '/', 'g')
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
|
|
|
@ -40,7 +40,7 @@ Execute(The C GCC handler should include 'include' directories for projects with
|
|||
\ ale#Escape('gcc')
|
||||
\ . ' -S -x c -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
|
||||
\ . ' -'
|
||||
\ , ale_linters#c#gcc#GetCommand(bufnr(''))
|
||||
|
||||
|
@ -53,7 +53,7 @@ Execute(The C GCC handler should include 'include' directories for projects with
|
|||
\ ale#Escape('gcc')
|
||||
\ . ' -S -x c -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/include')) . ' '
|
||||
\ . ' -'
|
||||
\ , ale_linters#c#gcc#GetCommand(bufnr(''))
|
||||
|
||||
|
@ -92,7 +92,7 @@ Execute(The C Clang handler should include 'include' directories for projects wi
|
|||
\ ale#Escape('clang')
|
||||
\ . ' -S -x c -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
|
||||
\ . ' -'
|
||||
\ , ale_linters#c#clang#GetCommand(bufnr(''))
|
||||
|
||||
|
@ -144,7 +144,7 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi
|
|||
\ ale#Escape('gcc')
|
||||
\ . ' -S -x c++ -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
|
||||
\ . ' -'
|
||||
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
|
||||
|
||||
|
@ -157,7 +157,7 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi
|
|||
\ ale#Escape('gcc')
|
||||
\ . ' -S -x c++ -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/include')) . ' '
|
||||
\ . ' -'
|
||||
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
|
||||
|
||||
|
@ -196,7 +196,7 @@ Execute(The C++ Clang handler should include 'include' directories for projects
|
|||
\ ale#Escape('clang++')
|
||||
\ . ' -S -x c++ -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
|
||||
\ . ' -'
|
||||
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
|
||||
|
||||
|
@ -209,7 +209,7 @@ Execute(The C++ Clang handler should include 'include' directories for projects
|
|||
\ ale#Escape('clang++')
|
||||
\ . ' -S -x c++ -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/include')) . ' '
|
||||
\ . ' -'
|
||||
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
|
||||
|
||||
|
@ -256,7 +256,7 @@ Execute(The C++ Clang handler shoud use the include directory based on the .git
|
|||
\ ale#Escape('clang++')
|
||||
\ . ' -S -x c++ -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/git_and_nested_makefiles/src')) . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/git_and_nested_makefiles') . '/include') . ' '
|
||||
\ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/git_and_nested_makefiles/include')) . ' '
|
||||
\ . ' -'
|
||||
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
|
||||
|
||||
|
@ -268,7 +268,7 @@ Execute(The C++ ClangTidy handler should include json folders for projects with
|
|||
AssertEqual
|
||||
\ ale#Escape('clang-tidy')
|
||||
\ . ' -checks=' . ale#Escape('*') . ' %s '
|
||||
\ . '-p ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/json_project') . '/build')
|
||||
\ . '-p ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/json_project/build'))
|
||||
\ , ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
|
||||
|
||||
Execute(Move .git/HEAD back):
|
||||
|
|
|
@ -1,15 +1,29 @@
|
|||
Execute(Relative paths should be resolved correctly):
|
||||
AssertEqual
|
||||
\ '/foo/bar/baz/whatever.txt',
|
||||
\ has('win32') ? '\foo\bar\baz\whatever.txt' : '/foo/bar/baz/whatever.txt',
|
||||
\ ale#path#GetAbsPath('/foo/bar/xyz', '../baz/whatever.txt')
|
||||
AssertEqual
|
||||
\ has('win32') ? '/foo/bar/xyz\whatever.txt' : '/foo/bar/xyz/whatever.txt',
|
||||
\ has('win32') ? '\foo\bar\xyz\whatever.txt' : '/foo/bar/xyz/whatever.txt',
|
||||
\ ale#path#GetAbsPath('/foo/bar/xyz', './whatever.txt')
|
||||
AssertEqual
|
||||
\ has('win32') ? '/foo/bar/xyz\whatever.txt' : '/foo/bar/xyz/whatever.txt',
|
||||
\ has('win32') ? '\foo\bar\xyz\whatever.txt' : '/foo/bar/xyz/whatever.txt',
|
||||
\ ale#path#GetAbsPath('/foo/bar/xyz', 'whatever.txt')
|
||||
|
||||
if has('win32')
|
||||
AssertEqual
|
||||
\ 'C:\foo\bar\baz\whatever.txt',
|
||||
\ ale#path#GetAbsPath('C:\foo\bar\baz\xyz', '../whatever.txt')
|
||||
endif
|
||||
|
||||
Execute(Absolute paths should be resolved correctly):
|
||||
AssertEqual
|
||||
\ '/ding/dong',
|
||||
\ has('win32') ? '\ding\dong' : '/ding/dong',
|
||||
\ ale#path#GetAbsPath('/foo/bar/xyz', '/ding/dong')
|
||||
|
||||
AssertEqual
|
||||
\ has('win32') ? '\ding\dong' : '/ding/dong',
|
||||
\ ale#path#GetAbsPath('/foo/bar/xyz', '//ding/dong')
|
||||
|
||||
if has('win32')
|
||||
AssertEqual '\ding', ale#path#GetAbsPath('/foo/bar/xyz', '\\ding')
|
||||
endif
|
||||
|
|
|
@ -1,52 +1,48 @@
|
|||
After:
|
||||
let g:ale_has_override = {}
|
||||
Execute(ale#path#Upwards should return the correct path components):
|
||||
if has('unix')
|
||||
" Absolute paths should include / on the end.
|
||||
AssertEqual
|
||||
\ ['/foo/bar/baz', '/foo/bar', '/foo', '/'],
|
||||
\ ale#path#Upwards('/foo/bar/baz')
|
||||
AssertEqual
|
||||
\ ['/foo/bar/baz', '/foo/bar', '/foo', '/'],
|
||||
\ ale#path#Upwards('/foo/bar/baz///')
|
||||
" Relative paths do not.
|
||||
AssertEqual
|
||||
\ ['foo/bar/baz', 'foo/bar', 'foo'],
|
||||
\ ale#path#Upwards('foo/bar/baz')
|
||||
AssertEqual
|
||||
\ ['foo2/bar', 'foo2'],
|
||||
\ ale#path#Upwards('foo//..////foo2////bar')
|
||||
" Expect an empty List for empty strings.
|
||||
AssertEqual [], ale#path#Upwards('')
|
||||
endif
|
||||
|
||||
Execute(ale#path#Upwards should return the correct path components for Unix):
|
||||
let g:ale_has_override = {'win32': 0}
|
||||
|
||||
" Absolute paths should include / on the end.
|
||||
AssertEqual
|
||||
\ ['/foo/bar/baz', '/foo/bar', '/foo', '/'],
|
||||
\ ale#path#Upwards('/foo/bar/baz')
|
||||
AssertEqual
|
||||
\ ['/foo/bar/baz', '/foo/bar', '/foo', '/'],
|
||||
\ ale#path#Upwards('/foo/bar/baz///')
|
||||
" Relative paths do not.
|
||||
AssertEqual
|
||||
\ ['foo/bar/baz', 'foo/bar', 'foo'],
|
||||
\ ale#path#Upwards('foo/bar/baz')
|
||||
AssertEqual
|
||||
\ ['foo2/bar', 'foo2'],
|
||||
\ ale#path#Upwards('foo//..////foo2////bar')
|
||||
" Expect an empty List for empty strings.
|
||||
AssertEqual [], ale#path#Upwards('')
|
||||
|
||||
Execute(ale#path#Upwards should return the correct path components for Windows):
|
||||
let g:ale_has_override = {'win32': 1}
|
||||
|
||||
AssertEqual
|
||||
\ ['C:\foo\bar\baz', 'C:\foo\bar', 'C:\foo', 'C:\'],
|
||||
\ ale#path#Upwards('C:\foo\bar\baz')
|
||||
AssertEqual
|
||||
\ ['C:\foo\bar\baz', 'C:\foo\bar', 'C:\foo', 'C:\'],
|
||||
\ ale#path#Upwards('C:\foo\bar\baz\\\')
|
||||
AssertEqual
|
||||
\ ['/foo\bar\baz', '/foo\bar', '/foo', '/'],
|
||||
\ ale#path#Upwards('/foo/bar/baz')
|
||||
AssertEqual
|
||||
\ ['foo\bar\baz', 'foo\bar', 'foo'],
|
||||
\ ale#path#Upwards('foo/bar/baz')
|
||||
AssertEqual
|
||||
\ ['foo\bar\baz', 'foo\bar', 'foo'],
|
||||
\ ale#path#Upwards('foo\bar\baz')
|
||||
" simplify() is used internally, and should sort out \ paths when actually
|
||||
" running Windows, which we can't test here.
|
||||
AssertEqual
|
||||
\ ['foo2\bar', 'foo2'],
|
||||
\ ale#path#Upwards('foo//..///foo2////bar')
|
||||
" Expect an empty List for empty strings.
|
||||
AssertEqual [], ale#path#Upwards('')
|
||||
" Paths starting with // return /
|
||||
AssertEqual
|
||||
\ ['/foo2\bar', '/foo2', '/'],
|
||||
\ ale#path#Upwards('//foo//..///foo2////bar')
|
||||
if has('win32')
|
||||
AssertEqual
|
||||
\ ['C:\foo\bar\baz', 'C:\foo\bar', 'C:\foo', 'C:\'],
|
||||
\ ale#path#Upwards('C:\foo\bar\baz')
|
||||
AssertEqual
|
||||
\ ['C:\foo\bar\baz', 'C:\foo\bar', 'C:\foo', 'C:\'],
|
||||
\ ale#path#Upwards('C:\foo\bar\baz\\\')
|
||||
AssertEqual
|
||||
\ ['/foo\bar\baz', '/foo\bar', '/foo', '/'],
|
||||
\ ale#path#Upwards('/foo/bar/baz')
|
||||
AssertEqual
|
||||
\ ['foo\bar\baz', 'foo\bar', 'foo'],
|
||||
\ ale#path#Upwards('foo/bar/baz')
|
||||
AssertEqual
|
||||
\ ['foo\bar\baz', 'foo\bar', 'foo'],
|
||||
\ ale#path#Upwards('foo\bar\baz')
|
||||
" simplify() is used internally, and should sort out \ paths when actually
|
||||
" running Windows, which we can't test here.
|
||||
AssertEqual
|
||||
\ ['foo2\bar', 'foo2'],
|
||||
\ ale#path#Upwards('foo//..///foo2////bar')
|
||||
" Expect an empty List for empty strings.
|
||||
AssertEqual [], ale#path#Upwards('')
|
||||
" Paths starting with // return /
|
||||
AssertEqual
|
||||
\ ['/foo2\bar', '/foo2', '/'],
|
||||
\ ale#path#Upwards('//foo//..///foo2////bar')
|
||||
endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue