summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Houston <houstdav000@gmail.com>2021-11-11 17:34:25 -0500
committerGitHub <noreply@github.com>2021-11-12 07:34:25 +0900
commita9d7f45924b97a5244fb626dd9ae0bf934ca1ee6 (patch)
tree92469b20ab095a1742fa84f5782b479606824caa /test
parent8b3b16d71c4c683da6f3ca39662d207a3e894901 (diff)
downloadale-a9d7f45924b97a5244fb626dd9ae0bf934ca1ee6.zip
Implement statix Linter and Fixer (#3969)
* Add Statix for Linting Add `statix check` as a linter. Provides a simple set of definition tests additionally. Variable names specify "check" to allow for later addition of `statix fix` as a formatter once stream support is added. Signed-off-by: David Houston <houstdav000@gmail.com> * Fixup Supported Tools List I didn't realise there were two separate lists of tools, so add statix to the other list. Also, remembered "S" comes after "R", and so re-ordered it. Signed-off-by: David Houston <houstdav000@gmail.com> * Fix statix Test File I refactored the variables for statix to allow for writing a fixer later, and forgot to update them in the test, so update them now. Also remove a stray "i", add missing space before checks Signed-off-by: David Houston <houstdav000@gmail.com> * Update Output Stream for v0.4.0 statix v0.4.0 provides a breaking change of output stream from stderr to stdout. Signed-off-by: David Houston <houstdav000@gmail.com> * Add statix fix Fixer Implement statix fix as a fixer for simple Nix antipatterns. Signed-off-by: David Houston <houstdav000@gmail.com> * Fix statix Fixer Tests Fix the statix fixer tests by removing the unnecessary 'read_temporary_file' value from the command, since it simply uses the default value. Signed-off-by: David Houston <houstdav000@gmail.com> * Add statix Handler Test Add a test for the statix handler per @hsanson's request. Signed-off-by: David Houston <houstdav000@gmail.com> * Fix to run only on stdin for linting Signed-off-by: David Houston <houstdav000@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/fixers/test_statix_fixer.vader18
-rw-r--r--test/handler/test_statix_handler.vader16
-rw-r--r--test/linter/test_nix_statix.vader19
3 files changed, 53 insertions, 0 deletions
diff --git a/test/fixers/test_statix_fixer.vader b/test/fixers/test_statix_fixer.vader
new file mode 100644
index 00000000..c55365a6
--- /dev/null
+++ b/test/fixers/test_statix_fixer.vader
@@ -0,0 +1,18 @@
+Before:
+ call ale#assert#SetUpFixerTest('nix', 'statix')
+
+After:
+ call ale#assert#TearDownFixerTest()
+
+Execute(The callback should return the correct default values):
+ AssertFixer { 'command': ale#Escape('statix') . ' fix --stdin' }
+
+Execute(The callback should include a custom runtime):
+ let g:ale_nix_statix_fix_executable = 'foo/bar'
+
+ AssertFixer { 'command': ale#Escape('foo/bar') . ' fix --stdin' }
+
+Execute(The callback should include custom options):
+ let g:ale_nix_statix_fix_options = '--foobar'
+
+ AssertFixer { 'command': ale#Escape('statix') . ' fix --stdin --foobar' }
diff --git a/test/handler/test_statix_handler.vader b/test/handler/test_statix_handler.vader
new file mode 100644
index 00000000..f2a105ee
--- /dev/null
+++ b/test/handler/test_statix_handler.vader
@@ -0,0 +1,16 @@
+Execute(The statix handler should handle statix output):
+ call ale#test#SetFilename('flake.nix')
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 46,
+ \ 'type': 'W',
+ \ 'col': 13,
+ \ 'code': '3',
+ \ 'text': 'This assignment is better written with `inherit`'
+ \ },
+ \ ],
+ \ ale#handlers#statix#Handle(bufnr(''),
+ \ '<stdin>>46:13:W:3:This assignment is better written with `inherit`'
+ \)
diff --git a/test/linter/test_nix_statix.vader b/test/linter/test_nix_statix.vader
new file mode 100644
index 00000000..8ee4c027
--- /dev/null
+++ b/test/linter/test_nix_statix.vader
@@ -0,0 +1,19 @@
+Before:
+ call ale#assert#SetUpLinterTest('nix', 'statix')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The statix command should be correct):
+ AssertLinter 'statix', ale#Escape('statix') . ' check -o errfmt --stdin'
+
+Execute(Additional statix options should be configurable):
+ let g:ale_nix_statix_check_options = '--foobar'
+
+ AssertLinter 'statix',
+ \ ale#Escape('statix') . ' check -o errfmt --stdin --foobar'
+
+Execute(The statix command should be configurable):
+ let g:ale_nix_statix_check_executable = 'foo/bar'
+
+ AssertLinter 'foo/bar', ale#Escape('foo/bar') . ' check -o errfmt --stdin'