summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Houston <houstdav000@gmail.com>2021-11-18 17:41:05 -0500
committerGitHub <noreply@github.com>2021-11-19 07:41:05 +0900
commitea643b97ab08e571a543f4bd89cd3170f3f288e2 (patch)
treef701724bf0911b445107fc5caa23d6d1503de260 /test
parentaee0cc45bea7f190c27f0fc06f98a465ecff56fa (diff)
downloadale-ea643b97ab08e571a543f4bd89cd3170f3f288e2.zip
Add cspell Linter (#3981)
* Add cspell linter Add cspell linter, with the languages it supports. Signed-off-by: David Houston <houstdav000@gmail.com> * Add cspell Global Variables Documentation Add documentation to /doc/ale.txt with cspell configuration options. Signed-off-by: David Houston <houstdav000@gmail.com> * Add cspell to docs, Minor Cleanup Add cspell for each supported language, adding some spaces and removing others when caught navigating the file. Signed-off-by: David Houston <houstdav000@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/handler/test_cspell_handler.vader13
-rw-r--r--test/linter/test_cspell.vader69
-rwxr-xr-xtest/test-files/cspell/node-modules-2/node_modules/cspell/bin.js0
-rwxr-xr-xtest/test-files/cspell/node-modules/node_modules/.bin/cspell0
4 files changed, 82 insertions, 0 deletions
diff --git a/test/handler/test_cspell_handler.vader b/test/handler/test_cspell_handler.vader
new file mode 100644
index 00000000..b74b8d22
--- /dev/null
+++ b/test/handler/test_cspell_handler.vader
@@ -0,0 +1,13 @@
+Execute(The cspell handler should handle cspell output):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 721,
+ \ 'col': 18,
+ \ 'type': 'W',
+ \ 'text': 'Unknown word (stylelint)',
+ \ },
+ \ ],
+ \ ale#handlers#cspell#Handle(bufnr(''),
+ \ '/:721:18 - Unknown word (stylelint)'
+ \)
diff --git a/test/linter/test_cspell.vader b/test/linter/test_cspell.vader
new file mode 100644
index 00000000..7a72be44
--- /dev/null
+++ b/test/linter/test_cspell.vader
@@ -0,0 +1,69 @@
+Before:
+ call ale#assert#SetUpLinterTest('tex', 'cspell')
+
+ " We have to manually do our own variable reset because SetUpLinterTest calls
+ " ale#assert#ResetVariables, which specifically only resets variables that
+ " begin with ale_<filetype>_, per https://github.com/dense-analysis/ale/blob/76c2293e68a6cad3b192062743d25b8daa082205/autoload/ale/assert.vim#L256
+ "
+ " Took a lot of debugging and reading both junegunn/vader.vim and most ALE
+ " files to find this behavior
+
+ Save g:ale_cspell_executable
+ Save g:ale_cspell_use_global
+ Save g:ale_cspell_options
+
+ unlet! g:ale_cspell_executable
+ unlet! g:ale_cspell_use_global
+ unlet! g:ale_cspell_options
+
+ let g:ale_cspell_executable = 'cspell'
+ let g:ale_cspell_use_global = 0
+ let g:ale_cspell_options = ''
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The global executable should be used when the local one cannot be found):
+ AssertLinter
+ \ 'cspell',
+ \ ale#Escape('cspell')
+ \ . ' lint --no-color --no-progress --no-summary -- stdin'
+
+Execute(Should use the node_modules/.bin executable if available):
+ call ale#test#SetFilename('../test-files/cspell/node-modules/test.tex')
+
+ AssertLinter
+ \ ale#path#Simplify(g:dir
+ \ . '/../test-files/cspell/node-modules/node_modules/.bin/cspell'),
+ \ ale#Escape(ale#path#Simplify(g:dir
+ \ . '/../test-files/cspell/node-modules/node_modules/.bin/cspell'))
+ \ . ' lint --no-color --no-progress --no-summary -- stdin'
+
+Execute(Should use the node_modules/cspell executable if available):
+ call ale#test#SetFilename('../test-files/cspell/node-modules-2/test.tex')
+
+ AssertLinter
+ \ ale#path#Simplify(g:dir
+ \ . '/../test-files/cspell/node-modules-2/node_modules/cspell/bin.js'),
+ \ (has('win32') ? 'node.exe ': '')
+ \ . ale#Escape(ale#path#Simplify(g:dir
+ \ . '/../test-files/cspell/node-modules-2/node_modules/cspell/bin.js'))
+ \ . ' lint --no-color --no-progress --no-summary -- stdin'
+
+Execute(Should let users configure a global executable and override local paths):
+ let g:ale_cspell_executable = '/path/to/custom/cspell'
+ let g:ale_cspell_use_global = 1
+
+ AssertLinter
+ \ '/path/to/custom/cspell',
+ \ ale#Escape('/path/to/custom/cspell')
+ \ . ' lint --no-color --no-progress --no-summary -- stdin'
+
+Execute(Additional cspell options should be configurable):
+ let g:ale_cspell_options = '--foobar'
+
+ AssertLinter
+ \ 'cspell',
+ \ ale#Escape('cspell')
+ \ . ' lint --no-color --no-progress --no-summary --foobar -- stdin'
+
diff --git a/test/test-files/cspell/node-modules-2/node_modules/cspell/bin.js b/test/test-files/cspell/node-modules-2/node_modules/cspell/bin.js
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/test/test-files/cspell/node-modules-2/node_modules/cspell/bin.js
diff --git a/test/test-files/cspell/node-modules/node_modules/.bin/cspell b/test/test-files/cspell/node-modules/node_modules/.bin/cspell
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/test/test-files/cspell/node-modules/node_modules/.bin/cspell