#4454 Clean up more tests and code

* Remove some tests we no longer need
* Delete blocks of redundant code
* Compress some tests together to simplify them
* Remove a little code for ancient linter versions
* Escape more executables we didn't escape before
* Rename a deno option that didn't match our conventions
This commit is contained in:
w0rp
2023-09-16 22:22:01 +01:00
parent 4b11cf21dc
commit ae1d051504
98 changed files with 257 additions and 674 deletions

View File

@@ -1,11 +1,14 @@
Before:
Save b:ale_warn_about_trailing_whitespace
runtime ale_linters/ansible/ansible_lint.vim
call ale#test#SetFilename('test_playbook.yml')
let b:ale_warn_about_trailing_whitespace = 1
After:
unlet! b:ale_warn_about_trailing_whitespace
Restore
call ale#linter#Reset()
Execute(The ansible-lint handler for version group <5 should handle basic errors):

View File

@@ -5,7 +5,6 @@ After:
call ale#linter#Reset()
Execute(The asm GCC handler should parse lines from GCC 6.3.1 correctly):
AssertEqual
\ [
\ {

View File

@@ -5,7 +5,6 @@ After:
call ale#linter#Reset()
Execute(The bibclean handler should parse lines from bibclean <= v2.11.4 correctly):
AssertEqual
\ [
\ {
@@ -46,7 +45,6 @@ Execute(The bibclean handler should parse lines from bibclean <= v2.11.4 correct
\ ])
Execute(The bibclean handler should parse lines of bibclean > v2.11.4 correctly):
AssertEqual
\ [
\ {

View File

@@ -2,8 +2,6 @@ Before:
runtime ale_linters/bicep/az_bicep.vim
After:
Restore
call ale#linter#Reset()
Execute(The az_bicep handler should handle basic warnings):

View File

@@ -2,8 +2,6 @@ Before:
runtime ale_linters/bicep/bicep.vim
After:
Restore
call ale#linter#Reset()
Execute(The bicep handler should handle basic warnings):

View File

@@ -74,7 +74,7 @@ Execute(The brakeman handler should parse JSON correctly when there is no output
\ [],
\ ale_linters#ruby#brakeman#Handle(347, [
\ ])
\
Execute(The brakeman handler should handle garbage output):
AssertEqual
\ [],

View File

@@ -2,11 +2,9 @@ Before:
runtime ale_linters/make/checkmake.vim
After:
call ale#linter#Reset()
call ale#linter#Reset()
Execute(Parsing checkmake errors should work):
silent file Makefile
AssertEqual
\ [
\ {

View File

@@ -2,8 +2,6 @@ Before:
runtime ale_linters/cmake/cmake_lint.vim
After:
Restore
call ale#linter#Reset()
Execute(The cmake_lint handler should handle basic warnings):

View File

@@ -19,4 +19,3 @@ Execute(Basic warnings should be handled):
\ ale_linters#chef#cookstyle#Handle(bufnr(''), [
\ '{"metadata":{"rubocop_version":"0.62.0","ruby_engine":"ruby","ruby_version":"2.6.0","ruby_patchlevel":"0","ruby_platform":"x86_64-linux"},"files":[{"path":"recipes/default.rb","offenses":[{"severity":"convention","message":"Style/UnneededInterpolation: Prefer `to_s` over string interpolation.","cop_name":"Style/UnneededInterpolation","corrected":false,"location":{"start_line":58,"start_column":24,"last_line":58,"last_column":40,"length":17,"line":58,"column":24}}]}],"summary":{"offense_count":1,"target_file_count":1,"inspected_file_count":1}}'
\ ])

View File

@@ -5,7 +5,6 @@ After:
call ale#linter#Reset()
Execute(cpplint warnings from included files should be parsed correctly):
AssertEqual
\ [
\ {

View File

@@ -9,7 +9,7 @@ Before:
runtime ale_linters/cs/csc.vim
After:
unlet! g:ale_cs_csc_source
Restore
call ale#test#RestoreDirectory()
call ale#linter#Reset()

View File

@@ -1,8 +1,4 @@
Execute(The deadnix handler should handle deadnix output):
let output = [
\'{"file":"./flake.nix","results":[{"column":5,"endColumn":9,"line":23,"message":"Unused lambda pattern: self"},{"column":2,"endColumn":6,"line":1,"message":"Unused lambda pattern: pkgs"}]}'
\]
AssertEqual
\ [
\ {
@@ -20,7 +16,9 @@ Execute(The deadnix handler should handle deadnix output):
\ 'type': 'W',
\ },
\ ],
\ ale#handlers#deadnix#Handle(bufnr(''), output)
\ ale#handlers#deadnix#Handle(bufnr(''), [
\ '{"file":"./flake.nix","results":[{"column":5,"endColumn":9,"line":23,"message":"Unused lambda pattern: self"},{"column":2,"endColumn":6,"line":1,"message":"Unused lambda pattern: pkgs"}]}'
\ ])
AssertEqual [], ale#handlers#deadnix#Handle(bufnr(''), [''])
AssertEqual [], ale#handlers#deadnix#Handle(bufnr(''), ['not json'])

View File

@@ -5,7 +5,6 @@ After:
call ale#linter#Reset()
Execute(The dogma handler should parse lines correctly):
AssertEqual
\ [
\ {

View File

@@ -2,7 +2,6 @@ Before:
runtime ale_linters/eruby/erblint.vim
After:
unlet! g:lines
call ale#linter#Reset()
Execute(The erblint handler should parse lines correctly):
@@ -61,10 +60,5 @@ Execute(The erblint handler should handle when files are checked and no offenses
\ ])
Execute(The erblint handler should handle output without any errors):
AssertEqual
\ [],
\ ale_linters#eruby#erblint#Handle(347, ['{}'])
AssertEqual
\ [],
\ ale_linters#eruby#erblint#Handle(347, [])
AssertEqual [], ale_linters#eruby#erblint#Handle(347, ['{}'])
AssertEqual [], ale_linters#eruby#erblint#Handle(347, [])

View File

@@ -16,12 +16,6 @@ Execute(The dialyzer handler should handle error messages.):
\],
\ ale_linters#erlang#dialyzer#Handle(bufnr(''), ['erl_tidy_prv_fmt.erl:3: Callback info about the provider behaviour is not available'])
Execute(The dialyzer handler should handle empty file.):
AssertEqual
\[],
\ ale_linters#erlang#dialyzer#Handle(bufnr(''), [])
Execute(The dialyzer handler should handle empty lines.):
AssertEqual
\[],
\ ale_linters#erlang#dialyzer#Handle(bufnr(''), [''])
Execute(The dialyzer handler should handle empty input):
AssertEqual [], ale_linters#erlang#dialyzer#Handle(bufnr(''), [])
AssertEqual [], ale_linters#erlang#dialyzer#Handle(bufnr(''), [''])

View File

@@ -1,8 +1,8 @@
Before:
runtime ale_linters/fish/fish.vim
runtime ale_linters/fish/fish.vim
After:
call ale#linter#Reset()
call ale#linter#Reset()
Execute(The fish handler should handle basic warnings and syntax errors):
AssertEqual

View File

@@ -1,23 +1,10 @@
Before:
Save g:ale_c_flawfinder_error_severity
unlet! g:ale_c_flawfinder_error_severity
unlet! b:ale_c_flawfinder_error_severity
Save b:ale_c_flawfinder_error_severity
runtime ale_linters/c/flawfinder.vim
After:
unlet! g:ale_c_flawfinder_error_severity
Restore
Execute(The Flawfinder handler should ignore other lines of output):
AssertEqual
\ [],
\ ale#handlers#flawfinder#HandleFlawfinderFormat(347, [
\ 'foo',
\ 'bar',
\ 'baz',
\ ])
call ale#linter#Reset()
Execute(The Flawfinder handler should work):
AssertEqual
@@ -30,7 +17,10 @@ Execute(The Flawfinder handler should work):
\ },
\ ],
\ ale#handlers#flawfinder#HandleFlawfinderFormat(347, [
\ "<stdin>:31:4: [1] (buffer) strncpy:Easily used incorrectly",
\ '<stdin>:31:4: [1] (buffer) strncpy:Easily used incorrectly',
\ 'foo',
\ 'bar',
\ 'baz',
\ ])
Execute(The Flawfinder error severity level should be configurable):
@@ -52,6 +42,6 @@ Execute(The Flawfinder error severity level should be configurable):
\ },
\ ],
\ ale#handlers#flawfinder#HandleFlawfinderFormat(bufnr(''), [
\ "<stdin>:12:4: [2] (buffer) char:Statically-sized arrays can be bad",
\ "<stdin>:31:4: [1] (buffer) strncpy:Easily used incorrectly",
\ '<stdin>:12:4: [2] (buffer) char:Statically-sized arrays can be bad',
\ '<stdin>:31:4: [1] (buffer) strncpy:Easily used incorrectly',
\ ])

