From d787050fa8a82eec26962055829af1f33bd70bbf Mon Sep 17 00:00:00 2001 From: Michael Pardo Date: Mon, 10 Jul 2017 18:03:36 -0400 Subject: Kotlin and general Gradle support. (#745) --- .../build-gradle-project/build.gradle | 0 .../build-gradle-project/src/main/kotlin/dummy.kt | 0 test/gradle-test-files/gradle | 0 .../non-gradle-project/src/main/kotlin/dummy.kt | 0 .../settings-gradle-project/settings.gradle | 0 .../src/main/kotlin/dummy.kt | 0 .../unwrapped-project/build.gradle | 0 .../unwrapped-project/settings.gradle | 0 .../unwrapped-project/src/main/kotlin/dummy.kt | 0 .../gradle-test-files/wrapped-project/build.gradle | 0 test/gradle-test-files/wrapped-project/gradlew | 0 .../wrapped-project/settings.gradle | 0 .../wrapped-project/src/main/kotlin/dummy.kt | 0 test/test_gradle_build_classpath_command.vader | 42 ++++++++++++++++++++++ test/test_gradle_find_executable.vader | 31 ++++++++++++++++ test/test_gradle_find_project_root.vader | 35 ++++++++++++++++++ 16 files changed, 108 insertions(+) create mode 100644 test/gradle-test-files/build-gradle-project/build.gradle create mode 100644 test/gradle-test-files/build-gradle-project/src/main/kotlin/dummy.kt create mode 100755 test/gradle-test-files/gradle create mode 100644 test/gradle-test-files/non-gradle-project/src/main/kotlin/dummy.kt create mode 100644 test/gradle-test-files/settings-gradle-project/settings.gradle create mode 100644 test/gradle-test-files/settings-gradle-project/src/main/kotlin/dummy.kt create mode 100644 test/gradle-test-files/unwrapped-project/build.gradle create mode 100644 test/gradle-test-files/unwrapped-project/settings.gradle create mode 100644 test/gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt create mode 100644 test/gradle-test-files/wrapped-project/build.gradle create mode 100644 test/gradle-test-files/wrapped-project/gradlew create mode 100644 test/gradle-test-files/wrapped-project/settings.gradle create mode 100644 test/gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt create mode 100644 test/test_gradle_build_classpath_command.vader create mode 100644 test/test_gradle_find_executable.vader create mode 100644 test/test_gradle_find_project_root.vader (limited to 'test') diff --git a/test/gradle-test-files/build-gradle-project/build.gradle b/test/gradle-test-files/build-gradle-project/build.gradle new file mode 100644 index 00000000..e69de29b diff --git a/test/gradle-test-files/build-gradle-project/src/main/kotlin/dummy.kt b/test/gradle-test-files/build-gradle-project/src/main/kotlin/dummy.kt new file mode 100644 index 00000000..e69de29b diff --git a/test/gradle-test-files/gradle b/test/gradle-test-files/gradle new file mode 100755 index 00000000..e69de29b diff --git a/test/gradle-test-files/non-gradle-project/src/main/kotlin/dummy.kt b/test/gradle-test-files/non-gradle-project/src/main/kotlin/dummy.kt new file mode 100644 index 00000000..e69de29b diff --git a/test/gradle-test-files/settings-gradle-project/settings.gradle b/test/gradle-test-files/settings-gradle-project/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/test/gradle-test-files/settings-gradle-project/src/main/kotlin/dummy.kt b/test/gradle-test-files/settings-gradle-project/src/main/kotlin/dummy.kt new file mode 100644 index 00000000..e69de29b diff --git a/test/gradle-test-files/unwrapped-project/build.gradle b/test/gradle-test-files/unwrapped-project/build.gradle new file mode 100644 index 00000000..e69de29b diff --git a/test/gradle-test-files/unwrapped-project/settings.gradle b/test/gradle-test-files/unwrapped-project/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/test/gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt b/test/gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt new file mode 100644 index 00000000..e69de29b diff --git a/test/gradle-test-files/wrapped-project/build.gradle b/test/gradle-test-files/wrapped-project/build.gradle new file mode 100644 index 00000000..e69de29b diff --git a/test/gradle-test-files/wrapped-project/gradlew b/test/gradle-test-files/wrapped-project/gradlew new file mode 100644 index 00000000..e69de29b diff --git a/test/gradle-test-files/wrapped-project/settings.gradle b/test/gradle-test-files/wrapped-project/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/test/gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt b/test/gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt new file mode 100644 index 00000000..e69de29b diff --git a/test/test_gradle_build_classpath_command.vader b/test/test_gradle_build_classpath_command.vader new file mode 100644 index 00000000..84135268 --- /dev/null +++ b/test/test_gradle_build_classpath_command.vader @@ -0,0 +1,42 @@ +Before: + call ale#test#SetDirectory('/testplugin/test') + runtime ale_linters/kotlin/kotlinc.vim + let g:ale_gradle_path = $PATH + +After: + call ale#test#RestoreDirectory() + call ale#linter#Reset() + let $PATH = g:ale_gradle_path + +Execute(Should return 'gradlew' command if project includes gradle wapper): + call ale#test#SetFilename('gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt') + + let g:project_root = '/testplugin/test/gradle-test-files/wrapped-project' + let g:gradle_executable = '/testplugin/test/gradle-test-files/wrapped-project/gradlew' + let g:gradle_init_path = '/testplugin/autoload/ale/gradle/init.gradle' + let g:gradle_options = '-I ' . g:gradle_init_path . ' -q printClasspath' + + + AssertEqual + \ "cd '" . g:project_root . "' && " . g:gradle_executable . " " . g:gradle_options, + \ ale#gradle#BuildClasspathCommand(bufnr('')) + +Execute(Should return 'gradle' command if project does not include gradle wapper): + call ale#test#SetFilename('gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt') + let $PATH .= ':' . g:dir . '/gradle-test-files' + + let g:project_root = '/testplugin/test/gradle-test-files/unwrapped-project' + let g:gradle_executable = 'gradle' + let g:gradle_init_path = '/testplugin/autoload/ale/gradle/init.gradle' + let g:gradle_options = '-I ' . g:gradle_init_path . ' -q printClasspath' + + AssertEqual + \ "cd '" . g:project_root . "' && " . g:gradle_executable . " " . g:gradle_options, + \ ale#gradle#BuildClasspathCommand(bufnr('')) + +Execute(Should return empty string if gradle cannot be executed): + call ale#test#SetFilename('gradle-test-files/non-gradle-project/src/main/kotlin/dummy.kt') + + AssertEqual + \ '', + \ ale#gradle#BuildClasspathCommand(bufnr('')) diff --git a/test/test_gradle_find_executable.vader b/test/test_gradle_find_executable.vader new file mode 100644 index 00000000..2ae2b464 --- /dev/null +++ b/test/test_gradle_find_executable.vader @@ -0,0 +1,31 @@ +Before: + call ale#test#SetDirectory('/testplugin/test') + runtime ale_linters/kotlin/kotlinc.vim + let g:ale_gradle_path = $PATH + +After: + call ale#test#RestoreDirectory() + call ale#linter#Reset() + let $PATH = g:ale_gradle_path + +Execute(Should return 'gradlew' if found in parent directory): + call ale#test#SetFilename('gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt') + + AssertEqual + \ g:dir . '/gradle-test-files/wrapped-project/gradlew', + \ ale#gradle#FindExecutable(bufnr('')) + +Execute(Should return 'gradle' if 'gradlew' not found in parent directory): + call ale#test#SetFilename('gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt') + let $PATH .= ':' . g:dir . '/gradle-test-files' + + AssertEqual + \ 'gradle', + \ ale#gradle#FindExecutable(bufnr('')) + +Execute(Should return empty string if 'gradlew' not in parent directory and gradle not in path): + call ale#test#SetFilename('gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt') + + AssertEqual + \ '', + \ ale#gradle#FindExecutable(bufnr('')) diff --git a/test/test_gradle_find_project_root.vader b/test/test_gradle_find_project_root.vader new file mode 100644 index 00000000..bd1b8d7d --- /dev/null +++ b/test/test_gradle_find_project_root.vader @@ -0,0 +1,35 @@ +Before: + call ale#test#SetDirectory('/testplugin/test') + runtime ale_linters/kotlin/kotlinc.vim + +After: + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(Should return directory for 'gradlew' if found in parent directory): + call ale#test#SetFilename('gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt') + + AssertEqual + \ g:dir . '/gradle-test-files/wrapped-project', + \ ale#gradle#FindProjectRoot(bufnr('')) + +Execute(Should return directory for 'settings.gradle' if found in parent directory): + call ale#test#SetFilename('gradle-test-files/settings-gradle-project/src/main/kotlin/dummy.kt') + + AssertEqual + \ g:dir . '/gradle-test-files/settings-gradle-project', + \ ale#gradle#FindProjectRoot(bufnr('')) + +Execute(Should return directory for 'build.gradle' if found in parent directory): + call ale#test#SetFilename('gradle-test-files/build-gradle-project/src/main/kotlin/dummy.kt') + + AssertEqual + \ g:dir . '/gradle-test-files/build-gradle-project', + \ ale#gradle#FindProjectRoot(bufnr('')) + +Execute(Should return empty string if gradle files are not found in parent directory): + call ale#test#SetFilename('gradle-test-files/non-gradle-project/src/main/kotlin/dummy.kt') + + AssertEqual + \ '', + \ ale#gradle#FindProjectRoot(bufnr('')) -- cgit v1.2.3