summaryrefslogtreecommitdiff
path: root/test/command_callback/test_cs_mcsc_command_callbacks.vader
diff options
context:
space:
mode:
authorXristoph Hintermüller <christoph@out-world.com>2017-09-26 09:19:53 +0200
committerXristoph Hintermüller <christoph@out-world.com>2017-09-27 13:21:05 +0200
commit8f6044b8b64b608196a28b8125719be8736932bd (patch)
tree03fe4e437a4b7ace6244fee0ad4acf802c76976e /test/command_callback/test_cs_mcsc_command_callbacks.vader
parent0be77c60c59072a8895cde3fea38669391cff010 (diff)
downloadale-8f6044b8b64b608196a28b8125719be8736932bd.zip
Implemented review recommendations
Implements suggestions and recommendations suggested by the first review of the "Advance C# linter based on mcs -t:module (#952)" pull request. - Clarifies and simplifies description of linters and options - Added links to help file and marked the mcsc linter as to be run only when file in buffer is saved or loaded. - Added comments to the mcsc.vim file to clarify code - removed type checks considered not necessary be reviewer. - addresses findings by vader - removed call to getcwd and cd in vim script - handler expands file names relative to route of source tree into absolute pathes. Fixes errors not being marked when vim is started from subdirectory of source tree. - implements tests for mcs.vim and mcsc.vim linter
Diffstat (limited to 'test/command_callback/test_cs_mcsc_command_callbacks.vader')
-rw-r--r--test/command_callback/test_cs_mcsc_command_callbacks.vader120
1 files changed, 120 insertions, 0 deletions
diff --git a/test/command_callback/test_cs_mcsc_command_callbacks.vader b/test/command_callback/test_cs_mcsc_command_callbacks.vader
new file mode 100644
index 00000000..b513b655
--- /dev/null
+++ b/test/command_callback/test_cs_mcsc_command_callbacks.vader
@@ -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"'
+