summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-03-31 20:14:53 +0100
committerw0rp <devw0rp@gmail.com>2017-03-31 20:14:53 +0100
commit7c736579b72a79d955d090db35adf8c751a79fd8 (patch)
tree81a647646b6136bfebb6864461096f490b4af589 /test
parent7a8dbe1139b698cff7c7e04e5e27a40a8ffec5f5 (diff)
downloadale-7c736579b72a79d955d090db35adf8c751a79fd8.zip
Fix #438 Create Java .class files for javac in a temporary directory
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_javac_command_callback.vader33
-rw-r--r--test/test_temporary_file_management.vader20
2 files changed, 53 insertions, 0 deletions
diff --git a/test/command_callback/test_javac_command_callback.vader b/test/command_callback/test_javac_command_callback.vader
new file mode 100644
index 00000000..52aeff44
--- /dev/null
+++ b/test/command_callback/test_javac_command_callback.vader
@@ -0,0 +1,33 @@
+Before:
+ runtime ale_linters/java/javac.vim
+ call ale#engine#InitBufferInfo(bufnr(''))
+
+After:
+ call ale#linter#Reset()
+ " We need to clean up the buffer to remove the temporary directories created
+ " for the command.
+ call ale#cleanup#Buffer(bufnr(''))
+ let g:ale_java_javac_options = ''
+ let g:ale_java_javac_classpath = ''
+
+Execute(The javac callback should return the correct default value):
+ let b:command = ale_linters#java#javac#GetCommand(bufnr(''))
+
+ Assert match(b:command, '\v^javac +-Xlint +-d +/tmp/[0-9a-zA-Z/]+ +\%t$') >= 0,
+ \ 'Invalid command string: ' . b:command
+
+Execute(The javac callback should use g:ale_java_javac_classpath correctly):
+ let g:ale_java_javac_classpath = 'foo.jar'
+
+ let b:command = ale_linters#java#javac#GetCommand(bufnr(''))
+
+ Assert match(b:command, '\v^javac +-Xlint -cp foo\.jar +-d +/tmp/[0-9a-zA-Z/]+ +\%t$') >= 0,
+ \ 'Invalid command string: ' . b:command
+
+Execute(The javac callback should use g:ale_java_javac_options correctly):
+ let g:ale_java_javac_options = '--anything --else'
+
+ let b:command = ale_linters#java#javac#GetCommand(bufnr(''))
+
+ Assert match(b:command, '\v^javac +-Xlint +-d +/tmp/[0-9a-zA-Z/]+ --anything --else +\%t$') >= 0,
+ \ 'Invalid command string: ' . b:command
diff --git a/test/test_temporary_file_management.vader b/test/test_temporary_file_management.vader
index 17a375e1..b66f3d19 100644
--- a/test/test_temporary_file_management.vader
+++ b/test/test_temporary_file_management.vader
@@ -81,3 +81,23 @@ Execute(ALE should delete managed files when the buffer is removed):
Assert !filereadable(g:filename), 'The tempoary file was not deleted'
Assert !isdirectory(g:directory), 'The tempoary directory was not deleted'
Assert isdirectory(g:preserved_directory), 'The tempoary directory was not kept'
+
+Execute(ALE should create and delete directories for ale#engine#CreateDirectory()):
+ call ale#engine#InitBufferInfo(bufnr('%'))
+
+ let b:dir = ale#engine#CreateDirectory(bufnr('%'))
+ let b:dir2 = ale#engine#CreateDirectory(bufnr('%'))
+
+ Assert isdirectory(b:dir), 'The directory was not created'
+
+ " We should get the correct file permissions.
+ " We want to ensure that the directory is not readable by 'other'
+ AssertEqual 'rwxr-x---', getfperm(b:dir)
+
+ " The two directories shouldn't be the same.
+ AssertNotEqual b:dir2, b:dir
+
+ call ale#cleanup#Buffer(bufnr('%'))
+
+ Assert !isdirectory(b:dir), 'The directory was not deleted'
+ Assert !isdirectory(b:dir2), 'The second directory was not deleted'