View File

@@ -4,69 +4,6 @@ Before:
After:
call ale#linter#Reset()
Execute(The fortran handler should parse lines from GCC 4.1.2 correctly):
AssertEqual
\ [
\ {
\ 'bufnr': 357,
\ 'lnum': 4,
\ 'col': 0,
\ 'text': "Symbol b at (1) has no IMPLICIT type",
\ 'type': 'E',
\ },
\ {
\ 'bufnr': 357,
\ 'lnum': 3,
\ 'col': 0,
\ 'text': "Symbol a at (1) has no IMPLICIT type",
\ 'type': 'E',
\ },
\ ],
\ ale_linters#fortran#gcc#Handle(357, [
\ " In file :4",
\ "",
\ "write(*,*) b",
\ " 1",
\ "Error: Symbol b at (1) has no IMPLICIT type",
\ " In file :3",
\ "",
\ "write(*,*) a",
\ " 1",
\ "Error: Symbol a at (1) has no IMPLICIT type",
\ ])
Execute(The fortran handler should parse lines from GCC 4.9.3 correctly):
AssertEqual
\ [
\ {
\ 'bufnr': 357,
\ 'lnum': 3,
\ 'col': 12,
\ 'text': "Symbol a at (1) has no IMPLICIT type",
\ 'type': 'E',
\ },
\ {
\ 'bufnr': 357,
\ 'lnum': 4,
\ 'col': 12,
\ 'text': "Symbol b at (1) has no IMPLICIT type",
\ 'type': 'E',
\ },
\ ],
\ ale_linters#fortran#gcc#Handle(357, [
\ ":3.12:",
\ "",
\ "write(*,*) a",
\ " 1",
\ "Error: Symbol a at (1) has no IMPLICIT type",
\ ":4.12:",
\ "",
\ "write(*,*) b",
\ " 1",
\ "Error: Symbol b at (1) has no IMPLICIT type",
\ ])
Execute(The fortran handler should parse lines from GCC 6.3.1 correctly):
AssertEqual
\ [

View File

@@ -5,7 +5,6 @@ After:
call ale#linter#Reset()
Execute(gawk syntax errors should be parsed correctly):
AssertEqual
\ [
\ {

View File

@@ -1,11 +1,7 @@
Execute(The GCC handler should ignore other lines of output):
AssertEqual
\ [],
\ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
\ 'foo',
\ 'bar',
\ 'baz',
\ ])
\ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, ['foo', 'bar', 'baz'])
Execute(GCC errors from included files should be parsed correctly):
AssertEqual

