aboutsummaryrefslogtreecommitdiff
path: root/src/integTest/groovy/frege/gradle/plugins
diff options
context:
space:
mode:
authorThibault Gagnaux <tgagnaux@gmail.com>2021-06-28 11:10:10 +0200
committerThibault Gagnaux <tgagnaux@gmail.com>2021-06-28 11:10:10 +0200
commitf3d085304bad105e65ce0c77f25ae59161fd8776 (patch)
tree92988ca069de5c6cdce67a18971d9ccfb3b0ef85 /src/integTest/groovy/frege/gradle/plugins
parent3be7e4219a15c0939f929c7c0836273f78e3a4f5 (diff)
downloadfrege-gradle-plugin-f3d085304bad105e65ce0c77f25ae59161fd8776.tar.gz
frege-gradle-plugin-f3d085304bad105e65ce0c77f25ae59161fd8776.tar.bz2
frege-gradle-plugin-f3d085304bad105e65ce0c77f25ae59161fd8776.zip
Inits branch with a simple groovy test
Diffstat (limited to 'src/integTest/groovy/frege/gradle/plugins')
-rw-r--r--src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy208
1 files changed, 0 insertions, 208 deletions
diff --git a/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy b/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy
deleted file mode 100644
index 798d333..0000000
--- a/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy
+++ /dev/null
@@ -1,208 +0,0 @@
-package frege.gradle.plugins
-import frege.gradle.integtest.fixtures.AbstractFregeIntegrationSpec
-import org.gradle.testkit.runner.BuildResult
-import spock.lang.Unroll
-
-import static org.gradle.testkit.runner.TaskOutcome.NO_SOURCE
-import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
-import static org.gradle.testkit.runner.TaskOutcome.UP_TO_DATE
-
-class FregePluginIntegTest extends AbstractFregeIntegrationSpec {
-
- def setup() {
- buildFile << """
- plugins {
- id 'org.frege-lang'
- }
-
- repositories {
- jcenter()
- flatDir {
- dirs '${new File(".").absolutePath}/lib'
- }
- }
- compileFrege {
- classpath = files()
- }
- """
- }
-
- def "can handle non existing source directories"() {
- given:
- buildFile << """
- dependencies {
- compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION"
- }
- """
-
- when:
- def result = run(gradleVersion, "classes")
- then:
- result.task(":compileFrege").outcome == NO_SOURCE
- where:
- gradleVersion << ["4.0", "5.0", "5.3.1"]
- }
-
- @Unroll
- def "can compile and run frege code (gradle: #gradleVersion, frege: #fregeVersion)"() {
- given:
- buildFile << """
- dependencies {
- compile "org.frege-lang:frege:$fregeVersion"
- }
- ${sayHelloTask()}
- """
-
- fregeModule()
-
- when:
- def result = run(gradleVersion, "sayHello")
-
- then:
- result.output.contains("Hello Frege!")
- result.task(":sayHello").outcome == SUCCESS
-
- where:
- fregeVersion | gradleVersion
- DEFAULT_FREGE_VERSION | "5.3.1"
- DEFAULT_FREGE_VERSION | "5.0"
- DEFAULT_FREGE_VERSION | "4.0"
- "3.22.367-g2737683" | "2.12"
- }
-
- private void fregeModule(String modulePath = "src/main/frege/org/frege/HelloFrege.fr") {
- def moduleFolder = new File(testProjectDir.root, modulePath).parentFile
- moduleFolder.mkdirs()
- def moduleSource = testProjectDir.newFile(modulePath)
- moduleSource << """
- module org.frege.HelloFrege where
-
- greeting = "Hello Frege!"
-
- main _ = do
- println greeting
- """
- }
-
- def "can reference java from frege"() {
- given:
- buildFile << """
- dependencies {
- compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION"
- }
- ${sayHelloTask()}
- """
-
- and:
- javaCode()
- fregeCallingJava()
- when:
- BuildResult result = run("sayHello")
- then:
- result.task(":compileJava").outcome == SUCCESS
- result.task(":compileFrege").outcome == SUCCESS
- result.output.contains("hello from java")
- }
-
- def "can run frege doc on frege module"() {
- given:
- buildFile << """
- dependencies {
- compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION"
- }
- ext.destinationDir = "docs"
- """
-
- and:
- fregeModule()
- when:
- BuildResult result = run("fregeDoc")
- then:
- result.task(":fregeDoc").outcome == SUCCESS
- }
-
-
- def "frege doc works with mixed sources"() {
- given:
- buildFile << """
- dependencies {
- compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION"
- }
- """
-
- and:
- javaCode()
- fregeCallingJava()
- when:
- BuildResult result = run("fregeDoc")
- then:
- result.task(":fregeDoc").outcome == SUCCESS
- }
-
- def "supports additional source sets"() {
- given:
- buildFile << """
-
- sourceSets {
- api
- }
-
- dependencies {
- apiCompile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION"
- }
-
-
- """
- and:
- javaCode()
- fregeModule("src/api/frege/org/frege/HelloFrege.fr")
- when:
- BuildResult result = run("apiClasses")
- then:
- result.task(":compileApiJava").outcome == UP_TO_DATE
- result.task(":compileApiFrege").outcome == SUCCESS
- classFileExists("api/org/frege/HelloFrege.class")
- }
-
- def classFileExists(String relativeClasspath) {
- assert new File(testProjectDir.root, "build/classes/$relativeClasspath/").exists()
- true
- }
-
- def fregeCallingJava() {
-
- File fregeSourceFile = testProjectDir.newFile("src/main/frege/org/frege/HelloFrege.fr")
- fregeSourceFile << """
- module org.frege.HelloFrege where
-
- data StaticHello = pure native org.frege.java.StaticHello where
- pure native helloJava org.frege.java.StaticHello.helloJava:: () -> String
-
-
- main _ = do
- println(StaticHello.helloJava())
-
- """
- }
-
- def javaCode(String sourceRoot = "java") {
- def javaSourceFile = testProjectDir.newFile("src/main/$sourceRoot/org/frege/java/StaticHello.java")
-
- javaSourceFile << """
- package org.frege.java;
-
- public class StaticHello {
- public static String helloJava() {
- return "hello from java";
- }
- }
- """
- }
-
- def sayHelloTask() {
- return """ task sayHello(type: JavaExec) {
- classpath = sourceSets.main.runtimeClasspath
- main = 'org.frege.HelloFrege'
- } """
- }
-} \ No newline at end of file