summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/puppet/puppetlint.vim26
-rw-r--r--doc/ale-puppet.txt26
-rw-r--r--test/test_temporary_file_management.vader29
3 files changed, 64 insertions, 17 deletions
diff --git a/ale_linters/puppet/puppetlint.vim b/ale_linters/puppet/puppetlint.vim
index f96f8f79..902480d8 100644
--- a/ale_linters/puppet/puppetlint.vim
+++ b/ale_linters/puppet/puppetlint.vim
@@ -1,10 +1,26 @@
-" Author: Alexander Olofsson <alexander.olofsson@liu.se>
+" Author: Alexander Olofsson <alexander.olofsson@liu.se>, Robert Flechtner <flechtner@chemmedia.de>
+" Description: puppet-lint for puppet files
+
+let g:ale_puppet_puppetlint_executable =
+\ get(g:, 'ale_puppet_puppetlint_executable', 'puppet-lint')
+
+let g:ale_puppet_puppetlint_options =
+\ get(g:, 'ale_puppet_puppetlint_options', '--no-autoloader_layout-check')
+
+function! ale_linters#puppet#puppetlint#GetExecutable(buffer) abort
+ return g:ale_puppet_puppetlint_executable
+endfunction
+
+function! ale_linters#puppet#puppetlint#GetCommand(buffer) abort
+ return ale_linters#puppet#puppetlint#GetExecutable(a:buffer)
+ \ . ' ' . g:ale_puppet_puppetlint_options
+ \ . ' --log-format "-:%{line}:%{column}: %{kind}: [%{check}] %{message}"'
+ \ . ' %t'
+endfunction
call ale#linter#Define('puppet', {
\ 'name': 'puppetlint',
-\ 'executable': 'puppet-lint',
-\ 'command': 'puppet-lint --no-autoloader_layout-check'
-\ . ' --log-format "-:%{line}:%{column}: %{kind}: [%{check}] %{message}"'
-\ . ' %t',
+\ 'executable_callback': 'ale_linters#puppet#puppetlint#GetExecutable',
+\ 'command_callback': 'ale_linters#puppet#puppetlint#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\})
diff --git a/doc/ale-puppet.txt b/doc/ale-puppet.txt
new file mode 100644
index 00000000..1fd46e18
--- /dev/null
+++ b/doc/ale-puppet.txt
@@ -0,0 +1,26 @@
+===============================================================================
+ALE Puppet Integration *ale-puppet-options*
+
+
+-------------------------------------------------------------------------------
+puppetlint *ale-puppet-puppetlint*
+
+g:ale_puppet_puppetlint_executable *g:ale_puppet_puppetlint_executable*
+
+ Type: |String|
+ Default: `'puppet-lint'`
+
+ This variable can be changed to specify the executable used for puppet-lint.
+
+
+g:ale_puppet_puppetlint_options *g:ale_puppet_puppetlint_options*
+
+ Type: |String|
+ Default: `'--no-autoloader_layout-check'`
+
+ This variable can be changed to add command-line arguments to the
+ puppet-lint invocation.
+
+
+-------------------------------------------------------------------------------
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/test/test_temporary_file_management.vader b/test/test_temporary_file_management.vader
index b66f3d19..c8f379ab 100644
--- a/test/test_temporary_file_management.vader
+++ b/test/test_temporary_file_management.vader
@@ -1,22 +1,25 @@
Before:
let g:command = 'echo test'
- let g:filename = tempname()
- let g:directory = tempname()
- let g:preserved_directory = tempname()
+ let g:filename = ''
+ let g:directory = ''
+ let g:preserved_directory = ''
function! TestCommandCallback(buffer) abort
" We are registering a temporary file, so we should delete it.
+ let g:filename = tempname()
call writefile(['foo'], g:filename)
call ale#engine#ManageFile(a:buffer, g:filename)
" We are registering this directory appropriately, so we should delete
" the whole thing.
+ let g:directory = tempname()
call mkdir(g:directory)
call writefile(['foo'], g:directory . '/bar')
call ale#engine#ManageDirectory(a:buffer, g:directory)
" We are registering this directory as temporary file, so we
" shouldn't delete it.
+ let g:preserved_directory = tempname()
call mkdir(g:preserved_directory)
call writefile(['foo'], g:preserved_directory . '/bar')
call ale#engine#ManageFile(a:buffer, g:preserved_directory)
@@ -36,7 +39,9 @@ Before:
\})
After:
- call delete(g:preserved_directory, 'rf')
+ if !empty(g:preserved_directory)
+ call delete(g:preserved_directory, 'rf')
+ endif
unlet! g:command
unlet! g:filename
@@ -57,9 +62,9 @@ Execute(ALE should delete managed files/directories appropriately after linting)
call ale#Lint()
call ale#engine#WaitForJobs(2000)
- Assert !filereadable(g:filename), 'The tempoary file was not deleted'
- Assert !isdirectory(g:directory), 'The tempoary directory was not deleted'
- Assert isdirectory(g:preserved_directory), 'The tempoary directory was not kept'
+ Assert !filereadable(g:filename), 'The temporary file was not deleted'
+ Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
+ Assert isdirectory(g:preserved_directory), 'The temporary directory was not kept'
Execute(ALE should delete managed files even if no command is run):
AssertEqual 'foobar', &filetype
@@ -69,17 +74,17 @@ Execute(ALE should delete managed files even if no command is run):
call ale#Lint()
call ale#engine#WaitForJobs(2000)
- Assert !filereadable(g:filename), 'The tempoary file was not deleted'
- Assert !isdirectory(g:directory), 'The tempoary directory was not deleted'
- Assert isdirectory(g:preserved_directory), 'The tempoary directory was not kept'
+ Assert !filereadable(g:filename), 'The temporary file was not deleted'
+ Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
+ Assert isdirectory(g:preserved_directory), 'The temporary directory was not kept'
Execute(ALE should delete managed files when the buffer is removed):
call ale#engine#InitBufferInfo(bufnr('%'))
call TestCommandCallback(bufnr('%'))
call ale#cleanup#Buffer(bufnr('%'))
- Assert !filereadable(g:filename), 'The tempoary file was not deleted'
- Assert !isdirectory(g:directory), 'The tempoary directory was not deleted'
+ Assert !filereadable(g:filename), 'The temporary file was not deleted'
+ Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
Assert isdirectory(g:preserved_directory), 'The tempoary directory was not kept'
Execute(ALE should create and delete directories for ale#engine#CreateDirectory()):