diff options
author | w0rp <devw0rp@gmail.com> | 2017-12-18 13:27:59 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-12-18 13:27:59 +0000 |
commit | fdaac9bd781baf85d04d6b3138a2b80cd7b3a25d (patch) | |
tree | c79dc88b5d4a33e273484e6568d674e23bb6a64b /test | |
parent | 31241e9ed89ddad6c015d0f9ca9bb8a4de80332e (diff) | |
download | ale-fdaac9bd781baf85d04d6b3138a2b80cd7b3a25d.zip |
Fix #1210 - Fix a Windows path issue which broke TSLint
Diffstat (limited to 'test')
-rw-r--r-- | test/handler/test_javac_handler.vader | 10 | ||||
-rw-r--r-- | test/handler/test_tslint_handler.vader | 4 | ||||
-rw-r--r-- | test/test_c_import_paths.vader | 18 | ||||
-rw-r--r-- | test/test_get_abspath.vader | 22 | ||||
-rw-r--r-- | test/test_path_upwards.vader | 98 |
5 files changed, 81 insertions, 71 deletions
diff --git a/test/handler/test_javac_handler.vader b/test/handler/test_javac_handler.vader index 3997b42c..6189e6e1 100644 --- a/test/handler/test_javac_handler.vader +++ b/test/handler/test_javac_handler.vader @@ -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()', diff --git a/test/handler/test_tslint_handler.vader b/test/handler/test_tslint_handler.vader index bbaef837..8d263efa 100644 --- a/test/handler/test_tslint_handler.vader +++ b/test/handler/test_tslint_handler.vader @@ -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 \ [ diff --git a/test/test_c_import_paths.vader b/test/test_c_import_paths.vader index af185eae..21e49a3a 100644 --- a/test/test_c_import_paths.vader +++ b/test/test_c_import_paths.vader @@ -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): diff --git a/test/test_get_abspath.vader b/test/test_get_abspath.vader index 5f813804..7e1b5930 100644 --- a/test/test_get_abspath.vader +++ b/test/test_get_abspath.vader @@ -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 diff --git a/test/test_path_upwards.vader b/test/test_path_upwards.vader index 8b81a109..cd461a28 100644 --- a/test/test_path_upwards.vader +++ b/test/test_path_upwards.vader @@ -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 |