summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/hdl_server/foo.vhd0
-rw-r--r--test/command_callback/hdl_server/with_config_file/.hdl_checker.config0
-rw-r--r--test/command_callback/hdl_server/with_config_file/_hdl_checker.config0
-rw-r--r--test/command_callback/hdl_server/with_config_file/foo.vhd0
-rw-r--r--test/command_callback/hdl_server/with_git/files/foo.vhd1
-rw-r--r--test/test_filetype_linter_defaults.vader2
-rw-r--r--test/test_hdl_checker_options.vader78
7 files changed, 80 insertions, 1 deletions
diff --git a/test/command_callback/hdl_server/foo.vhd b/test/command_callback/hdl_server/foo.vhd
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/hdl_server/foo.vhd
diff --git a/test/command_callback/hdl_server/with_config_file/.hdl_checker.config b/test/command_callback/hdl_server/with_config_file/.hdl_checker.config
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/hdl_server/with_config_file/.hdl_checker.config
diff --git a/test/command_callback/hdl_server/with_config_file/_hdl_checker.config b/test/command_callback/hdl_server/with_config_file/_hdl_checker.config
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/hdl_server/with_config_file/_hdl_checker.config
diff --git a/test/command_callback/hdl_server/with_config_file/foo.vhd b/test/command_callback/hdl_server/with_config_file/foo.vhd
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/hdl_server/with_config_file/foo.vhd
diff --git a/test/command_callback/hdl_server/with_git/files/foo.vhd b/test/command_callback/hdl_server/with_git/files/foo.vhd
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/test/command_callback/hdl_server/with_git/files/foo.vhd
@@ -0,0 +1 @@
+
diff --git a/test/test_filetype_linter_defaults.vader b/test/test_filetype_linter_defaults.vader
index 9c40cb23..95ec3b9a 100644
--- a/test/test_filetype_linter_defaults.vader
+++ b/test/test_filetype_linter_defaults.vader
@@ -61,7 +61,7 @@ Execute(The defaults for the zsh filetype should be correct):
Execute(The defaults for the verilog filetype should be correct):
" This filetype isn't configured with default, so we can test loading all
" available linters with this.
- AssertEqual ['iverilog', 'verilator', 'vlog', 'xvlog'], GetLinterNames('verilog')
+ AssertEqual ['hdl-checker', 'iverilog', 'verilator', 'vlog', 'xvlog'], GetLinterNames('verilog')
let g:ale_linters_explicit = 1
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