diff options
Diffstat (limited to 'test/handler')
-rw-r--r-- | test/handler/test_crystal_handler.vader | 10 | ||||
-rw-r--r-- | test/handler/test_eslint_json_handler.vader | 20 | ||||
-rw-r--r-- | test/handler/test_mypy_handler.vader | 29 | ||||
-rw-r--r-- | test/handler/test_nim_handler.vader | 35 |
4 files changed, 92 insertions, 2 deletions
diff --git a/test/handler/test_crystal_handler.vader b/test/handler/test_crystal_handler.vader index a7b7f3ab..209632e9 100644 --- a/test/handler/test_crystal_handler.vader +++ b/test/handler/test_crystal_handler.vader @@ -16,3 +16,13 @@ Execute(The crystal handler should parse lines correctly and add the column if i \ ale_linters#crystal#crystal#Handle(255, [ \ '[{"file":"/tmp/test.cr","line":2,"column":1,"size":null,"message":"unexpected token: EOF"}]' \ ]) + +Execute(The crystal handler should not fail when a missing file is required): + AssertEqual + \ [ { 'lnum':1, 'col': 1, 'text': 'while requiring "./nonexistent.cr"' } ], + \ ale_linters#crystal#crystal#Handle(255, + \ json_encode([ + \ { "file":"/tmp/file.cr","line":1,"column":1,"size":0,"message":"while requiring \"./nonexistent.cr\"" }, + \ { "message": "can't find file './nonexistent.cr' relative to '/tmp'" }, + \ ]) + \ ) diff --git a/test/handler/test_eslint_json_handler.vader b/test/handler/test_eslint_json_handler.vader index 8e07bd80..6235794a 100644 --- a/test/handler/test_eslint_json_handler.vader +++ b/test/handler/test_eslint_json_handler.vader @@ -21,6 +21,7 @@ After: unlet! g:config_error_lines Execute(The eslint handler should parse json correctly): + call ale#test#SetFilename('foo.js') AssertEqual \ [ \ { @@ -53,6 +54,21 @@ Execute(The eslint handler should parse json correctly): \ '[{"filePath":"foo.js","messages":[{"ruleId":"no-unused-vars","severity":1,"message":"''variable'' is assigned a value but never used.","line":1,"column":7,"nodeType":"Identifier","endLine":1,"endColumn":15},{"ruleId":"semi","severity":1,"message":"Missing semicolon.","line":5,"column":15,"nodeType":"ExpressionStatement","fix":{"range":[46,46],"text":";"}},{"ruleId":"no-redeclare","severity":2,"message":"''variable'' is already defined.","line":7,"column":7,"nodeType":"Identifier","endLine":7,"endColumn":15}],"errorCount":1,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":1,"source":"const variable = {\n a: 3\n};\n\nconsole.log(1)\n\nclass variable {\n}\n"}]' \ ]) +Execute(The eslint handler should suppress deprecation warnings): + call ale#test#SetFilename('foo.js') + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 9, + \ 'text': 'Parsing error: Unexpected token Controller', + \ 'type': 'E', + \ } + \ ], + \ ale#handlers#eslint#HandleJSON(bufnr(''), [ + \ '[{"filePath":"foo.js","messages":[{"ruleId":null,"fatal":true,"severity":2 ,"message":"Parsing error: Unexpected token Controller","line":1,"column":9}],"errorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount": 0,"source":"i:mport Controller from \"@ember/controller\";\nimport listViewControllerMixin from \"elearning/mixins/list-view-controller\";\nimport { inject as service } from \"@ember/service\";\n\nexport default Controller.extend(listViewControllerMixin(), {\n modelName: \"notification\",\n intl: service(),\n\n flatpickrLocale: computed(\"intl.locale\", function() {\n return this.intl.locale.firstObject.split(\"-\")[0];\n })\n});\n"}]', '(node:616989) [ESLINT_LEGACY_OBJECT_REST_SPREAD] DeprecationWarning: The ''parserOptions.ecmaFeatures.experimentalObjectRestSpread'' option is deprecated. Use ''parser Options.ecmaVersion'' instead. (found in "node_modules/eslint-plugin-ember/lib/config/base.js")]' + \ ]) + Execute(The eslint handler should print a message about a missing configuration file): let g:config_error_lines = [ \ '', @@ -262,7 +278,7 @@ Execute(Suppressing missing configs shouldn't suppress module import errors): \ ale#handlers#eslint#HandleJSON(bufnr(''), g:config_error_lines[:]) Execute(The eslint handler should hint about using typescript-eslint-parser): - silent! noautocmd file foo.ts + call ale#test#SetFilename('foo.ts') AssertEqual \ [ @@ -326,7 +342,7 @@ Execute(Failing to connect to eslint_d should be handled correctly): \ ]) Execute(Disabling warnings about trailing spaces should work): - silent! noautocmd file foo.ts + call ale#test#SetFilename('foo.js') AssertEqual \ [ diff --git a/test/handler/test_mypy_handler.vader b/test/handler/test_mypy_handler.vader index 6e96f3f3..039155a2 100644 --- a/test/handler/test_mypy_handler.vader +++ b/test/handler/test_mypy_handler.vader @@ -1,6 +1,8 @@ Before: Save g:ale_python_mypy_ignore_invalid_syntax + Save g:ale_python_mypy_show_notes + unlet! g:ale_python_mypy_show_notes unlet! g:ale_python_mypy_ignore_invalid_syntax runtime ale_linters/python/mypy.vim @@ -16,6 +18,8 @@ After: Execute(The mypy handler should parse lines correctly): call ale#test#SetFilename('__init__.py') + let g:ale_python_mypy_show_notes = 0 + AssertEqual \ [ \ { @@ -69,6 +73,31 @@ Execute(The mypy handler should parse lines correctly): \ '__init__.py:72:1: warning: Some warning', \ ]) +Execute(The mypy handler should show notes if enabled): + call ale#test#SetFilename('__init__.py') + + AssertEqual + \ [ + \ { + \ 'lnum': 72, + \ 'col': 1, + \ 'filename': ale#path#Simplify(g:dir . '/__init__.py'), + \ 'type': 'I', + \ 'text': 'A note', + \ }, + \ ], + \ ale_linters#python#mypy#Handle(bufnr(''), [ + \ '__init__.py:72:1: note: A note', + \ ]) + + let g:ale_python_mypy_show_notes = 0 + + AssertEqual + \ [], + \ ale_linters#python#mypy#Handle(bufnr(''), [ + \ '__init__.py:72:1: note: A note', + \ ]) + Execute(The mypy handler should handle Windows names with spaces): " This test works on Unix, where this is seen as a single filename silent file C:\\something\\with\ spaces.py diff --git a/test/handler/test_nim_handler.vader b/test/handler/test_nim_handler.vader index e484000e..b6784d84 100644 --- a/test/handler/test_nim_handler.vader +++ b/test/handler/test_nim_handler.vader @@ -21,6 +21,7 @@ Execute(Parsing nim errors should work): \ 'col': 2, \ 'text': 'identifier expected, but found ''a.barfoo''', \ 'type': 'E', + \ 'end_col': 9, \ }, \ { \ 'lnum': 2, @@ -28,6 +29,7 @@ Execute(Parsing nim errors should work): \ 'text': '''NotUsed'' is declared but not used', \ 'code': 'XDeclaredButNotUsed', \ 'type': 'W', + \ 'end_col': 11, \ }, \ { \ 'lnum': 12, @@ -35,6 +37,35 @@ Execute(Parsing nim errors should work): \ 'text': 'with : character', \ 'type': 'E', \ }, + \ { + \ 'lnum': 1, + \ 'col': 8, + \ 'text': 'imported and not used: ''strutils''', + \ 'code': 'UnusedImport', + \ 'type': 'W', + \ 'end_col': 15, + \ }, + \ { + \ 'lnum': 12, + \ 'col': 9, + \ 'text': 'undeclared identifier: ''total''', + \ 'type': 'E', + \ 'end_col': 13, + \ }, + \ { + \ 'lnum': 14, + \ 'col': 1, + \ 'text': '''sum'' cannot be assigned to', + \ 'type': 'E', + \ 'end_col': 3, + \ }, + \ { + \ 'lnum': 15, + \ 'col': 1, + \ 'text': 'redefinition of ''getName''; previous declaration here: /nested/folder/foobar.nim(14, 6)', + \ 'type': 'E', + \ 'end_col': 7, + \ }, \ ], \ ale_linters#nim#nimcheck#Handle(bufnr(''), [ \ 'Line with wrong( format)', @@ -42,4 +73,8 @@ Execute(Parsing nim errors should work): \ 'foobar.nim(12, 2) Error: identifier expected, but found ''a.barfoo''', \ '/nested/folder/foobar.nim(2, 5) Hint: ''NotUsed'' is declared but not used [XDeclaredButNotUsed]', \ 'foobar.nim(12, 2) Error: with : character', + \ 'foobar.nim(1, 8) Warning: imported and not used: ''strutils'' [UnusedImport]', + \ 'foobar.nim(12, 9) Error: undeclared identifier: ''total''', + \ 'foobar.nim(14, 1) Error: ''sum'' cannot be assigned to', + \ 'foobar.nim(15, 1) Error: redefinition of ''getName''; previous declaration here: /nested/folder/foobar.nim(14, 6)', \ ]) |