Add tests for maven.vim file
This commit is contained in:
parent
7186b0437f
commit
4466c47990
11 changed files with 124 additions and 0 deletions
0
test/maven-test-files/maven-java-project/module1/mvnw
vendored
Executable file
0
test/maven-test-files/maven-java-project/module1/mvnw
vendored
Executable file
0
test/maven-test-files/maven-java-project/module1/mvnw.cmd
vendored
Executable file
0
test/maven-test-files/maven-java-project/module1/mvnw.cmd
vendored
Executable file
1
test/maven-test-files/maven-java-project/module1/pom.xml
Normal file
1
test/maven-test-files/maven-java-project/module1/pom.xml
Normal file
|
@ -0,0 +1 @@
|
|||
|
1
test/maven-test-files/maven-java-project/module2/pom.xml
Normal file
1
test/maven-test-files/maven-java-project/module2/pom.xml
Normal file
|
@ -0,0 +1 @@
|
|||
|
0
test/maven-test-files/mvn
Executable file
0
test/maven-test-files/mvn
Executable file
48
test/test_maven_build_classpath_command.vader
Normal file
48
test/test_maven_build_classpath_command.vader
Normal file
|
@ -0,0 +1,48 @@
|
|||
Before:
|
||||
Save $PATH
|
||||
Save $PATHEXT
|
||||
|
||||
let $PATHEXT = '.'
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
runtime ale_linters/java/javac.vim
|
||||
let g:expected_wrapper = ''
|
||||
if has('unix')
|
||||
let g:expected_wrapper = 'mvnw'
|
||||
else
|
||||
let g:expected_wrapper = 'mvnw.cmd'
|
||||
endif
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! g:expected_wrapper
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(Should use 'mvnw' in classpath command if available):
|
||||
call ale#test#SetFilename('maven-test-files/maven-java-project/module1/src/main/java/dummy1.java')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1'))
|
||||
\ . ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1/' . g:expected_wrapper)
|
||||
\ . ' dependency:build-classpath',
|
||||
\ ale#maven#BuildClasspathCommand(bufnr(''))
|
||||
|
||||
Execute(Should use 'mvn' in classpath command if it is executable and 'mvnw' is unavailable):
|
||||
call ale#test#SetFilename('maven-test-files/maven-java-project/module2/src/main/java/dummy2.java')
|
||||
let $PATH .= (has('win32') ? ';' : ':')
|
||||
\ . ale#path#Simplify(g:dir . '/maven-test-files')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module2'))
|
||||
\ . 'mvn dependency:build-classpath',
|
||||
\ ale#maven#BuildClasspathCommand(bufnr(''))
|
||||
|
||||
Execute(Should return empty string if maven cannot be executed):
|
||||
call ale#test#SetFilename('maven-test-files/non-maven-project/src/main/java/dummy.java')
|
||||
|
||||
AssertEqual
|
||||
\ '',
|
||||
\ ale#maven#BuildClasspathCommand(bufnr(''))
|
46
test/test_maven_find_executable.vader
Normal file
46
test/test_maven_find_executable.vader
Normal file
|
@ -0,0 +1,46 @@
|
|||
Before:
|
||||
Save $PATH
|
||||
Save $PATHEXT
|
||||
|
||||
" Count the maven executable without .exe as executable on Windows
|
||||
let $PATHEXT = '.'
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
runtime ale_linters/java/javac.vim
|
||||
let g:expected_wrapper = ''
|
||||
if has('unix')
|
||||
let g:expected_wrapper = 'mvnw'
|
||||
else
|
||||
let g:expected_wrapper = 'mvnw.cmd'
|
||||
endif
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! g:expected_wrapper
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(Should return 'mvnw' if found in parent directory):
|
||||
call ale#test#SetFilename('maven-test-files/maven-java-project/module1/src/main/java/dummy1.java')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1/' . g:expected_wrapper),
|
||||
\ ale#maven#FindExecutable(bufnr(''))
|
||||
|
||||
Execute(Should return 'mvn' if 'mvnw' not found in parent directory):
|
||||
call ale#test#SetFilename('maven-test-files/maven-java-project/module2/src/main/java/dummy2.java')
|
||||
let $PATH .= (has('win32') ? ';' : ':')
|
||||
\ . ale#path#Simplify(g:dir . '/maven-test-files')
|
||||
|
||||
AssertEqual
|
||||
\ 'mvn',
|
||||
\ ale#maven#FindExecutable(bufnr(''))
|
||||
|
||||
Execute(Should return empty string if 'mvnw' not in parent directory and mvn not in path):
|
||||
call ale#test#SetFilename('mvn-test-files/java-maven-project/module2/src/main/java/dummy2.java')
|
||||
|
||||
AssertEqual
|
||||
\ '',
|
||||
\ ale#gradle#FindExecutable(bufnr(''))
|
28
test/test_maven_find_project_root.vader
Normal file
28
test/test_maven_find_project_root.vader
Normal file
|
@ -0,0 +1,28 @@
|
|||
Before:
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
runtime ale_linters/kotlin/javac.vim
|
||||
|
||||
After:
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(Should return directory for 'mvnw' if found in parent directory):
|
||||
call ale#test#SetFilename('maven-test-files/maven-java-project/module1/src/main/java/dummy1.java')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1'),
|
||||
\ ale#maven#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(Should return directory for 'pom.xml' if found in parent directory):
|
||||
call ale#test#SetFilename('maven-test-files/maven-java-project/module2/src/main/java/dummy2.java')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module2'),
|
||||
\ ale#maven#FindProjectRoot(bufnr(''))
|
||||
|
||||
Execute(Should return empty string if maven files are not found in parent directory):
|
||||
call ale#test#SetFilename('maven-test-files/non-maven-project/src/main/java/dummy.java')
|
||||
|
||||
AssertEqual
|
||||
\ '',
|
||||
\ ale#maven#FindProjectRoot(bufnr(''))
|
Reference in a new issue