From acfa74706b83d620c675df81fcb81b805f6293a8 Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Wed, 18 Nov 2015 12:45:16 +0000 Subject: add gradle wrapper using gradle 2.9 --- gradle/wrapper/gradle-wrapper.jar | Bin 53636 -> 53636 bytes gradle/wrapper/gradle-wrapper.properties | 4 ++-- gradlew | 10 +++------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index fd7e590..9411448 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6e80329..2aae013 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Sep 03 23:57:28 CEST 2015 +#Wed Nov 18 11:44:20 WET 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip diff --git a/gradlew b/gradlew index 91a7e26..9d82f78 100755 --- a/gradlew +++ b/gradlew @@ -42,11 +42,6 @@ case "`uname`" in ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" @@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do fi done SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- +cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" -cd "$SAVED" >&- +cd "$SAVED" >/dev/null CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -114,6 +109,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` -- cgit From da9a1b100639e7eb5a7986952f5a1f3ba0d675e6 Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Wed, 18 Nov 2015 12:48:31 +0000 Subject: Add infrastructure for adding integration tests using testkit --- build.gradle | 48 ++++++++------ gradle/integTest.gradle | 50 ++++++++++++++ .../frege/plugin/FregePluginIntegTest.groovy | 77 ++++++++++++++++++++++ 3 files changed, 155 insertions(+), 20 deletions(-) create mode 100644 gradle/integTest.gradle create mode 100644 src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy diff --git a/build.gradle b/build.gradle index fcca969..a3114ee 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,9 @@ - apply plugin: "groovy" apply plugin: "maven" apply plugin: "signing" +apply plugin: "idea" + +apply from: 'gradle/integTest.gradle' defaultTasks "build" @@ -20,8 +22,8 @@ ext { fregeVersion = "$fregeBaseVersion$fregeClassifier" // work around https://issues.gradle.org/browse/GRADLE-3281 - def home = new File(System.getProperty("user.home")) - def propfile = new File(home, ".gradle/gradle.properties") + def home = new File(System.getProperty("user.home")) + def propfile = new File(home, ".gradle/gradle.properties") if (propfile.exists()) { props = new Properties() propfile.withReader { @@ -59,21 +61,27 @@ dependencies { compile "$projectGroup:frege-repl-core:1.2" compile "$projectGroup:frege-native-gen:1.3" compile "org.functionaljava:functionaljava:4.4" + compile gradleApi() compile localGroovy() + testCompile gradleTestKit() + + testCompile('org.spockframework:spock-core:1.0-groovy-2.4') { + exclude module: 'groovy-all' + } } // using the publishing plugin buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" + repositories { + maven { + url "https://plugins.gradle.org/m2/" + } + } + dependencies { + classpath "com.gradle.publish:plugin-publish-plugin:0.9.1" } - } - dependencies { - classpath "com.gradle.publish:plugin-publish-plugin:0.9.1" - } } // Details on how to publish to the gradle plugin portal @@ -86,15 +94,15 @@ apply plugin: "com.gradle.plugin-publish" // The configuration example below shows the minimum required properties // configured to publish your plugin to the plugin portal pluginBundle { - website = 'https://github.com/Frege/frege-gradle-plugin' - vcsUrl = 'https://github.com/Frege/frege-gradle-plugin' - description = 'Enabling Frege for compilation, testing, documentation, and supporting tools.' - tags = ['frege', 'haskell', 'java'] - - plugins { - fregePlugin { - id = 'org.frege-lang' - displayName = 'Frege plugin' + website = 'https://github.com/Frege/frege-gradle-plugin' + vcsUrl = 'https://github.com/Frege/frege-gradle-plugin' + description = 'Enabling Frege for compilation, testing, documentation, and supporting tools.' + tags = ['frege', 'haskell', 'java'] + + plugins { + fregePlugin { + id = 'org.frege-lang' + displayName = 'Frege plugin' + } } - } } diff --git a/gradle/integTest.gradle b/gradle/integTest.gradle new file mode 100644 index 0000000..07b0743 --- /dev/null +++ b/gradle/integTest.gradle @@ -0,0 +1,50 @@ +sourceSets { + integTest { + compileClasspath += main.output + test.output + runtimeClasspath += main.output + test.output + } +} + +configurations { + integTestCompile.extendsFrom testCompile + integTestRuntime.extendsFrom testRuntime +} + +task integTest(type: Test) { + shouldRunAfter 'test' + testClassesDir = sourceSets.integTest.output.classesDir + classpath = sourceSets.integTest.runtimeClasspath + +} +check.dependsOn(integTest) + +plugins.withType(org.gradle.plugins.ide.idea.IdeaPlugin) { + idea { + module { + testSourceDirs += sourceSets.integTest.groovy.srcDirs + testSourceDirs += sourceSets.integTest.resources.srcDirs + scopes.TEST.plus.add(configurations.integTestCompile) + scopes.TEST.plus.add(configurations.integTestRuntime) + } + } +} + + +// START SNIPPET test-logic-classpath +// Write the plugin's classpath to a file to share with the tests +task createClasspathManifest { + def outputDir = file("$buildDir/$name") + + inputs.files sourceSets.main.runtimeClasspath + outputs.dir outputDir + + doLast { + outputDir.mkdirs() + file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join("\n") + } +} + +// Add the classpath file to the test runtime classpath +dependencies { + integTestRuntime files(createClasspathManifest) +} \ No newline at end of file diff --git a/src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy b/src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy new file mode 100644 index 0000000..5c985e8 --- /dev/null +++ b/src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy @@ -0,0 +1,77 @@ +package frege.plugin + +import org.gradle.testkit.runner.GradleRunner +import org.junit.Rule +import org.junit.rules.TemporaryFolder +import spock.lang.Specification + +import static org.gradle.testkit.runner.TaskOutcome.SUCCESS + +class FregePluginIntegTest extends Specification { + + @Rule + final TemporaryFolder testProjectDir = new TemporaryFolder() + File buildFile + + List pluginClasspath + + def setup() { + buildFile = testProjectDir.newFile('build.gradle') + + def pluginClasspathResource = getClass().classLoader.findResource("plugin-classpath.txt") + if (pluginClasspathResource == null) { + // try again via file reference + pluginClasspathResource = new File("build/createClasspathManifest/plugin-classpath.txt") + if (pluginClasspathResource == null) { + throw new IllegalStateException("Did not find plugin classpath resource, run `integTestClasses` build task.") + } + } + pluginClasspath = pluginClasspathResource.readLines().collect { new File(it) } + } + + def "can compile frege production code"() { + given: + buildFile << """ + plugins { + id 'org.frege-lang' + } + + repositories { + jcenter() + } + + dependencies { + compile "org.frege-lang:frege:3.22.367-g2737683" + } + + task sayHello(type: JavaExec){ + classpath = sourceSets.main.runtimeClasspath + main = 'HelloFrege' + } + + """ + + testProjectDir.newFolder("src", "main", "frege") + def fregeSourceFile = testProjectDir.newFile("src/main/frege/HelloFrege.fr") + + fregeSourceFile << """ +module HelloFrege where + +greeting = "Hello Frege!" + +main _ = do + println greeting +""" + + when: + def result = GradleRunner.create() + .withProjectDir(testProjectDir.root) + .withArguments('sayHello') + .withPluginClasspath(pluginClasspath) + .build() + + then: + result.output.contains("Hello Frege!") + result.task(":sayHello").outcome == SUCCESS + } +} \ No newline at end of file -- cgit