summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/go_paths/go1/prj1/file.go0
-rw-r--r--test/command_callback/go_paths/go2/prj2/file.go0
-rw-r--r--test/command_callback/test_dart_language_server_command_callback.vader8
-rw-r--r--test/command_callback/test_golangci_lint_command_callback.vader38
-rw-r--r--test/command_callback/test_golangserver_command_callback.vader67
-rw-r--r--test/command_callback/test_nasm_nasm_command_callbacks.vader6
-rw-r--r--test/command_callback/test_ruby_solargraph.vader7
-rw-r--r--test/command_callback/test_scala_sbtserver.vader19
-rw-r--r--test/completion/test_completion_prefixes.vader20
-rw-r--r--test/fixers/test_sqlfmt_fixer_callback.vader26
-rw-r--r--test/fixers/test_uncrustify_fixer_callback.vader36
-rw-r--r--test/handler/test_gitlint_handler.vader19
-rw-r--r--test/handler/test_golangci_lint_handler.vader55
-rw-r--r--test/handler/test_perl_handler.vader5
-rw-r--r--test/ruby_fixtures/valid_ruby_app3/.solargraph.yml0
-rw-r--r--test/ruby_fixtures/valid_ruby_app3/lib/file.rb0
-rw-r--r--test/scala_fixtures/invalid_sbt_project/Main.scala0
-rw-r--r--test/scala_fixtures/valid_sbt_project/Main.scala0
-rw-r--r--test/scala_fixtures/valid_sbt_project/build.sbt0
-rwxr-xr-xtest/script/block-padding-checker117
-rwxr-xr-xtest/script/custom-linting-rules15
-rw-r--r--test/test_should_do_nothing_conditions.vader18
22 files changed, 449 insertions, 7 deletions
diff --git a/test/command_callback/go_paths/go1/prj1/file.go b/test/command_callback/go_paths/go1/prj1/file.go
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/go_paths/go1/prj1/file.go
diff --git a/test/command_callback/go_paths/go2/prj2/file.go b/test/command_callback/go_paths/go2/prj2/file.go
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/go_paths/go2/prj2/file.go
diff --git a/test/command_callback/test_dart_language_server_command_callback.vader b/test/command_callback/test_dart_language_server_command_callback.vader
new file mode 100644
index 00000000..5567f271
--- /dev/null
+++ b/test/command_callback/test_dart_language_server_command_callback.vader
@@ -0,0 +1,8 @@
+Before:
+ call ale#assert#SetUpLinterTest('dart', 'language_server')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct):
+ AssertLinter 'dart_language_server', ale#Escape('dart_language_server')
diff --git a/test/command_callback/test_golangci_lint_command_callback.vader b/test/command_callback/test_golangci_lint_command_callback.vader
new file mode 100644
index 00000000..6cb73246
--- /dev/null
+++ b/test/command_callback/test_golangci_lint_command_callback.vader
@@ -0,0 +1,38 @@
+Before:
+ call ale#assert#SetUpLinterTest('go', 'golangci_lint')
+ call ale#test#SetFilename('test.go')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The golangci-lint defaults should be correct):
+ AssertLinter 'golangci-lint',
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
+ \ . ale#Escape('golangci-lint')
+ \ . ' run ' . ale#util#EscapePCRE(expand('%' . ':t'))
+ \ . ' --enable-all'
+
+Execute(The golangci-lint callback should use a configured executable):
+ let b:ale_go_golangci_lint_executable = 'something else'
+
+ AssertLinter 'something else',
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
+ \ . ale#Escape('something else')
+ \ . ' run ' . ale#util#EscapePCRE(expand('%' . ':t'))
+ \ . ' --enable-all'
+
+Execute(The golangci-lint callback should use configured options):
+ let b:ale_go_golangci_lint_options = '--foobar'
+
+ AssertLinter 'golangci-lint',
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
+ \ . ale#Escape('golangci-lint')
+ \ . ' run ' . ale#util#EscapePCRE(expand('%' . ':t'))
+ \ . ' --foobar'
+
+Execute(The golangci-lint `lint_package` option should use the correct command):
+ let b:ale_go_golangci_lint_package = 1
+
+ AssertLinter 'golangci-lint',
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
+ \ . ale#Escape('golangci-lint') . ' run --enable-all'
diff --git a/test/command_callback/test_golangserver_command_callback.vader b/test/command_callback/test_golangserver_command_callback.vader
new file mode 100644
index 00000000..ee88e1a4
--- /dev/null
+++ b/test/command_callback/test_golangserver_command_callback.vader
@@ -0,0 +1,67 @@
+Before:
+ Save $GOPATH
+ Save g:ale_completion_enabled
+
+ let g:ale_completion_enabled = 0
+ let g:sep = has('win32') ? ';' : ':'
+
+ call ale#assert#SetUpLinterTest('go', 'langserver')
+ let $GOPATH = ale#path#Simplify(g:dir . '/go_paths/go1')
+ \ . g:sep
+ \ . ale#path#Simplify(g:dir . '/go_paths/go2')
+
+After:
+ Restore
+
+ unlet! b:ale_completion_enabled
+ unlet! g:sep
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(should set correct defaults):
+ AssertLinter 'go-langserver', ale#Escape('go-langserver')
+
+Execute(should configure go-langserver callback executable):
+ let b:ale_go_langserver_executable = 'boo'
+
+ AssertLinter 'boo', ale#Escape('boo')
+
+Execute(should set go-langserver options):
+ call ale#test#SetFilename('go_paths/go1/prj1/file.go')
+ let b:ale_completion_enabled = 1
+ let b:ale_go_langserver_options = ''
+
+ AssertLinter 'go-langserver',
+ \ ale#Escape('go-langserver') . ' -gocodecompletion'
+
+ let b:ale_go_langserver_options = '-trace'
+
+ AssertLinter 'go-langserver',
+ \ ale#Escape('go-langserver') . ' -gocodecompletion -trace'
+
+Execute(should ignore go-langserver -gocodecompletion option):
+ call ale#test#SetFilename('go_paths/go1/prj1/file.go')
+
+ let b:ale_go_langserver_options = '-trace -gocodecompletion'
+ let b:ale_completion_enabled = 1
+
+ AssertLinter 'go-langserver',
+ \ ale#Escape('go-langserver') . ' -gocodecompletion -trace'
+
+ let b:ale_completion_enabled = 0
+
+ AssertLinter 'go-langserver', ale#Escape('go-langserver') . ' -trace'
+
+Execute(should set go-langserver for go app1):
+ call ale#test#SetFilename('go_paths/go1/prj1/file.go')
+
+ AssertLSPLanguage 'go'
+ AssertLSPOptions {}
+ AssertLSPProject ale#path#Simplify(g:dir . '/go_paths/go1')
+
+Execute(should set go-langserver for go app2):
+ call ale#test#SetFilename('go_paths/go2/prj1/file.go')
+
+ AssertLSPLanguage 'go'
+ AssertLSPOptions {}
+ AssertLSPProject ale#path#Simplify(g:dir . '/go_paths/go2')
diff --git a/test/command_callback/test_nasm_nasm_command_callbacks.vader b/test/command_callback/test_nasm_nasm_command_callbacks.vader
index 0d3e572a..8e077306 100644
--- a/test/command_callback/test_nasm_nasm_command_callbacks.vader
+++ b/test/command_callback/test_nasm_nasm_command_callbacks.vader
@@ -2,9 +2,9 @@ Before:
call ale#assert#SetUpLinterTest('nasm', 'nasm')
let b:command_tail =
- \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' %s'
+ \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' %s -o ' . (has('win32') ? 'NUL' : '/dev/null')
let b:command_tail_opt =
- \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w+orphan-labels %s'
+ \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w+orphan-labels %s -o ' . (has('win32') ? 'NUL' : '/dev/null')
After:
unlet! b:command_tail
@@ -23,7 +23,7 @@ Execute(The options should be configurable):
let b:ale_nasm_nasm_options = '-w-macro-params'
AssertLinter 'nasm', ale#Escape('nasm')
- \ . ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w-macro-params %s'
+ \ . ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w-macro-params %s -o ' . (has('win32') ? 'NUL' : '/dev/null')
Execute(The options should be used in command):
let b:ale_nasm_nasm_options = '-w+orphan-labels'
diff --git a/test/command_callback/test_ruby_solargraph.vader b/test/command_callback/test_ruby_solargraph.vader
index a27cb62d..b9dd46d8 100644
--- a/test/command_callback/test_ruby_solargraph.vader
+++ b/test/command_callback/test_ruby_solargraph.vader
@@ -27,3 +27,10 @@ Execute(should set solargraph for ruby app2):
AssertLSPOptions {}
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app2')
AssertLSPAddress '127.0.0.1:7658'
+
+Execute(should set solargraph for ruby app3):
+ call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app3/lib/file.rb')
+ AssertLSPLanguage 'ruby'
+ AssertLSPOptions {}
+ AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app3')
+ AssertLSPAddress '127.0.0.1:7658'
diff --git a/test/command_callback/test_scala_sbtserver.vader b/test/command_callback/test_scala_sbtserver.vader
new file mode 100644
index 00000000..1b708bd9
--- /dev/null
+++ b/test/command_callback/test_scala_sbtserver.vader
@@ -0,0 +1,19 @@
+" Author: ophirr33 <coghlan.ty@gmail.com>
+" Description: Tests for the sbt Server lsp linter
+
+Before:
+ call ale#assert#SetUpLinterTest('scala', 'sbtserver')
+After:
+ call ale#assert#TearDownLinterTest()
+Execute(should set sbtserver for sbt project with build.sbt):
+ call ale#test#SetFilename('../scala_fixtures/valid_sbt_project/Main.scala')
+ AssertLSPLanguage 'scala'
+ AssertLSPOptions {}
+ AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../scala_fixtures/valid_sbt_project')
+ AssertLSPAddress '127.0.0.1:4273'
+Execute(should not set sbtserver for sbt project without build.sbt):
+ call ale#test#SetFilename('../scala_fixtures/invalid_sbt_project/Main.scala')
+ AssertLSPLanguage 'scala'
+ AssertLSPOptions {}
+ AssertLSPProject ''
+ AssertLSPAddress '127.0.0.1:4273'
diff --git a/test/completion/test_completion_prefixes.vader b/test/completion/test_completion_prefixes.vader
index 0b2cfeaf..3f2cab15 100644
--- a/test/completion/test_completion_prefixes.vader
+++ b/test/completion/test_completion_prefixes.vader
@@ -43,3 +43,23 @@ Execute(Completion should be done after words in parens in Rust):
Execute(Completion should not be done after parens in Rust):
AssertEqual '', ale#completion#GetPrefix(&filetype, 3, 15)
+
+Given lisp():
+ (minus-name
+ (full-name)
+
+Execute(Completion should be done for function names with minuses in Lisp):
+ AssertEqual 'minus-name', ale#completion#GetPrefix(&filetype, 1, 12)
+
+Execute(Completion should not be done after parens in Lisp):
+ AssertEqual '', ale#completion#GetPrefix(&filetype, 2, 12)
+
+Given clojure():
+ (minus-name
+ (full-name)
+
+Execute(Completion should be done for function names with minuses in Clojure):
+ AssertEqual 'minus-name', ale#completion#GetPrefix(&filetype, 1, 12)
+
+Execute(Completion should not be done after parens in Clojure):
+ AssertEqual '', ale#completion#GetPrefix(&filetype, 2, 12)
diff --git a/test/fixers/test_sqlfmt_fixer_callback.vader b/test/fixers/test_sqlfmt_fixer_callback.vader
new file mode 100644
index 00000000..3046edb3
--- /dev/null
+++ b/test/fixers/test_sqlfmt_fixer_callback.vader
@@ -0,0 +1,26 @@
+Before:
+ Save g:ale_sql_sqlfmt_executable
+ Save g:ale_sql_sqlfmt_options
+
+After:
+ Restore
+
+Execute(The sqlfmt callback should return the correct default values):
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('sqlfmt')
+ \ . ' -w',
+ \ },
+ \ ale#fixers#sqlfmt#Fix(bufnr(''))
+
+Execute(The sqlfmt executable and options should be configurable):
+ let g:ale_sql_sqlfmt_executable = '/path/to/sqlfmt'
+ let g:ale_sql_sqlfmt_options = '-u'
+
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('/path/to/sqlfmt')
+ \ . ' -w'
+ \ . ' -u',
+ \ },
+ \ ale#fixers#sqlfmt#Fix(bufnr(''))
diff --git a/test/fixers/test_uncrustify_fixer_callback.vader b/test/fixers/test_uncrustify_fixer_callback.vader
new file mode 100644
index 00000000..8ef4e79b
--- /dev/null
+++ b/test/fixers/test_uncrustify_fixer_callback.vader
@@ -0,0 +1,36 @@
+Before:
+ Save g:ale_c_uncrustify_executable
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_c_uncrustify_executable = 'xxxinvalid'
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+ silent cd ..
+ silent cd command_callback
+ let g:dir = getcwd()
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The clang-format callback should return the correct default values):
+ call ale#test#SetFilename('c_paths/dummy.c')
+
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape(g:ale_c_uncrustify_executable)
+ \ . ' --no-backup'
+ \ },
+ \ ale#fixers#uncrustify#Fix(bufnr(''))
+
+Execute(The uncrustify callback should include any additional options):
+ call ale#test#SetFilename('c_paths/dummy.c')
+ let b:ale_c_uncrustify_options = '--some-option'
+
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape(g:ale_c_uncrustify_executable)
+ \ . ' --no-backup --some-option',
+ \ },
+ \ ale#fixers#uncrustify#Fix(bufnr(''))
diff --git a/test/handler/test_gitlint_handler.vader b/test/handler/test_gitlint_handler.vader
index 60d632a0..5c531664 100644
--- a/test/handler/test_gitlint_handler.vader
+++ b/test/handler/test_gitlint_handler.vader
@@ -61,6 +61,19 @@ Execute(Disabling trailing whitespace warnings should work):
\ '8: T2 Trailing whitespace',
\])
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 8,
+ \ 'type': 'E',
+ \ 'text': 'Trailing whitespace',
+ \ 'code': 'B2',
+ \ },
+ \ ],
+ \ ale_linters#gitcommit#gitlint#Handle(bufnr(''), [
+ \ '8: B2 Trailing whitespace',
+ \])
+
let b:ale_warn_about_trailing_whitespace = 0
AssertEqual
@@ -68,3 +81,9 @@ Execute(Disabling trailing whitespace warnings should work):
\ ale_linters#gitcommit#gitlint#Handle(bufnr(''), [
\ '8: T2 Trailing whitespace',
\ ])
+
+ AssertEqual
+ \ [],
+ \ ale_linters#gitcommit#gitlint#Handle(bufnr(''), [
+ \ '8: B2 Trailing whitespace',
+ \ ])
diff --git a/test/handler/test_golangci_lint_handler.vader b/test/handler/test_golangci_lint_handler.vader
new file mode 100644
index 00000000..fb6841f4
--- /dev/null
+++ b/test/handler/test_golangci_lint_handler.vader
@@ -0,0 +1,55 @@
+Before:
+ runtime ale_linters/go/golangci_lint.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute (The golangci-lint handler should handle names with spaces):
+ " We can't test Windows paths with the path resovling on Linux, but we can
+ " test the regex.
+ AssertEqual
+ \ [
+ \ [
+ \ 'C:\something\file with spaces.go',
+ \ '12',
+ \ '3',
+ \ 'expected ''package'', found ''IDENT'' gibberish (staticcheck)',
+ \ ],
+ \ [
+ \ 'C:\something\file with spaces.go',
+ \ '37',
+ \ '5',
+ \ 'expected ''package'', found ''IDENT'' gibberish (golint)',
+ \ ],
+ \ ],
+ \ map(ale_linters#go#golangci_lint#GetMatches([
+ \ 'C:\something\file with spaces.go:12:3: expected ''package'', found ''IDENT'' gibberish (staticcheck)',
+ \ 'C:\something\file with spaces.go:37:5: expected ''package'', found ''IDENT'' gibberish (golint)',
+ \ ]), 'v:val[1:4]')
+
+Execute (The golangci-lint handler should handle paths correctly):
+ call ale#test#SetFilename('app/test.go')
+
+ let file = ale#path#GetAbsPath(expand('%:p:h'), 'test.go')
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 12,
+ \ 'col': 3,
+ \ 'text': 'expected ''package'', found ''IDENT'' gibberish (staticcheck)',
+ \ 'type': 'E',
+ \ 'filename': ale#path#Simplify(expand('%:p:h') . '/test.go'),
+ \ },
+ \ {
+ \ 'lnum': 37,
+ \ 'col': 5,
+ \ 'text': 'expected ''package'', found ''IDENT'' gibberish (golint)',
+ \ 'type': 'E',
+ \ 'filename': ale#path#Simplify(expand('%:p:h') . '/test.go'),
+ \ },
+ \ ],
+ \ ale_linters#go#golangci_lint#Handler(bufnr(''), [
+ \ file . ':12:3: expected ''package'', found ''IDENT'' gibberish (staticcheck)',
+ \ file . ':37:5: expected ''package'', found ''IDENT'' gibberish (golint)',
+ \ ])
diff --git a/test/handler/test_perl_handler.vader b/test/handler/test_perl_handler.vader
index c5791d76..e769550c 100644
--- a/test/handler/test_perl_handler.vader
+++ b/test/handler/test_perl_handler.vader
@@ -7,6 +7,11 @@ After:
call ale#test#RestoreDirectory()
call ale#linter#Reset()
+Execute(The Perl linter should handle empty output):
+ call ale#test#SetFilename('bar.pl')
+
+ AssertEqual [], ale_linters#perl#perl#Handle(bufnr(''), [])
+
Execute(The Perl linter should ignore errors from other files):
call ale#test#SetFilename('bar.pl')
diff --git a/test/ruby_fixtures/valid_ruby_app3/.solargraph.yml b/test/ruby_fixtures/valid_ruby_app3/.solargraph.yml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/ruby_fixtures/valid_ruby_app3/.solargraph.yml
diff --git a/test/ruby_fixtures/valid_ruby_app3/lib/file.rb b/test/ruby_fixtures/valid_ruby_app3/lib/file.rb
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/ruby_fixtures/valid_ruby_app3/lib/file.rb
diff --git a/test/scala_fixtures/invalid_sbt_project/Main.scala b/test/scala_fixtures/invalid_sbt_project/Main.scala
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/scala_fixtures/invalid_sbt_project/Main.scala
diff --git a/test/scala_fixtures/valid_sbt_project/Main.scala b/test/scala_fixtures/valid_sbt_project/Main.scala
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/scala_fixtures/valid_sbt_project/Main.scala
diff --git a/test/scala_fixtures/valid_sbt_project/build.sbt b/test/scala_fixtures/valid_sbt_project/build.sbt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/scala_fixtures/valid_sbt_project/build.sbt
diff --git a/test/script/block-padding-checker b/test/script/block-padding-checker
new file mode 100755
index 00000000..b13c9b92
--- /dev/null
+++ b/test/script/block-padding-checker
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+"""
+This script checks for missing or forbidden blank lines before or after
+particular Vim commands. This script ensures that VimL scripts are padded
+correctly, so they are easier to read.
+"""
+
+import sys
+import re
+
+INDENTATION_RE = re.compile(r'^ *')
+COMMENT_LINE_RE = re.compile(r'^ *"')
+COMMAND_RE = re.compile(r'^ *([a-zA-Z]+)')
+
+START_BLOCKS = set(['if', 'for', 'while', 'try', 'function'])
+END_BLOCKS = set(['endif', 'endfor', 'endwhile', 'endtry', 'endfunction'])
+MIDDLE_BLOCKS = set(['else', 'elseif', 'catch', 'finally'])
+TERMINATORS = set(['return', 'throw'])
+
+WHITESPACE_BEFORE_SET = START_BLOCKS | TERMINATORS
+WHITESPACE_FORBIDDEN_BEFORE_SET = END_BLOCKS | MIDDLE_BLOCKS
+WHITESPACE_AFTER_SET = END_BLOCKS
+WHITESPACE_FORBIDDEN_AFTER_SET = START_BLOCKS | MIDDLE_BLOCKS
+
+
+def remove_comment_lines(line_iter):
+ for line_number, line in enumerate(line_iter, 1):
+ if not COMMENT_LINE_RE.match(line):
+ yield (line_number, line)
+
+
+def check_lines(line_iter):
+ previous_indentation_level = None
+ previous_command = None
+ previous_line_blank = False
+
+ for line_number, line in remove_comment_lines(line_iter):
+ if len(line) == 0:
+ # Check for commands where we shouldn't have blank lines after
+ # them, like `else` or the start of blocks like `function`.
+ if (
+ previous_command is not None
+ and previous_command in WHITESPACE_FORBIDDEN_AFTER_SET
+ ):
+ yield (
+ line_number,
+ 'Blank line forbidden after `%s`' % (command,)
+ )
+
+ previous_line_blank = True
+ previous_command = None
+ else:
+ indentation_level = INDENTATION_RE.match(line).end()
+ command_match = COMMAND_RE.match(line)
+
+ if command_match:
+ command = command_match.group(1)
+
+ # Check for commands requiring blank lines before them, if they
+ # aren't at the start of a block.
+ if (
+ command in WHITESPACE_BEFORE_SET
+ and previous_indentation_level is not None
+ and indentation_level == previous_indentation_level
+ and previous_line_blank is False
+ ):
+ yield (
+ line_number,
+ 'Blank line required before `%s`' % (command,)
+ )
+
+ # Check for commands where we shouldn't have blank lines before
+ # them, like `else` or the end of blocks like `endfunction`.
+ if (
+ command in WHITESPACE_FORBIDDEN_BEFORE_SET
+ and previous_line_blank is True
+ ):
+ yield (
+ line_number - 1,
+ 'Blank line forbidden before `%s`' % (command,)
+ )
+
+ # Check for commands requiring blank lines after them, if they
+ # aren't at the end of a block.
+ if (
+ previous_command is not None
+ and previous_command in WHITESPACE_AFTER_SET
+ and previous_indentation_level is not None
+ and indentation_level == previous_indentation_level
+ and previous_line_blank is False
+ ):
+ yield (
+ line_number - 1,
+ 'Blank line required after `%s`' % (command,)
+ )
+
+ previous_command = command
+ previous_line_blank = False
+ previous_indentation_level = indentation_level
+
+
+def main():
+ status = 0
+
+ for filename in sys.argv[1:]:
+ with open(filename) as vim_file:
+ line_iter = (line.rstrip() for line in vim_file)
+
+ for line_number, message in check_lines(line_iter):
+ print('%s:%d %s' % (filename, line_number, message))
+ status = 1
+
+ sys.exit(status)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/test/script/custom-linting-rules b/test/script/custom-linting-rules
index 7aafe995..77e87db4 100755
--- a/test/script/custom-linting-rules
+++ b/test/script/custom-linting-rules
@@ -60,10 +60,10 @@ check_errors() {
for directory in "${directories[@]}"; do
# shellcheck disable=SC2086
- while IFS= read -r match; do
+ while read -r; do
RETURN_CODE=1
- echo "$match $message"
- done < <(grep -n "$regex" $include_arg "$directory"/**/*.vim \
+ echo "$REPLY $message"
+ done < <(grep -H -n "$regex" $include_arg "$directory"/**/*.vim \
| grep -v 'no-custom-checks' \
| grep -o '^[^:]\+:[0-9]\+' \
| sed 's:^\./::')
@@ -126,4 +126,13 @@ check_errors '\(!=.\?\|isnot\) type(\[\])' "Use 'isnot v:t_list' instead"
check_errors '\(!=.\?\|isnot\) type({})' "Use 'isnot v:t_dict' instead"
check_errors '\(!=.\?\|isnot\) type(function([^)]\+))' "Use 'isnot v:t_func' instead"
+# Run a Python script to find lines that require padding around them. For
+# users without Python installed, we'll skip these checks. Travis CI will run
+# the script.
+if command -v python > /dev/null; then
+ if ! test/script/block-padding-checker "$directory"/**/*.vim; then
+ RETURN_CODE=1
+ fi
+fi
+
exit $RETURN_CODE
diff --git a/test/test_should_do_nothing_conditions.vader b/test/test_should_do_nothing_conditions.vader
index 062ab875..de2e2782 100644
--- a/test/test_should_do_nothing_conditions.vader
+++ b/test/test_should_do_nothing_conditions.vader
@@ -4,10 +4,18 @@ Before:
Save g:ale_enabled
Save &l:statusline
+ let b:fake_mode = 'n'
+
call ale#test#SetDirectory('/testplugin/test')
let b:funky_command_created = 0
+ runtime autoload/ale/util.vim
+
+ function! ale#util#Mode(...) abort
+ return b:fake_mode
+ endfunction
+
" We will test for the existence of this command, so create one if needed.
if !exists(':CtrlPFunky')
command CtrlPFunky echo
@@ -25,6 +33,9 @@ After:
endif
unlet! b:funky_command_created
+ unlet! b:fake_mode
+
+ runtime autoload/ale/util.vim
Given foobar(An empty file):
Execute(ALE shouldn't do much of anything for ctrlp-funky buffers):
@@ -44,7 +55,7 @@ Execute(ALE shouldn't try to check buffers with '.' as the filename):
Assert ale#ShouldDoNothing(bufnr(''))
-Execute(DoNothing should return 0 when the filetype is empty):
+Execute(DoNothing should return 1 when the filetype is empty):
AssertEqual
\ 0,
\ ale#ShouldDoNothing(bufnr('')),
@@ -54,6 +65,11 @@ Execute(DoNothing should return 0 when the filetype is empty):
AssertEqual 1, ale#ShouldDoNothing(bufnr(''))
+Execute(DoNothing should return 1 when an operator is pending):
+ let b:fake_mode = 'no'
+
+ AssertEqual 1, ale#ShouldDoNothing(bufnr(''))
+
Execute(The DoNothing check should work if the ALE globals aren't defined):
unlet! g:ale_filetype_blacklist
unlet! g:ale_maximum_file_size