diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2024-12-28 07:32:08 +0800 |
|---|---|---|
| committer | zeertzjq <zeertzjq@outlook.com> | 2025-02-04 06:45:25 +0800 |
| commit | 89c294514853ee4849855f880d6d7ff349494c4d (patch) | |
| tree | c9e47794be4f9f2c0afc1f43b0d6dbfb5832f8df /test | |
| parent | d7426bc9e99a44e5c79a3645aa74fc2a300e3ae6 (diff) | |
| download | rneovim-89c294514853ee4849855f880d6d7ff349494c4d.tar.gz rneovim-89c294514853ee4849855f880d6d7ff349494c4d.tar.bz2 rneovim-89c294514853ee4849855f880d6d7ff349494c4d.zip | |
vim-patch:9.1.0967: SpotBugs compiler setup can be further improved
Problem: SpotBugs compiler can be further improved
Solution: Introduce event-driven primitives for SpotBugs
(Aliaksei Budavei)
closes: vim/vim#16258
https://github.com/vim/vim/commit/2e252474c4df5018b9819d86ebb70bf3b1b1a1af
Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/old/testdir/test_compiler.vim | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/test/old/testdir/test_compiler.vim b/test/old/testdir/test_compiler.vim index e6d5e57824..f9e7bf042d 100644 --- a/test/old/testdir/test_compiler.vim +++ b/test/old/testdir/test_compiler.vim @@ -399,12 +399,22 @@ func Test_compiler_spotbugs_properties() endfunc defer execute('delfunction g:SpotBugsPostCommand') + func! g:SpotBugsPostCompilerActionExecutor(action) abort + try + " XXX: Notify the spotbugs compiler about success or failure. + cc + catch /\<E42:/ + execute a:action + endtry + endfunc + defer execute('delfunction g:SpotBugsPostCompilerActionExecutor') + " TEST INTEGRATION WITH A SUPPORTED COMPILER PLUGIN. if filereadable($VIMRUNTIME .. '/compiler/maven.vim') if !executable('mvn') if has('win32') " This is what ":help executable()" suggests. - call writefile([], 'Xspotbugs/mvn.exe') + call writefile([], 'Xspotbugs/mvn.cmd') else let $PATH = 'Xspotbugs:' .. $PATH call writefile([], 'Xspotbugs/mvn') @@ -590,6 +600,8 @@ func Test_compiler_spotbugs_properties() \ 'DefaultPreCompilerTestCommand': function('g:SpotBugsPreTestCommand'), \ 'DefaultPreCompilerCommand': function('g:SpotBugsPreCommand'), \ 'DefaultPostCompilerCommand': function('g:SpotBugsPostCommand'), + \ 'PostCompilerActionExecutor': function('g:SpotBugsPostCompilerActionExecutor'), + \ 'augroupForPostCompilerAction': 'java_spotbugs_test', \ 'sourceDirPath': ['Xspotbugs/src'], \ 'classDirPath': ['Xspotbugs/src'], \ 'testSourceDirPath': ['tests'], @@ -636,6 +648,56 @@ func Test_compiler_spotbugs_properties() call assert_match('^spotbugs\s', &l:makeprg) endif + setlocal makeprg= + let s:spotbugs_results.preActionDone = 0 + let s:spotbugs_results.preTestActionOtherDone = 0 + let s:spotbugs_results.preTestLocalActionDone = 0 + let s:spotbugs_results.postActionDone = 0 + let s:spotbugs_results.preCommandArguments = '' + let s:spotbugs_results.preTestCommandArguments = '' + let s:spotbugs_results.postCommandArguments = '' + + " When "PostCompilerActionExecutor", "Pre*Action" and/or "Pre*TestAction", + " and "Post*Action" are available, "#java_spotbugs_post" must be defined. + call assert_true(exists('#java_spotbugs_post')) + call assert_true(exists('#java_spotbugs_post#User')) + call assert_false(exists('#java_spotbugs_post#ShellCmdPost')) + call assert_false(exists('#java_spotbugs_test#ShellCmdPost')) + + " Re-link a Funcref on the fly. + func! g:SpotBugsPreTestCommand(arguments) abort + let s:spotbugs_results.preTestActionOtherDone = 1 + let s:spotbugs_results.preTestCommandArguments = a:arguments + " Define a once-only ":autocmd" for "#java_spotbugs_test#ShellCmdPost". + doautocmd java_spotbugs_post User + " XXX: Do NOT use ":cc" to notify the spotbugs compiler about success or + " failure, and assume the transfer of control to a ShellCmdPost command. + endfunc + + doautocmd java_spotbugs User + " No match: "test_file !~# 'Xspotbugs/src'". + call assert_false(s:spotbugs_results.preActionDone) + call assert_true(empty(s:spotbugs_results.preCommandArguments)) + " A match: "test_file =~# 'tests'". + call assert_true(s:spotbugs_results.preTestActionOtherDone) + call assert_equal('test-compile', s:spotbugs_results.preTestCommandArguments) + " For a pre-match, no post-action (without ":cc") UNLESS a ShellCmdPost + " event is consumed whose command will invoke "PostCompilerActionExecutor" + " and the latter will accept a post-compiler action argument. + call assert_false(s:spotbugs_results.postActionDone) + call assert_true(exists('#java_spotbugs_test#ShellCmdPost')) + doautocmd ShellCmdPost + call assert_false(exists('#java_spotbugs_test#ShellCmdPost')) + call assert_true(s:spotbugs_results.postActionDone) + call assert_equal('%:S', s:spotbugs_results.postCommandArguments) + + " With a match, confirm that ":compiler spotbugs" has run. + if has('win32') + call assert_match('^spotbugs\.bat\s', &l:makeprg) + else + call assert_match('^spotbugs\s', &l:makeprg) + endif + bwipeout setlocal makeprg= endif |