aboutsummaryrefslogtreecommitdiff
path: root/src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy
diff options
context:
space:
mode:
authorRene Groeschke <rene@gradle.com>2015-11-22 00:50:45 +0000
committerRene Groeschke <rene@gradle.com>2015-11-22 00:50:45 +0000
commitfdc7b27d69b22e0ffa151d56c8f3812dcd229555 (patch)
treef67fb55cdf48e05596f6d71e2b7f11e6853f5f28 /src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy
parenta676a61ddf3478356b43b4b7f947e6f769cde50e (diff)
downloadfrege-gradle-plugin-fdc7b27d69b22e0ffa151d56c8f3812dcd229555.tar.gz
frege-gradle-plugin-fdc7b27d69b22e0ffa151d56c8f3812dcd229555.tar.bz2
frege-gradle-plugin-fdc7b27d69b22e0ffa151d56c8f3812dcd229555.zip
some more work on coverage and some cleanup
- get packages for integ tests right - introduce common AbstractFregeIntegrationSpec - first stab of unit test coverage for FregeCompile - minor cleanup on FregeCompile - configure fregePath as part as part of base plugin convention
Diffstat (limited to 'src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy')
-rw-r--r--src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy161
1 files changed, 0 insertions, 161 deletions
diff --git a/src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy b/src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy
deleted file mode 100644
index 40afe4a..0000000
--- a/src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy
+++ /dev/null
@@ -1,161 +0,0 @@
-package frege.plugin
-import org.gradle.testkit.runner.GradleRunner
-import org.junit.Rule
-import org.junit.rules.TemporaryFolder
-import spock.lang.Specification
-import spock.lang.Unroll
-
-import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
-
-class FregePluginIntegTest extends Specification {
-
- public static final String DEFAULT_FREGE_VERSION = "3.23.370-g898bc8c"
- @Rule
- final TemporaryFolder testProjectDir = new TemporaryFolder()
- File buildFile
-
- List<File> pluginClasspath
-
- def setup() {
- buildFile = testProjectDir.newFile('build.gradle')
-
- buildFile << """
- plugins {
- id 'org.frege-lang'
- }
-
- repositories {
- jcenter()
- }
- """
- 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 handle non existing source directories"() {
- given:
- buildFile << """
- dependencies {
- compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION"
- }
- """
-
- when:
- def result = GradleRunner.create()
- .withProjectDir(testProjectDir.root)
- .withArguments('classes')
- .withPluginClasspath(pluginClasspath)
- .build()
- then:
- result.task(":compileFrege") != null
- }
-
- @Unroll
- def "can compile and run frege code (gradle: #gradleVersion, frege: #fregeVersion)"() {
- given:
- buildFile << """
- dependencies {
- compile "org.frege-lang:frege:$fregeVersion"
- }
- ${sayHelloTask()}
- """
-
- testProjectDir.newFolder("src", "main", "frege", "org", "frege")
- def fregeSourceFile = testProjectDir.newFile("src/main/frege/org/frege/HelloFrege.fr")
-
- fregeSourceFile << """
-module org.frege.HelloFrege where
-
-greeting = "Hello Frege!"
-
-main _ = do
- println greeting
-"""
-
- when:
- def result = GradleRunner.create()
- .withGradleVersion(gradleVersion)
- .withProjectDir(testProjectDir.root)
- .withArguments('sayHello')
- .withPluginClasspath(pluginClasspath)
- .build()
-
- then:
- result.output.contains("Hello Frege!")
- result.task(":sayHello").outcome == SUCCESS
-
- where:
- fregeVersion | gradleVersion
- DEFAULT_FREGE_VERSION | "2.9"
- DEFAULT_FREGE_VERSION | "2.8"
- "3.22.367-g2737683" | "2.9"
- "3.22.367-g2737683" | "2.8"
- }
-
-
- def "can reference java from frege"() {
- given:
- buildFile << """
- dependencies {
- compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION"
- }
-
- ${sayHelloTask()}
- """
-
- and:
- testProjectDir.newFolder("src", "main", "frege", "org", "frege")
-
- def fregeSourceFile = testProjectDir.newFile("src/main/frege/org/frege/HelloFrege.fr")
-
- fregeSourceFile << """
-module org.frege.HelloFrege where
-
-data StaticHello = pure native org.frege.StaticHello where
- pure native helloJava org.frege.StaticHello.helloJava :: () -> String
-
-main _ = do
- println(StaticHello.helloJava())
-
-"""
- testProjectDir.newFolder("src", "main", "java", "org", "frege")
- def javaSourceFile = testProjectDir.newFile("src/main/java/org/frege/StaticHello.java")
-
- javaSourceFile << """
-package org.frege;
-
-public class StaticHello {
- public static String helloJava() {
- return "hello from java";
- }
-}
-"""
-
- when:
- def result = GradleRunner.create()
- .withProjectDir(testProjectDir.root)
- .withArguments('sayHello')
- .withPluginClasspath(pluginClasspath)
- .build()
- then:
- result.task(":compileJava").outcome == SUCCESS
- result.task(":compileFrege").outcome == SUCCESS
-
- result.output.contains("hello from java")
- }
-
-
- def sayHelloTask() {
- return """task sayHello(type: JavaExec){
- classpath = sourceSets.main.runtimeClasspath
- main = 'org.frege.HelloFrege'
- }"""
- }
-} \ No newline at end of file