summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-06-25 13:56:51 +0100
committerw0rp <devw0rp@gmail.com>2017-06-25 13:56:51 +0100
commit4eaa990fe8f1de3c767c6281d413506356999302 (patch)
tree41c77ff86992bc597248dd50a21c70f4a71a3a6f /test
parent8da56413555377a3012250f4d984a143e97945ee (diff)
downloadale-4eaa990fe8f1de3c767c6281d413506356999302.zip
Fix #684 - Use the JSON format for tslint, for consistency betwen versions, and handling of end line and column numbers
Diffstat (limited to 'test')
-rw-r--r--test/handler/test_tslint_handler.vader110
-rw-r--r--test/test_path_equality.vader17
2 files changed, 98 insertions, 29 deletions
diff --git a/test/handler/test_tslint_handler.vader b/test/handler/test_tslint_handler.vader
index 92ed7059..cf6ea4e3 100644
--- a/test/handler/test_tslint_handler.vader
+++ b/test/handler/test_tslint_handler.vader
@@ -1,41 +1,99 @@
Before:
runtime ale_linters/typescript/tslint.vim
+ silent! cd /testplugin/test/handler
+ let g:dir = getcwd()
+
+After:
+ silent execute 'cd ' . fnameescape(g:dir)
+ unlet! g:dir
+
+ call ale#linter#Reset()
+
Execute(The tslint handler should parse lines correctly):
+ call ale#test#SetFilename('app/test.ts')
+
AssertEqual
\ [
\ {
- \ 'lnum': 235,
- \ 'col': 21,
- \ 'text': 'unused expression, expected an assignment or function call',
- \ 'type': 'W',
- \ },
- \ {
- \ 'lnum': 35,
- \ 'col': 6,
+ \ 'lnum': 1,
+ \ 'col': 15,
+ \ 'end_lnum': 1,
+ \ 'end_col': 15,
\ 'text': 'Missing semicolon',
\ 'type': 'E',
\ },
\ {
- \ 'lnum': 147,
- \ 'col': 10,
- \ 'text': 'Unnecessary semicolon',
+ \ 'lnum': 2,
+ \ 'col': 15,
+ \ 'end_lnum': 3,
+ \ 'end_col': 23,
+ \ 'text': 'Something else',
\ 'type': 'W',
\ },
+ \ ],
+ \ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([
\ {
- \ 'lnum': 101,
- \ 'col': 25,
- \ 'text': 'Unnecessary trailing comma',
- \ 'type': 'E',
+ \ 'endPosition': {
+ \ 'character': 14,
+ \ 'line': 0,
+ \ 'position': 14
+ \ },
+ \ 'failure': 'Missing semicolon',
+ \ 'fix': {
+ \ 'innerLength': 0,
+ \ 'innerStart': 14,
+ \ 'innerText': ';'
+ \ },
+ \ 'name': 'app/test.ts',
+ \ 'ruleName': 'semicolon',
+ \ 'ruleSeverity': 'ERROR',
+ \ 'startPosition': {
+ \ 'character': 14,
+ \ 'line': 0,
+ \ 'position': 14
+ \ }
\ },
- \ ],
- \ ale_linters#typescript#tslint#Handle(347, [
- \ 'This line should be ignored completely',
- \ 'WARNING: hello.ts[235, 21]: unused expression, expected an assignment or function call',
- \ 'ERROR: hello.ts[35, 6]: Missing semicolon',
- \ 'WARNING: hello.ts[147, 10]: Unnecessary semicolon',
- \ 'ERROR: hello.ts[101, 25]: Unnecessary trailing comma'
- \ ])
-
-After:
- call ale#linter#Reset()
+ \ {
+ \ 'endPosition': {
+ \ 'character': 11,
+ \ 'line': 2,
+ \ 'position': 22
+ \ },
+ \ 'failure': 'Something else',
+ \ 'fix': {
+ \ 'innerLength': 0,
+ \ 'innerStart': 14,
+ \ 'innerText': ';'
+ \ },
+ \ 'name': 'app/test.ts',
+ \ 'ruleName': 'something',
+ \ 'ruleSeverity': 'WARNING',
+ \ 'startPosition': {
+ \ 'character': 7,
+ \ 'line': 1,
+ \ 'position': 14
+ \ }
+ \ },
+ \ {
+ \ 'endPosition': {
+ \ 'character': 11,
+ \ 'line': 2,
+ \ 'position': 22
+ \ },
+ \ 'failure': 'Something else',
+ \ 'fix': {
+ \ 'innerLength': 0,
+ \ 'innerStart': 14,
+ \ 'innerText': ';'
+ \ },
+ \ 'name': 'app/something-else.ts',
+ \ 'ruleName': 'something',
+ \ 'ruleSeverity': 'WARNING',
+ \ 'startPosition': {
+ \ 'character': 7,
+ \ 'line': 1,
+ \ 'position': 14
+ \ }
+ \ },
+ \])])
diff --git a/test/test_path_equality.vader b/test/test_path_equality.vader
index 7043eb5f..78af5627 100644
--- a/test/test_path_equality.vader
+++ b/test/test_path_equality.vader
@@ -1,8 +1,13 @@
Execute(ale#path#IsBufferPath should match simple relative paths):
- silent file! foo.txt
+ call ale#test#SetFilename('app/foo.txt')
+
+ Assert ale#path#IsBufferPath(bufnr(''), 'app/foo.txt'), 'No match for foo.txt'
+ Assert !ale#path#IsBufferPath(bufnr(''), 'app/bar.txt'), 'Bad match for bar.txt'
+
+Execute(ale#path#IsBufferPath should match relative paths with dots):
+ call ale#test#SetFilename('app/foo.txt')
- Assert ale#path#IsBufferPath(bufnr(''), 'foo.txt'), 'No match for foo.txt'
- Assert !ale#path#IsBufferPath(bufnr(''), 'bar.txt'), 'Bad match for bar.txt'
+ Assert ale#path#IsBufferPath(bufnr(''), '../../app/foo.txt'), 'No match for ../../app/foo.txt'
Execute(ale#path#IsBufferPath should match absolute paths):
silent file! foo.txt
@@ -30,3 +35,9 @@ Execute(ale#path#IsBufferPath should accept various names for stdin):
Assert ale#path#IsBufferPath(bufnr(''), 'stdin')
Assert ale#path#IsBufferPath(bufnr(''), '<stdin>')
Assert ale#path#IsBufferPath(bufnr(''), '<somethingelse>')
+
+Execute(ale#path#IsBufferPath should match files in /tmp):
+ call ale#test#SetFilename('app/test.ts')
+
+ Assert ale#path#IsBufferPath(bufnr(''), '../../../../../../../../tmp/vG0hKyD/1/test.ts')
+ Assert ale#path#IsBufferPath(bufnr(''), '/tmp/vG0hKyD/1/test.ts')