From 4fc8452838253a59fabc58ba48ea7a6425261edb Mon Sep 17 00:00:00 2001 From: w0rp Date: Mon, 3 Apr 2017 22:51:39 +0100 Subject: [PATCH] #447 Support zsh in the shell linter --- ale_linters/sh/shell.vim | 6 +-- test/handler/test_shell_handler.vader | 53 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 test/handler/test_shell_handler.vader diff --git a/ale_linters/sh/shell.vim b/ale_linters/sh/shell.vim index 7ab98fd..412aa8b 100644 --- a/ale_linters/sh/shell.vim +++ b/ale_linters/sh/shell.vim @@ -38,7 +38,7 @@ function! ale_linters#sh#shell#Handle(buffer, lines) abort " " bash: line 13: syntax error near unexpected token `d' " sh: 11: Syntax error: "(" unexpected - let l:pattern = '^[^:]\+: \%(\w\+ \|\)\(\d\+\): \(.\+\)' + let l:pattern = '\v(line |: ?)(\d+): (.+)$' let l:output = [] for l:line in a:lines @@ -48,8 +48,8 @@ function! ale_linters#sh#shell#Handle(buffer, lines) abort continue endif - let l:line = l:match[1] + 0 - let l:text = l:match[2] + let l:line = l:match[2] + 0 + let l:text = l:match[3] let l:type = 'E' call add(l:output, { diff --git a/test/handler/test_shell_handler.vader b/test/handler/test_shell_handler.vader new file mode 100644 index 0000000..1250682 --- /dev/null +++ b/test/handler/test_shell_handler.vader @@ -0,0 +1,53 @@ +After: + call ale#linter#Reset() + +Execute(The shell handler should parse lines correctly): + runtime ale_linters/sh/shell.vim + + AssertEqual + \ [ + \ { + \ 'bufnr': 347, + \ 'lnum': 13, + \ 'text': 'syntax error near unexpected token d', + \ 'type': 'E', + \ }, + \ { + \ 'bufnr': 347, + \ 'lnum': 7, + \ 'text': 'line 42: line 36:', + \ 'type': 'E', + \ }, + \ { + \ 'bufnr': 347, + \ 'lnum': 11, + \ 'text': 'Syntax error: "(" unexpected', + \ 'type': 'E', + \ }, + \ { + \ 'bufnr': 347, + \ 'lnum': 95, + \ 'text': 'parse error near `out=$(( $1 / 1024. )...', + \ 'type': 'E', + \ }, + \ { + \ 'bufnr': 347, + \ 'lnum': 22, + \ 'text': ':11: :33: :44:', + \ 'type': 'E', + \ }, + \ { + \ 'bufnr': 347, + \ 'lnum': 9, + \ 'text': '`done'' unexpected', + \ 'type': 'E', + \ }, + \ ], + \ ale_linters#sh#shell#Handle(347, [ + \ 'bash: line 13: syntax error near unexpected token d', + \ 'bash: line 7: line 42: line 36:', + \ 'sh: 11: Syntax error: "(" unexpected', + \ 'qfm:95: parse error near `out=$(( $1 / 1024. )...', + \ 'qfm:22: :11: :33: :44:', + \ 'foo.sh: syntax error at line 9: `done'' unexpected', + \ ])