View File

@@ -1,3 +1,6 @@
After:
unlet! g:detail
Execute(The ghc handler should handle hdevtools output):
call ale#test#SetFilename('foo.hs')

View File

@@ -2,7 +2,6 @@ Before:
runtime! ale_linters/yaml/gitlablint.vim
After:
Restore
call ale#linter#Reset()
Execute(Problems should be parsed correctly for gitlablint):

View File

@@ -43,8 +43,6 @@ Execute (The golangci-lint handler should handle paths correctly):
Execute (The golangci-lint handler should handle only typecheck lines as errors):
call ale#test#SetFilename('app/main.go')
let file = ale#path#GetAbsPath(expand('%:p:h'), 'test.go')
AssertEqual
\ [
\ {
@@ -63,6 +61,6 @@ Execute (The golangci-lint handler should handle only typecheck lines as errors)
\ }
\ ],
\ ale_linters#go#golangci_lint#Handler(bufnr(''), [
\ file . ':30:5: variable ''err'' is not used (typecheck)',
\ file . ':505:75: Magic number: 404, in <argument> detected (gomnd)',
\ ale#path#GetAbsPath(expand('%:p:h'), 'test.go') . ':30:5: variable ''err'' is not used (typecheck)',
\ ale#path#GetAbsPath(expand('%:p:h'), 'test.go') . ':505:75: Magic number: 404, in <argument> detected (gomnd)',
\ ])

