summaryrefslogtreecommitdiff
path: root/test/test_hdl_checker_options.vader
diff options
context:
space:
mode:
authorAndre Souto <suoto@users.noreply.github.com>2020-08-06 13:20:54 +0100
committerGitHub <noreply@github.com>2020-08-06 13:20:54 +0100
commit5b3da60cea542aa16c0bf9ea084242df834b2a7a (patch)
treeafdc70356691024f71d940d8a2310a4abd547820 /test/test_hdl_checker_options.vader
parent711c90c523bedcd644386e253d0840e0a9fc684e (diff)
downloadale-5b3da60cea542aa16c0bf9ea084242df834b2a7a.zip
Adds hdl_checker LSP support (#2804)
* Added hdl_checker support * Added hdl_checker tests HDL Checker searches for files when no config file is found, which could lead to very long searches when the user is not really on a project setting
Diffstat (limited to 'test/test_hdl_checker_options.vader')
-rw-r--r--test/test_hdl_checker_options.vader78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/test_hdl_checker_options.vader b/test/test_hdl_checker_options.vader
new file mode 100644
index 00000000..4bee0f55
--- /dev/null
+++ b/test/test_hdl_checker_options.vader
@@ -0,0 +1,78 @@
+Before:
+ call ale#assert#SetUpLinterTest('vhdl', 'hdl_checker')
+
+ Save g:ale_hdl_checker_config_file
+ Save g:ale_hdl_checker_options
+
+ let g:default_config_file = has('unix') ? '.hdl_checker.config' : '_hdl_checker.config'
+
+After:
+ Restore
+ call ale#assert#TearDownLinterTest()
+ unlet! g:default_config_file
+
+Execute(Get default initialization dict):
+ AssertEqual
+ \ {'project_file': g:default_config_file},
+ \ ale#handlers#hdl_checker#GetInitOptions(bufnr(''))
+
+Execute(Get custom initialization dict):
+ let g:ale_hdl_checker_config_file = 'some_file_name'
+
+ AssertEqual
+ \ {'project_file': 'some_file_name'},
+ \ ale#handlers#hdl_checker#GetInitOptions(bufnr(''))
+
+Execute(Get the checker command without extra user parameters):
+ AssertEqual
+ \ ale#Escape('hdl_checker') . ' --lsp',
+ \ ale#handlers#hdl_checker#GetCommand(bufnr(''))
+
+Execute(Get the checker command with user configured parameters):
+ let g:ale_hdl_checker_options = '--log-level DEBUG'
+
+ AssertEqual
+ \ ale#Escape('hdl_checker') . ' --lsp --log-level DEBUG',
+ \ ale#handlers#hdl_checker#GetCommand(bufnr(''))
+
+Execute(Customize executable):
+ let g:ale_hdl_checker_executable = '/some/other/path'
+ AssertEqual
+ \ ale#Escape('/some/other/path') . ' --lsp',
+ \ ale#handlers#hdl_checker#GetCommand(bufnr(''))
+
+Execute(Get project root based on .git):
+ call ale#test#SetFilename('hdl_server/with_git/files/foo.vhd')
+ " Create .git file
+ silent! call mkdir(g:dir . '/hdl_server/with_git/.git')
+ AssertNotEqual '', glob(g:dir . '/hdl_server/with_git/.git')
+
+ AssertEqual
+ \ ale#path#Simplify(g:dir . '/hdl_server/with_git'),
+ \ ale#handlers#hdl_checker#GetProjectRoot(bufnr(''))
+
+Execute(Get project root based on config file):
+ call ale#test#SetFilename('hdl_server/with_config_file/foo.vhd')
+
+ AssertEqual
+ \ ale#path#Simplify(g:dir . '/hdl_server/with_config_file'),
+ \ ale#handlers#hdl_checker#GetProjectRoot(bufnr(''))
+
+Execute(Return no project root if neither .git or config file are found):
+ let g:call_count = 0
+
+ " Mock this command to avoid the test to find ale's own .git folder
+ function! ale#handlers#hdl_checker#IsDotGit(path) abort
+ let g:call_count += 1
+ return 0
+ endfunction
+
+ call ale#test#SetFilename('hdl_server/foo.vhd')
+
+ AssertEqual
+ \ '',
+ \ ale#handlers#hdl_checker#GetProjectRoot(bufnr(''))
+
+ AssertEqual g:call_count, 1
+
+ unlet! g:call_count