mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-10 05:22:31 +08:00
Merge pull request #952 from hernot/master
Add mcsc for checking C# code.
This commit is contained in:
34
test/command_callback/test_cs_mcs_command_callbacks.vader
Normal file
34
test/command_callback/test_cs_mcs_command_callbacks.vader
Normal file
@@ -0,0 +1,34 @@
|
||||
Before:
|
||||
Save g:ale_cs_mcs_options
|
||||
|
||||
unlet! g:ale_cs_mcs_options
|
||||
|
||||
runtime ale_linters/cs/mcs.vim
|
||||
|
||||
let b:command_tail = ' -unsafe --parse'
|
||||
|
||||
After:
|
||||
Restore
|
||||
unlet! b:command_tail
|
||||
unlet! b:ale_cs_mcs_options
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(Check for proper default command):
|
||||
|
||||
let b:command = ale_linters#cs#mcs#GetCommand(bufnr(''))
|
||||
let b:command = substitute(b:command,'\s\+',' ','g')
|
||||
|
||||
AssertEqual
|
||||
\ b:command,
|
||||
\ 'mcs -unsafe --parse %t'
|
||||
|
||||
Execute(The options should be be used in the command):
|
||||
|
||||
let b:ale_cs_mcs_options = '-pkg:dotnet'
|
||||
let b:command = ale_linters#cs#mcs#GetCommand(bufnr(''))
|
||||
let b:command = substitute(b:command,'\s\+',' ','g')
|
||||
|
||||
AssertEqual
|
||||
\ b:command,
|
||||
\ 'mcs' . b:command_tail . ' ' . b:ale_cs_mcs_options . ' %t',
|
||||
|
||||
120
test/command_callback/test_cs_mcsc_command_callbacks.vader
Normal file
120
test/command_callback/test_cs_mcsc_command_callbacks.vader
Normal file
@@ -0,0 +1,120 @@
|
||||
Before:
|
||||
Save g:ale_cs_mcsc_options
|
||||
Save g:ale_cs_mcsc_source
|
||||
Save g:ale_cs_mcsc_assembly_path
|
||||
Save g:ale_cs_mcsc_assemblies
|
||||
|
||||
unlet! g:ale_cs_mcsc_options
|
||||
unlet! g:ale_cs_mcsc_source
|
||||
unlet! g:ale_cs_mcsc_assembly_path
|
||||
unlet! g:ale_cs_mcsc_assemblies
|
||||
|
||||
let g:temppath = fnamemodify(tempname(), ':p:h')
|
||||
let g:temppathpattern = substitute(escape(g:temppath, '\\/.*$^~[]'), '[\\/]*$', '[\\\\/]\\+\\S\\+','')
|
||||
let g:sometempfile = fnamemodify(g:temppath .'/some_temp_file.tmp', ':p')
|
||||
|
||||
runtime ale_linters/cs/mcsc.vim
|
||||
|
||||
After:
|
||||
Restore
|
||||
unlet! b:ale_cs_mcsc_options
|
||||
unlet! g:ale_cs_mcsc_source
|
||||
unlet! g:ale_cs_mcsc_assembly_path
|
||||
unlet! g:ale_cs_mcsc_assemblies
|
||||
unlet! g:temppath
|
||||
unlet! g:temppathpattern
|
||||
unlet! g:sometempfile
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(Check for proper default command):
|
||||
|
||||
let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
|
||||
let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
|
||||
let b:command = substitute(b:command, '\s\+', ' ', 'g')
|
||||
|
||||
AssertEqual
|
||||
\ b:command,
|
||||
\ 'cd ".";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
|
||||
|
||||
Execute(The options should be be used in the command):
|
||||
|
||||
let g:ale_cs_mcsc_options = '-pkg:dotnet'
|
||||
|
||||
let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
|
||||
let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
|
||||
let b:command = substitute(b:command, '\s\+', ' ', 'g')
|
||||
|
||||
AssertEqual
|
||||
\ b:command,
|
||||
\ 'cd ".";mcs -unsafe ' . g:ale_cs_mcsc_options . ' -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
|
||||
|
||||
Execute(The souce path should be be used in the command):
|
||||
call ale#engine#Cleanup(bufnr(''))
|
||||
call ale#engine#InitBufferInfo(bufnr(''))
|
||||
|
||||
let g:ale_cs_mcsc_source='../foo/bar'
|
||||
|
||||
let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
|
||||
let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
|
||||
let b:command = substitute(b:command, '\s\+', ' ', 'g')
|
||||
|
||||
AssertEqual
|
||||
\ b:command,
|
||||
\ 'cd "' . g:ale_cs_mcsc_source . '";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
|
||||
|
||||
Execute(The list of search pathes for assemblies should be be used in the command if not empty):
|
||||
call ale#engine#Cleanup(bufnr(''))
|
||||
call ale#engine#InitBufferInfo(bufnr(''))
|
||||
|
||||
let g:ale_cs_mcsc_assembly_path = [
|
||||
\ '/usr/lib/mono',
|
||||
\ '../foo/bar'
|
||||
\]
|
||||
|
||||
let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
|
||||
let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
|
||||
let b:command = substitute(b:command, '\s\+', ' ', 'g')
|
||||
|
||||
AssertEqual
|
||||
\ b:command,
|
||||
\ 'cd ".";mcs -unsafe -lib:"' . join(g:ale_cs_mcsc_assembly_path,'","') . '" -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
|
||||
|
||||
let g:ale_cs_mcsc_assembly_path = [
|
||||
\]
|
||||
|
||||
let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
|
||||
let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
|
||||
let b:command = substitute(b:command, '\s\+', ' ', 'g')
|
||||
|
||||
AssertEqual
|
||||
\ b:command,
|
||||
\ 'cd ".";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
|
||||
|
||||
Execute(The list of assemblies should be be used in the command if not empty):
|
||||
call ale#engine#Cleanup(bufnr(''))
|
||||
call ale#engine#InitBufferInfo(bufnr(''))
|
||||
|
||||
let g:ale_cs_mcsc_assemblies = [
|
||||
\ 'foo.dll',
|
||||
\ 'bar.dll'
|
||||
\]
|
||||
|
||||
let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
|
||||
let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
|
||||
let b:command = substitute(b:command,'\s\+',' ','g')
|
||||
|
||||
AssertEqual
|
||||
\ b:command,
|
||||
\ 'cd ".";mcs -unsafe -r:"' . join(g:ale_cs_mcsc_assemblies,'","') . '" -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
|
||||
|
||||
let g:ale_cs_mcsc_assemblies = [
|
||||
\]
|
||||
|
||||
let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
|
||||
let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
|
||||
let b:command = substitute(b:command,'\s\+',' ','g')
|
||||
|
||||
AssertEqual
|
||||
\ b:command,
|
||||
\ 'cd ".";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'
|
||||
|
||||
34
test/handler/test_mcs_handler.vader
Normal file
34
test/handler/test_mcs_handler.vader
Normal file
@@ -0,0 +1,34 @@
|
||||
Before:
|
||||
runtime ale_linters/cs/mcs.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The mcs handler should handle cannot find symbol errors):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 12,
|
||||
\ 'col' : 29,
|
||||
\ 'text': 'error CS1001: ; expected',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 101,
|
||||
\ 'col': 0,
|
||||
\ 'text': 'error CS1028: Unexpected processor directive (no #if for this #endif)',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 10,
|
||||
\ 'col': 12,
|
||||
\ 'text': 'warning CS0123: some warning',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#cs#mcs#Handle(347, [
|
||||
\ 'Tests.cs(12,29): error CS1001: ; expected',
|
||||
\ 'Tests.cs(101,0): error CS1028: Unexpected processor directive (no #if for this #endif)',
|
||||
\ 'Tests.cs(10,12): warning CS0123: some warning',
|
||||
\ 'Compilation failed: 2 error(s), 1 warnings',
|
||||
\ ])
|
||||
44
test/handler/test_mcsc_handler.vader
Normal file
44
test/handler/test_mcsc_handler.vader
Normal file
@@ -0,0 +1,44 @@
|
||||
Before:
|
||||
Save g:ale_cs_mcsc_source
|
||||
|
||||
unlet! g:ale_cs_mcsc_source
|
||||
|
||||
runtime ale_linters/cs/mcsc.vim
|
||||
|
||||
After:
|
||||
unlet! g:ale_cs_mcsc_source
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The mcs handler should handle cannot find symbol errors):
|
||||
let g:ale_cs_mcsc_source='/home/foo/project/bar'
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 12,
|
||||
\ 'col' : 29,
|
||||
\ 'text': 'error CS1001: ; expected',
|
||||
\ 'type': 'E',
|
||||
\ 'filename': '/home/foo/project/bar/Test.cs'
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 101,
|
||||
\ 'col': 0,
|
||||
\ 'text': 'error CS1028: Unexpected processor directive (no #if for this #endif)',
|
||||
\ 'type': 'E',
|
||||
\ 'filename': '/home/foo/project/bar/Test.cs'
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 10,
|
||||
\ 'col': 12,
|
||||
\ 'text': 'warning CS0123: some warning',
|
||||
\ 'type': 'W',
|
||||
\ 'filename': '/home/foo/project/bar/Test.cs'
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#cs#mcsc#Handle(347, [
|
||||
\ 'Test.cs(12,29): error CS1001: ; expected',
|
||||
\ 'Test.cs(101,0): error CS1028: Unexpected processor directive (no #if for this #endif)',
|
||||
\ 'Test.cs(10,12): warning CS0123: some warning',
|
||||
\ 'Compilation failed: 2 error(s), 1 warnings',
|
||||
\ ])
|
||||
Reference in New Issue
Block a user