View File

@@ -5,7 +5,6 @@ After:
call ale#linter#Reset()
Execute(The asm llvm-mc handler should parse lines correctly):
AssertEqual
\ [
\ {

View File

@@ -33,4 +33,3 @@ Execute(The luac handler should parse lines correctly):
\ 'luac /file/path/here.lua:3: unexpected symbol near ''-''',
\ 'luac /file/path/here.lua:5: ''='' expected near '')''',
\ ])

View File

@@ -4,64 +4,7 @@ Before:
After:
call ale#linter#Reset()
Execute(The Markdownlint handler should parse pre v0.19.0 output with single digit line correctly):
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'code': 'MD013/line-length',
\ 'text': 'Line length [Expected: 80; Actual: 114]',
\ 'type': 'W'
\ }
\ ],
\ ale#handlers#markdownlint#Handle(0, [
\ 'README.md: 1: MD013/line-length Line length [Expected: 80; Actual: 114]'
\ ])
Execute(The Markdownlint handler should parse pre v0.19.0 output with multi digit line correctly):
AssertEqual
\ [
\ {
\ 'lnum': 100,
\ 'code': 'MD013/line-length',
\ 'text': 'Line length [Expected: 80; Actual: 114]',
\ 'type': 'W'
\ }
\ ],
\ ale#handlers#markdownlint#Handle(0, [
\ 'README.md: 100: MD013/line-length Line length [Expected: 80; Actual: 114]'
\ ])
Execute(The Markdownlint handler should parse post v0.19.0 output with single digit line correctly):
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'code': 'MD013/line-length',
\ 'text': 'Line length [Expected: 80; Actual: 114]',
\ 'type': 'W'
\ }
\ ],
\ ale#handlers#markdownlint#Handle(0, [
\ 'README.md:1 MD013/line-length Line length [Expected: 80; Actual: 114]'
\ ])
Execute(The Markdownlint handler should parse post v0.19.0 output with multi digit line correctly):
AssertEqual
\ [
\ {
\ 'lnum': 100,
\ 'code': 'MD013/line-length',
\ 'text': 'Line length [Expected: 80; Actual: 114]',
\ 'type': 'W'
\ }
\ ],
\ ale#handlers#markdownlint#Handle(0, [
\ 'README.md:100 MD013/line-length Line length [Expected: 80; Actual: 114]'
\ ])
Execute(The Markdownlint handler should parse post v0.22.0 output with column correctly):
Execute(The Markdownlint handler should parse output with a column correctly):
AssertEqual
\ [
\ {

View File

@@ -5,7 +5,6 @@ After:
call ale#linter#Reset()
Execute(The mix handler should parse lines correctly):
AssertEqual
\ [
\ {

View File

@@ -17,4 +17,3 @@ Execute(The Perl::Critic handler should create all issues as warnings):
\ ale_linters#perl#perlcritic#Handle(99, [
\ '21:17 Regular expression without "/m" flag'
\ ])

View File

@@ -4,8 +4,6 @@ Before:
runtime ale_linters/php/phpstan.vim
After:
Restore
call ale#test#RestoreDirectory()
call ale#linter#Reset()

View File

@@ -10,8 +10,6 @@ After:
call ale#linter#Reset()
silent file something_else.py
Execute(Basic prospector errors should be handle):
AssertEqual
\ [

View File

@@ -14,7 +14,6 @@ After:
unlet! b:ale_warn_about_trailing_whitespace
call ale#linter#Reset()
silent file something_else.py
Execute(The pycodestyle handler should parse output):
AssertEqual

View File

@@ -20,7 +20,7 @@ After:
" This is a multi-line description that should produce multiple errors to be
" tested by the handler
" """
" return Fales
" return False
"
"
" if __name__ == '__main__':

View File

@@ -1,12 +1,19 @@
Before:
Save g:ale_ruby_reek_show_context
Save g:ale_ruby_reek_show_wiki_link
let g:ale_ruby_reek_show_context = 0
let g:ale_ruby_reek_show_wiki_link = 0
runtime ale_linters/ruby/reek.vim
After:
Restore
call ale#linter#Reset()
Execute(The reek handler should parse JSON correctly, with only context enabled):
let g:ale_ruby_reek_show_context = 1
let g:ale_ruby_reek_show_wiki_link = 0
AssertEqual
\ [
@@ -34,9 +41,6 @@ Execute(The reek handler should parse JSON correctly, with only context enabled)
\ ])
Execute(The reek handler should parse JSON correctly, with no context or wiki links):
let g:ale_ruby_reek_show_context = 0
let g:ale_ruby_reek_show_wiki_link = 0
AssertEqual
\ [
\ {

View File

@@ -30,4 +30,3 @@ Execute(Warning and error messages should be handled correctly):
\ 'test.robot:W:1:2:RequireSuiteDocumentation:No suite documentation',
\ 'test.robot:E:3:4:RequireTestDocumentation:No testcase documentation'
\])

View File

@@ -2,7 +2,6 @@ Before:
runtime ale_linters/ruby/rubocop.vim
After:
unlet! g:lines
call ale#linter#Reset()
Execute(The rubocop handler should parse lines correctly):
@@ -59,18 +58,6 @@ Execute(The rubocop handler should handle when no files are checked):
\ '{"metadata":{"rubocop_version":"0.47.1","ruby_engine":"ruby","ruby_version":"2.1.5","ruby_patchlevel":"273","ruby_platform":"x86_64-linux-gnu"},"files":[],"summary":{"offense_count":0,"target_file_count":0,"inspected_file_count":0}}'
\ ])
Execute(The rubocop handler should handle output without any errors):
let g:lines = [
\ '{"metadata":{"rubocop_version":"0.48.1","ruby_engine":"ruby","ruby_version":"2.4.1","ruby_patchlevel":"111","ruby_platform":"x86_64-darwin16"},"files":[]}',
\]
AssertEqual
\ [],
\ ale#ruby#HandleRubocopOutput(347, g:lines)
\
AssertEqual
\ [],
\ ale#ruby#HandleRubocopOutput(347, ['{}'])
AssertEqual
\ [],
\ ale#ruby#HandleRubocopOutput(347, [])
Execute(The rubocop handler should handle empty output):
AssertEqual [], ale#ruby#HandleRubocopOutput(347, ['{}'])
AssertEqual [], ale#ruby#HandleRubocopOutput(347, [])

