Skip to content

Commit

Permalink
test gradle projects
Browse files Browse the repository at this point in the history
add tests for gradle DSLs
- groovy
- kotlin
import fails for gradle kotlin DSL
  • Loading branch information
lmmarsano committed May 7, 2019
1 parent 7f1f99e commit 8b9f7c8
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 5 deletions.
16 changes: 16 additions & 0 deletions features/ImportProject.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,19 @@ Feature: Importing projects
And I add project "m" folder "tmp" to the list of workspace folders
And I start lsp-java
Then The server status must become "LSP::Started"

Scenario: Gradle Groovy DSL projects
Given I have gradle groovy DSL project "m" in "tmp"
And I have a java file "tmp/m/src/main/java/temp/App.java"
And I clear the buffer
And I add project "m" folder "tmp" to the list of workspace folders
And I start lsp-java
Then The server status must become "LSP::Started"

Scenario: Gradle Kotlin DSL projects
Given I have gradle kotlin DSL project "m" in "tmp"
And I have a java file "tmp/m/src/main/java/temp/App.java"
And I clear the buffer
And I add project "m" folder "tmp" to the list of workspace folders
And I start lsp-java
Then The server status must become "LSP::Started"
47 changes: 42 additions & 5 deletions features/step-definitions/lsp-java-steps.el
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
(setq retry-count (1+ retry-count))
(message "The function failed, attempt %s" retry-count)))))))

(Given "^I have maven project \"\\([^\"]+\\)\" in \"\\([^\"]+\\)\"$"
(lambda (project-name dir-name)
(defun lsp-java-steps-project (project-name dir-name config-name config)
(setq default-directory lsp-java-test-root)

;; delete old directory
Expand All @@ -52,8 +51,12 @@
(f-join dir-name project-name "src" "main" "java" "temp")) t)

;; add pom.xml
(with-temp-file (expand-file-name "pom.xml" (f-join dir-name project-name))
(insert "
(with-temp-file (expand-file-name config-name (f-join dir-name project-name))
(insert config)))

(Given "^I have maven project \"\\([^\"]+\\)\" in \"\\([^\"]+\\)\"$"
(lambda (project-name dir-name)
(lsp-java-steps-project project-name dir-name "pom.xml" "
<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">
<modelVersion>4.0.0</modelVersion>
Expand All @@ -68,7 +71,41 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>"))))
</project>")))

(Given "^I have gradle groovy DSL project \"\\([^\"]+\\)\" in \"\\([^\"]+\\)\"$"
(lambda (project-name dir-name)
(lsp-java-steps-project project-name dir-name "build.gradle" "
plugins {
id 'java'
id 'application'
}
repositories {
jcenter()
}
dependencies {
implementation 'com.google.guava:guava:27.0.1-jre'
}
application {
mainClassName = 'test-project'
}")))

(Given "^I have gradle kotlin DSL project \"\\([^\"]+\\)\" in \"\\([^\"]+\\)\"$"
(lambda (project-name dir-name)
(lsp-java-steps-project project-name dir-name "build.gradle.kts" "
plugins {
java
application
}
repositories {
jcenter()
}
dependencies {
implementation(\"com.google.guava:guava:27.0.1-jre\")
}
application {
mainClassName = \"java.test.App\"
}")))

(And "^I have a java file \"\\([^\"]+\\)\"$"
(lambda (file-name)
Expand Down

0 comments on commit 8b9f7c8

Please sign in to comment.