2017-03-31 19:14:53 +00:00
|
|
|
Before:
|
2017-10-08 22:26:50 +00:00
|
|
|
call ale#test#SetDirectory('/testplugin/test/command_callback')
|
|
|
|
|
|
|
|
Save g:ale_java_javac_options
|
|
|
|
Save g:ale_java_javac_classpath
|
|
|
|
|
|
|
|
unlet! g:ale_java_javac_options
|
|
|
|
unlet! g:ale_java_javac_classpath
|
|
|
|
|
|
|
|
let g:cp_sep = has('unix') ? ':' : ';'
|
|
|
|
|
|
|
|
function! GetCommand(previous_output) abort
|
|
|
|
let l:command = ale_linters#java#javac#GetCommand(
|
|
|
|
\ bufnr(''),
|
|
|
|
\ a:previous_output
|
|
|
|
\)
|
|
|
|
|
|
|
|
let l:split_command = split(l:command)
|
|
|
|
let l:index = index(l:split_command, '-d')
|
|
|
|
|
|
|
|
let l:split_command[l:index + 1] = 'TEMP'
|
|
|
|
|
|
|
|
return join(l:split_command)
|
|
|
|
endfunction
|
|
|
|
|
2017-03-31 19:14:53 +00:00
|
|
|
runtime ale_linters/java/javac.vim
|
|
|
|
call ale#engine#InitBufferInfo(bufnr(''))
|
|
|
|
|
2017-10-08 22:26:50 +00:00
|
|
|
call ale#test#SetFilename('dummy.java')
|
2017-04-25 21:32:48 +00:00
|
|
|
|
2017-11-05 15:33:31 +00:00
|
|
|
let g:prefix = 'cd ' . ale#Escape(expand('%:p:h')) . ' && javac -Xlint'
|
|
|
|
|
2017-03-31 19:14:53 +00:00
|
|
|
After:
|
2017-10-08 22:26:50 +00:00
|
|
|
call ale#test#RestoreDirectory()
|
|
|
|
|
|
|
|
Restore
|
|
|
|
|
|
|
|
unlet! g:cp_sep
|
2017-11-05 15:33:31 +00:00
|
|
|
unlet! g:prefix
|
2017-10-08 22:26:50 +00:00
|
|
|
|
|
|
|
delfunction GetCommand
|
|
|
|
|
2017-03-31 19:14:53 +00:00
|
|
|
call ale#linter#Reset()
|
|
|
|
" We need to clean up the buffer to remove the temporary directories created
|
|
|
|
" for the command.
|
2017-07-07 22:47:41 +00:00
|
|
|
call ale#engine#Cleanup(bufnr(''))
|
2017-03-31 19:14:53 +00:00
|
|
|
|
|
|
|
Execute(The javac callback should return the correct default value):
|
2017-11-05 15:33:31 +00:00
|
|
|
AssertEqual g:prefix . ' -d TEMP %t', GetCommand([])
|
2017-03-31 19:14:53 +00:00
|
|
|
|
|
|
|
Execute(The javac callback should use g:ale_java_javac_classpath correctly):
|
|
|
|
let g:ale_java_javac_classpath = 'foo.jar'
|
|
|
|
|
2017-10-08 22:26:50 +00:00
|
|
|
AssertEqual
|
2017-11-05 15:33:31 +00:00
|
|
|
\ g:prefix
|
2017-10-08 22:26:50 +00:00
|
|
|
\ . ' -cp ' . ale#Escape('foo.jar')
|
|
|
|
\ . ' -d TEMP %t',
|
|
|
|
\ GetCommand([])
|
2017-04-25 21:32:48 +00:00
|
|
|
|
|
|
|
Execute(The javac callback should include discovered classpaths):
|
2017-10-08 22:26:50 +00:00
|
|
|
AssertEqual
|
2017-11-05 15:33:31 +00:00
|
|
|
\ g:prefix
|
|
|
|
\ . ' -cp '
|
2017-10-08 22:26:50 +00:00
|
|
|
\ . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep))
|
|
|
|
\ . ' -d TEMP %t',
|
|
|
|
\ GetCommand([
|
|
|
|
\ '[DEBUG] Ignore this.',
|
|
|
|
\ '[INFO] Something we should ignore.',
|
|
|
|
\ '/foo/bar.jar',
|
|
|
|
\ '/xyz/abc.jar',
|
|
|
|
\ ])
|
2017-04-25 21:32:48 +00:00
|
|
|
|
|
|
|
Execute(The javac callback should combine discovered classpaths and manual ones):
|
|
|
|
let g:ale_java_javac_classpath = 'configured.jar'
|
|
|
|
|
2017-10-08 22:26:50 +00:00
|
|
|
AssertEqual
|
2017-11-05 15:33:31 +00:00
|
|
|
\ g:prefix
|
|
|
|
\ . ' -cp '
|
2017-10-08 22:26:50 +00:00
|
|
|
\ . ale#Escape(join(
|
|
|
|
\ [
|
|
|
|
\ '/foo/bar.jar',
|
|
|
|
\ '/xyz/abc.jar',
|
|
|
|
\ 'configured.jar',
|
|
|
|
\ ],
|
|
|
|
\ g:cp_sep
|
|
|
|
\ ))
|
|
|
|
\ . ' -d TEMP %t',
|
|
|
|
\ GetCommand([
|
|
|
|
\ '[DEBUG] Ignore this.',
|
|
|
|
\ '[INFO] Something we should ignore.',
|
|
|
|
\ '/foo/bar.jar',
|
|
|
|
\ '/xyz/abc.jar',
|
|
|
|
\ ])
|
|
|
|
|
|
|
|
let g:ale_java_javac_classpath = 'configured.jar' . g:cp_sep . 'configured2.jar'
|
|
|
|
|
|
|
|
AssertEqual
|
2017-11-05 15:33:31 +00:00
|
|
|
\ g:prefix
|
|
|
|
\ . ' -cp '
|
2017-10-08 22:26:50 +00:00
|
|
|
\ . ale#Escape(join(
|
|
|
|
\ [
|
|
|
|
\ '/foo/bar.jar',
|
|
|
|
\ '/xyz/abc.jar',
|
|
|
|
\ 'configured.jar',
|
|
|
|
\ 'configured2.jar',
|
|
|
|
\ ],
|
|
|
|
\ g:cp_sep
|
|
|
|
\ ))
|
|
|
|
\ . ' -d TEMP %t',
|
|
|
|
\ GetCommand([
|
|
|
|
\ '[DEBUG] Ignore this.',
|
|
|
|
\ '[INFO] Something we should ignore.',
|
|
|
|
\ '/foo/bar.jar',
|
|
|
|
\ '/xyz/abc.jar',
|
|
|
|
\ ])
|
2017-04-25 21:32:48 +00:00
|
|
|
|
|
|
|
Execute(The javac callback should detect source directories):
|
2017-07-07 22:47:41 +00:00
|
|
|
call ale#engine#Cleanup(bufnr(''))
|
2017-11-20 16:42:43 +00:00
|
|
|
noautocmd e! java_paths/src/main/java/com/something/dummy
|
2017-04-25 21:32:48 +00:00
|
|
|
call ale#engine#InitBufferInfo(bufnr(''))
|
|
|
|
|
2017-10-08 22:26:50 +00:00
|
|
|
AssertEqual
|
2017-11-05 15:33:31 +00:00
|
|
|
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && javac -Xlint'
|
2017-10-08 22:26:50 +00:00
|
|
|
\ . ' -sourcepath ' . ale#Escape(
|
2017-12-19 18:23:09 +00:00
|
|
|
\ ale#path#Simplify(g:dir . '/java_paths/src/main/java/')
|
2017-10-08 22:26:50 +00:00
|
|
|
\ )
|
|
|
|
\ . ' -d TEMP %t',
|
|
|
|
\ GetCommand([])
|
2017-04-25 21:32:48 +00:00
|
|
|
|
|
|
|
Execute(The javac callback should combine detected source directories and classpaths):
|
2017-07-07 22:47:41 +00:00
|
|
|
call ale#engine#Cleanup(bufnr(''))
|
2017-10-08 22:26:50 +00:00
|
|
|
call ale#test#SetFilename('java_paths/src/main/java/com/something/dummy.java')
|
2017-04-25 21:32:48 +00:00
|
|
|
call ale#engine#InitBufferInfo(bufnr(''))
|
|
|
|
|
2017-10-08 22:26:50 +00:00
|
|
|
AssertEqual
|
2017-11-05 15:33:31 +00:00
|
|
|
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && javac -Xlint'
|
2017-10-08 22:26:50 +00:00
|
|
|
\ . ' -cp ' . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep))
|
|
|
|
\ . ' -sourcepath ' . ale#Escape(
|
2017-12-19 18:23:09 +00:00
|
|
|
\ ale#path#Simplify(g:dir . '/java_paths/src/main/java/')
|
2017-10-08 22:26:50 +00:00
|
|
|
\ )
|
|
|
|
\ . ' -d TEMP %t',
|
|
|
|
\ GetCommand([
|
|
|
|
\ '[DEBUG] Ignore this.',
|
|
|
|
\ '[INFO] Something we should ignore.',
|
|
|
|
\ '/foo/bar.jar',
|
|
|
|
\ '/xyz/abc.jar',
|
|
|
|
\ ])
|
2017-03-31 19:14:53 +00:00
|
|
|
|
|
|
|
Execute(The javac callback should use g:ale_java_javac_options correctly):
|
|
|
|
let g:ale_java_javac_options = '--anything --else'
|
|
|
|
|
2017-04-25 21:32:48 +00:00
|
|
|
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [])
|
2017-03-31 19:14:53 +00:00
|
|
|
|
2017-10-08 22:26:50 +00:00
|
|
|
AssertEqual
|
2017-11-05 15:33:31 +00:00
|
|
|
\ g:prefix
|
2017-10-08 22:26:50 +00:00
|
|
|
\ . ' -d TEMP --anything --else %t',
|
|
|
|
\ GetCommand([])
|
2017-11-20 16:42:43 +00:00
|
|
|
|
|
|
|
Execute(The javac callback should include src/test/java for test paths):
|
|
|
|
call ale#engine#Cleanup(bufnr(''))
|
|
|
|
" The test path is only included for test files.
|
|
|
|
" Regular Java files shouldn't import from tests.
|
|
|
|
noautocmd e! java_paths/src/test/java/com/something/dummy
|
|
|
|
call ale#engine#InitBufferInfo(bufnr(''))
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && javac -Xlint'
|
|
|
|
\ . ' -sourcepath ' . ale#Escape(join([
|
2017-12-19 18:23:09 +00:00
|
|
|
\ ale#path#Simplify(g:dir . '/java_paths/src/main/java/'),
|
|
|
|
\ ale#path#Simplify(g:dir . '/java_paths/src/test/java/'),
|
2017-11-20 16:42:43 +00:00
|
|
|
\ ], g:cp_sep))
|
|
|
|
\ . ' -d TEMP %t',
|
|
|
|
\ GetCommand([])
|
|
|
|
|
|
|
|
Execute(The javac callback should include src/main/jaxb when available):
|
|
|
|
call ale#engine#Cleanup(bufnr(''))
|
|
|
|
noautocmd e! java_paths_with_jaxb/src/main/java/com/something/dummy
|
|
|
|
call ale#engine#InitBufferInfo(bufnr(''))
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && javac -Xlint'
|
|
|
|
\ . ' -sourcepath ' . ale#Escape(join([
|
2017-12-19 18:23:09 +00:00
|
|
|
\ ale#path#Simplify(g:dir . '/java_paths_with_jaxb/src/main/java/'),
|
|
|
|
\ ale#path#Simplify(g:dir . '/java_paths_with_jaxb/src/main/jaxb/'),
|
2017-11-20 16:42:43 +00:00
|
|
|
\ ], g:cp_sep))
|
|
|
|
\ . ' -d TEMP %t',
|
|
|
|
\ GetCommand([])
|