View File

@@ -1,3 +1,11 @@
Before:
Save g:ale_rust_ignore_secondary_spans
let g:ale_rust_ignore_secondary_spans = 0
After:
Restore
Execute(The Rust handler should handle rustc output):
call ale#test#SetFilename('src/playpen.rs')
@@ -340,7 +348,6 @@ Execute(The Rust handler should find correct files):
Execute(The Rust handler should remove secondary spans if set):
call ale#test#SetFilename('src/noerrors/mod.rs')
let g:ale_rust_ignore_secondary_spans = 0
AssertEqual
\ [
\ {
@@ -416,6 +423,7 @@ Execute(The Rust handler should remove secondary spans if set):
\ ])
let g:ale_rust_ignore_secondary_spans = 1
AssertEqual
\ [
\ {

View File

@@ -1,13 +1,10 @@
After:
call ale#linter#Reset()
Execute(The handler should return an empty list with empty input):
AssertEqual [], ale#handlers#scala#HandleScalacLintFormat(bufnr(''), [])
Execute(The handler should correctly parse error messages):
AssertEqual
AssertEqual
\ [
\ {
\ {
\ 'lnum': 4,
\ 'col': 8,
\ 'text': ''':'' expected but identifier found.',

View File

@@ -6,7 +6,6 @@ After:
call ale#linter#Reset()
Execute(The slim handler should parse lines correctly):
AssertEqual
\ [
\ {

View File

@@ -2,8 +2,6 @@ Before:
runtime ale_linters/sql/sqlfluff.vim
After:
Restore
call ale#linter#Reset()
Execute(The sqlfluff handler should handle basic warnings):

View File

@@ -37,5 +37,4 @@ Execute(textlint handler should handle errors output):
Execute(textlint handler should no error output):
AssertEqual
\ [],
\ ale#handlers#textlint#HandleTextlintOutput(bufnr(''), [
\ ])
\ ale#handlers#textlint#HandleTextlintOutput(bufnr(''), [])

View File

@@ -4,32 +4,6 @@ Before:
After:
call ale#linter#Reset()
Execute(The tflint handler should parse items correctly for pre 0.11):
AssertEqual
\ [
\ {
\ 'lnum': 12,
\ 'text': 'be warned, traveller',
\ 'code': 'aws_db_instance_readable_password',
\ 'type': 'W',
\ },
\ {
\ 'lnum': 9,
\ 'text': 'error message',
\ 'code': 'aws_elasticache_cluster_invalid_type',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 5,
\ 'text': 'just so ya know',
\ 'code': 'aws_instance_not_specified_iam_profile',
\ 'type': 'I',
\ },
\ ],
\ ale_linters#terraform#tflint#Handle(123, [
\ '[ { "detector": "aws_db_instance_readable_password", "type": "WARNING", "message": "be warned, traveller", "line": 12, "file": "github.com/wata727/example-module/aws_db_instance.tf", "link": "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md" }, { "detector": "aws_elasticache_cluster_invalid_type", "type": "ERROR", "message": "error message", "line": 9, "file": "github.com/wata727/example-module/aws_elasticache_cluster.tf", "link": "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_invalid_type.md" }, { "detector": "aws_instance_not_specified_iam_profile", "type": "NOTICE", "message": "just so ya know", "line": 5, "file": "github.com/wata727/example-module/aws_instance.tf", "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_not_specified_iam_profile.md" } ]'
\ ])
Execute(The tflint handler should parse items correctly):
AssertEqual
\ [

View File

@@ -1,8 +1,8 @@
Before:
runtime ale_linters/thrift/thrift.vim
runtime ale_linters/thrift/thrift.vim
After:
call ale#linter#Reset()
call ale#linter#Reset()
Execute(The thrift handler should handle basic warnings and errors):
AssertEqual

View File

@@ -1,8 +1,8 @@
Before:
runtime ale_linters/thrift/thriftcheck.vim
runtime ale_linters/thrift/thriftcheck.vim
After:
call ale#linter#Reset()
call ale#linter#Reset()
Execute(The thriftcheck handler should handle basic warnings and errors):
AssertEqual

View File

@@ -4,7 +4,6 @@ Before:
After:
call ale#linter#Reset()
Execute (The verilator handler should parse legacy messages with only line numbers):
AssertEqual
\ [
@@ -26,7 +25,6 @@ Execute (The verilator handler should parse legacy messages with only line numbe
\ '%Warning-BLKSEQ: bar.v:10: Blocking assignments (=) in sequential (flop or latch) block; suggest delayed assignments (<=).',
\ ])
Execute (The verilator handler should parse new format messages with line and column numbers):
AssertEqual
\ [
@@ -49,4 +47,3 @@ Execute (The verilator handler should parse new format messages with line and co
\ '%Error: bar.v:3:1: syntax error, unexpected endmodule, expecting ;',
\ '%Warning-UNUSED: foo.v:4:6: Signal is not used: r',
\ ])

View File

@@ -9,8 +9,6 @@ After:
call ale#test#RestoreDirectory()
call ale#linter#Reset()
silent file something_else.py
Execute(Basic vulture check with relative path in result should be handled):
call ale#test#SetFilename('something_else.py')
AssertEqual