summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-12 11:35:14 +0000
committerw0rp <devw0rp@gmail.com>2017-11-12 11:35:14 +0000
commit5b3094558bb8e890404c2ea8e65f0fc9a520a322 (patch)
tree5261596fe241c24b6e1550e04f74db8f6dab9ce3 /test
parent0741612db704b05e6c8da680865febe96d88759b (diff)
parent7edcb2210b2b60d5eaf81381e5d9443369576c28 (diff)
downloadale-5b3094558bb8e890404c2ea8e65f0fc9a520a322.zip
Merge branch 'zanona-less-lessc-linter'
Diffstat (limited to 'test')
-rwxr-xr-xtest/command_callback/lessc_paths/node_modules/.bin/lessc0
-rw-r--r--test/command_callback/test_lessc_command_callback.vader82
-rw-r--r--test/handler/test_lessc_handler.vader69
3 files changed, 151 insertions, 0 deletions
diff --git a/test/command_callback/lessc_paths/node_modules/.bin/lessc b/test/command_callback/lessc_paths/node_modules/.bin/lessc
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/lessc_paths/node_modules/.bin/lessc
diff --git a/test/command_callback/test_lessc_command_callback.vader b/test/command_callback/test_lessc_command_callback.vader
new file mode 100644
index 00000000..785c38c0
--- /dev/null
+++ b/test/command_callback/test_lessc_command_callback.vader
@@ -0,0 +1,82 @@
+Before:
+ Save g:ale_less_lessc_executable
+ Save g:ale_less_lessc_use_global
+ Save g:ale_less_lessc_options
+
+ unlet! b:executable
+
+ unlet! g:ale_less_lessc_executable
+ unlet! g:ale_less_lessc_use_global
+ unlet! g:ale_less_lessc_options
+
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#test#SetFilename('testfile.less')
+
+ runtime ale_linters/less/lessc.vim
+
+After:
+ Restore
+
+ unlet! b:executable
+ unlet! b:ale_less_lessc_executable
+ unlet! b:ale_less_lessc_use_global
+ unlet! b:ale_less_lessc_options
+
+ call ale#test#SetFilename('test.txt')
+
+ call ale#test#RestoreDirectory()
+ call ale#linter#Reset()
+
+Execute(node_modules directories should be discovered):
+ call ale#test#SetFilename('lessc_paths/nested/testfile.less')
+
+ let b:executable = ale#path#Winify(
+ \ g:dir
+ \ . '/lessc_paths/node_modules/.bin/lessc'
+ \)
+
+ AssertEqual
+ \ b:executable,
+ \ ale_linters#less#lessc#GetExecutable(bufnr(''))
+
+ AssertEqual
+ \ ale#Escape(b:executable)
+ \ . ' --no-color --lint'
+ \ . ' --include-path='
+ \ . ale#Escape(ale#path#Winify(g:dir . '/lessc_paths/nested'))
+ \ . ' -',
+ \ ale_linters#less#lessc#GetCommand(bufnr(''))
+
+Execute(The global override should work):
+ let b:ale_less_lessc_executable = 'foobar'
+ let b:ale_less_lessc_use_global = 1
+
+ call ale#test#SetFilename('lessc_paths/nested/testfile.less')
+
+ AssertEqual
+ \ 'foobar',
+ \ ale_linters#less#lessc#GetExecutable(bufnr(''))
+
+ AssertEqual
+ \ ale#Escape('foobar')
+ \ . ' --no-color --lint'
+ \ . ' --include-path='
+ \ . ale#Escape(ale#path#Winify(g:dir . '/lessc_paths/nested'))
+ \ . ' -',
+ \ ale_linters#less#lessc#GetCommand(bufnr(''))
+
+Execute(Extra options should be configurable):
+ let b:ale_less_lessc_options = '--whatever'
+
+ AssertEqual
+ \ 'lessc',
+ \ ale_linters#less#lessc#GetExecutable(bufnr(''))
+
+ AssertEqual
+ \ ale#Escape('lessc')
+ \ . ' --no-color --lint'
+ \ . ' --include-path='
+ \ . ale#Escape(ale#path#Winify(g:dir))
+ \ . ' --whatever'
+ \ . ' -',
+ \ ale_linters#less#lessc#GetCommand(bufnr(''))
diff --git a/test/handler/test_lessc_handler.vader b/test/handler/test_lessc_handler.vader
new file mode 100644
index 00000000..530c5824
--- /dev/null
+++ b/test/handler/test_lessc_handler.vader
@@ -0,0 +1,69 @@
+Before:
+ call ale#test#SetDirectory('/testplugin/test/handler')
+ call ale#test#SetFilename('testfile.less')
+
+ runtime ale_linters/less/lessc.vim
+
+After:
+ call ale#test#RestoreDirectory()
+ call ale#linter#Reset()
+
+Execute(The lessc handler should handle errors for the current file correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 2,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'text': 'Unrecognised input. Possibly missing something',
+ \ },
+ \ ],
+ \ ale_linters#less#lessc#Handle(bufnr(''), [
+ \ 'ParseError: Unrecognised input. Possibly missing something in - on line 2, column 1:',
+ \ '1 vwewww',
+ \ '2 ',
+ \])
+
+Execute(The lessc handler should handle errors for other files in the same directory correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 2,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'text': 'Unrecognised input. Possibly missing something',
+ \ 'filename': ale#path#Winify(g:dir . '/imported.less')
+ \ },
+ \ {
+ \ 'lnum': 2,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'text': 'Unrecognised input. Possibly missing something',
+ \ 'filename': ale#path#Winify(g:dir . '/imported.less')
+ \ },
+ \ ],
+ \ ale_linters#less#lessc#Handle(bufnr(''), [
+ \ 'ParseError: Unrecognised input. Possibly missing something in imported.less on line 2, column 1:',
+ \ '1 vwewww',
+ \ '2 ',
+ \ 'ParseError: Unrecognised input. Possibly missing something in ./imported.less on line 2, column 1:',
+ \ '1 vwewww',
+ \ '2 ',
+ \])
+
+Execute(The lessc handler should handle errors for files in directories above correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 2,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'text': 'Unrecognised input. Possibly missing something',
+ \ 'filename': ale#path#Winify(g:dir . '/../imported2.less')
+ \ },
+ \ ],
+ \ ale_linters#less#lessc#Handle(bufnr(''), [
+ \ 'ParseError: Unrecognised input. Possibly missing something in ../imported2.less on line 2, column 1:',
+ \ '1 vwewww',
+ \ '2 ',
+ \])