diff options
author | Rene Groeschke <rene@gradle.com> | 2015-11-18 12:48:31 +0000 |
---|---|---|
committer | Rene Groeschke <rene@gradle.com> | 2015-11-18 12:48:31 +0000 |
commit | da9a1b100639e7eb5a7986952f5a1f3ba0d675e6 (patch) | |
tree | 5a6227a8f7417a4cca0a522fe3e9ecf83bcc469a /src/integTest/groovy | |
parent | acfa74706b83d620c675df81fcb81b805f6293a8 (diff) | |
download | frege-gradle-plugin-da9a1b100639e7eb5a7986952f5a1f3ba0d675e6.tar.gz frege-gradle-plugin-da9a1b100639e7eb5a7986952f5a1f3ba0d675e6.tar.bz2 frege-gradle-plugin-da9a1b100639e7eb5a7986952f5a1f3ba0d675e6.zip |
Add infrastructure for adding integration tests using testkit
Diffstat (limited to 'src/integTest/groovy')
-rw-r--r-- | src/integTest/groovy/frege/plugin/FregePluginIntegTest.groovy | 77 |
1 files changed, 77 insertions, 0 deletions
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<File> 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 |