diff options
author | Horacio Sanson <hsanson@gmail.com> | 2020-10-02 20:07:28 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-02 20:07:28 +0900 |
commit | b91c6c2edd20794ad5637b561ed4c678647a76e5 (patch) | |
tree | b4faf1cf480be30f463dd25d89697e19abbfe02e /test | |
parent | 2d3ed956b944132e1d520446493fa5c9aa8a309f (diff) | |
parent | 4466c479900cbdc029d3091beedda5f1729851ae (diff) | |
download | ale-b91c6c2edd20794ad5637b561ed4c678647a76e5.zip |
Merge pull request #3374 from fenuks/maven_helper
Use maven wrapper if available
Diffstat (limited to 'test')
11 files changed, 124 insertions, 0 deletions
diff --git a/test/maven-test-files/maven-java-project/module1/mvnw b/test/maven-test-files/maven-java-project/module1/mvnw new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/maven-test-files/maven-java-project/module1/mvnw diff --git a/test/maven-test-files/maven-java-project/module1/mvnw.cmd b/test/maven-test-files/maven-java-project/module1/mvnw.cmd new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/maven-test-files/maven-java-project/module1/mvnw.cmd diff --git a/test/maven-test-files/maven-java-project/module1/pom.xml b/test/maven-test-files/maven-java-project/module1/pom.xml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/maven-test-files/maven-java-project/module1/pom.xml @@ -0,0 +1 @@ + diff --git a/test/maven-test-files/maven-java-project/module1/src/main/java/dummy1.java b/test/maven-test-files/maven-java-project/module1/src/main/java/dummy1.java new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/maven-test-files/maven-java-project/module1/src/main/java/dummy1.java diff --git a/test/maven-test-files/maven-java-project/module2/pom.xml b/test/maven-test-files/maven-java-project/module2/pom.xml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/maven-test-files/maven-java-project/module2/pom.xml @@ -0,0 +1 @@ + diff --git a/test/maven-test-files/maven-java-project/module2/src/main/java/dummy2.java b/test/maven-test-files/maven-java-project/module2/src/main/java/dummy2.java new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/maven-test-files/maven-java-project/module2/src/main/java/dummy2.java diff --git a/test/maven-test-files/mvn b/test/maven-test-files/mvn new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/maven-test-files/mvn diff --git a/test/maven-test-files/non-maven-project/src/main/java/dummy.java b/test/maven-test-files/non-maven-project/src/main/java/dummy.java new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/maven-test-files/non-maven-project/src/main/java/dummy.java diff --git a/test/test_maven_build_classpath_command.vader b/test/test_maven_build_classpath_command.vader new file mode 100644 index 00000000..2d8b38a5 --- /dev/null +++ b/test/test_maven_build_classpath_command.vader @@ -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('')) diff --git a/test/test_maven_find_executable.vader b/test/test_maven_find_executable.vader new file mode 100644 index 00000000..1d2f6da2 --- /dev/null +++ b/test/test_maven_find_executable.vader @@ -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('')) diff --git a/test/test_maven_find_project_root.vader b/test/test_maven_find_project_root.vader new file mode 100644 index 00000000..3a2138d1 --- /dev/null +++ b/test/test_maven_find_project_root.vader @@ -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('')) |