Skip to content

Commit 683b709

Browse files
committed
Added integration test for single source set with Java and Clojure
sources. Renamed test cases with backticks for more readable test output.
1 parent 8d04cc3 commit 683b709

File tree

10 files changed

+135
-10
lines changed

10 files changed

+135
-10
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2017 Colin Fleming
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id 'com.cursive-ide.clojure'
19+
}
20+
21+
repositories {
22+
mavenCentral()
23+
}
24+
25+
dependencies {
26+
compile 'org.clojure:clojure:1.8.0'
27+
}
28+
29+
compileClojure {
30+
aotCompile = true
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
;
2+
; Copyright 2017 Colin Fleming
3+
;
4+
; Licensed under the Apache License, Version 2.0 (the "License")
5+
; you may not use this file except in compliance with the License.
6+
; You may obtain a copy of the License at
7+
;
8+
; http://www.apache.org/licenses/LICENSE-2.0
9+
;
10+
; Unless required by applicable law or agreed to in writing, software
11+
; distributed under the License is distributed on an "AS IS" BASIS,
12+
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
; See the License for the specific language governing permissions and
14+
; limitations under the License.
15+
;
16+
17+
(ns clj-example.core)
18+
19+
(defn test [])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2017 Colin Fleming
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package javaExample;
18+
19+
public class Example {
20+
public void test() {
21+
}
22+
}

src/test/kotlin/cursive/BasicClojureProjectTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BasicClojureProjectTest : IntegrationTestBase() {
2424
val coreNsSourceFile = testProjectDir.resolve("src/main/clojure/basic_project/core.clj")
2525

2626
@Test
27-
fun basicClojureProjectBuildNoAot() {
27+
fun `Build without AOT only copies clj files to output directory`() {
2828
// when
2929
val result = projectBuildRunner().withArguments("check").build()
3030

@@ -39,7 +39,7 @@ class BasicClojureProjectTest : IntegrationTestBase() {
3939
}
4040

4141
@Test
42-
fun basicClojureProjectBuildWithAot() {
42+
fun `Build with AOT compiles to class files without copying clj files to output directory`() {
4343
// given
4444
projectGradleFile().appendText("compileClojure.aotCompile = true")
4545

src/test/kotlin/cursive/IncrementalCompilationTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class IncrementalCompilationTest : IntegrationTestBase() {
2424
val coreNsSourceFile = testProjectDir.resolve("src/main/clojure/basic_project/core.clj")
2525

2626
@Test
27-
fun incrementalCompileTaskUpToDateWhenNoChangesNoAot() {
27+
fun `Incremental compile task without AOT is up-to-date when no input changes`() {
2828
// when
2929
val firstRunResult = projectBuildRunner().withArguments("check").build()
3030

@@ -41,7 +41,7 @@ class IncrementalCompilationTest : IntegrationTestBase() {
4141
}
4242

4343
@Test
44-
fun incrementalCompileTaskUpToDateWhenNoChangesWithAot() {
44+
fun `Incremental compile task with AOT is up-to-date when no input changes`() {
4545
// given
4646
projectGradleFile().appendText("compileClojure.aotCompile = true")
4747

@@ -61,7 +61,7 @@ class IncrementalCompilationTest : IntegrationTestBase() {
6161
}
6262

6363
@Test
64-
fun incrementalCompileTaskExecutedWhenSourceFileChangedNoAot() {
64+
fun `Incremental compile task without AOT processes outdated source files when input changes`() {
6565
// given
6666
val utilsNsSourceFile = testProjectDir.resolve("src/main/clojure/basic_project/utils.clj")
6767

@@ -88,7 +88,7 @@ class IncrementalCompilationTest : IntegrationTestBase() {
8888
}
8989

9090
@Test
91-
fun incrementalCompileTaskExecutedWhenNewCljFileAddedWithAot() {
91+
fun `Incremental compile task with AOT processes outdated source files when input changes`() {
9292
// given
9393
projectGradleFile().appendText("compileClojure.aotCompile = true")
9494
val utilsNsSourceFile = testProjectDir.resolve("src/main/clojure/basic_project/utils.clj")
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2017 Colin Fleming
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package cursive
18+
19+
import org.assertj.core.api.KotlinAssertions.assertThat
20+
import org.gradle.testkit.runner.TaskOutcome
21+
import org.junit.Test
22+
23+
class JavaAndClojureInOneSourceSetTest : IntegrationTestBase() {
24+
val coreNsSourceFile = testProjectDir.resolve("src/main/clojure/clj_example/core.clj")
25+
val utilsNsSourceFile = testProjectDir.resolve("src/main/clojure/clj_example/utils.clj")
26+
val javaClassFile = testProjectDir.resolve("build/classes/main/javaExample/Example.class")
27+
28+
@Test
29+
fun `Incremental compile task does not remove Java class files`() {
30+
// when
31+
val firstRunResult = projectBuildRunner().withArguments("build").build()
32+
33+
// then
34+
assertThat(firstRunResult.task(":compileClojure").outcome).isEqualTo(TaskOutcome.SUCCESS)
35+
assertThat(firstRunResult.task(":compileJava").outcome).isEqualTo(TaskOutcome.SUCCESS)
36+
assertSourceFileIsOnlyCompiledToOutputDir(coreNsSourceFile)
37+
assertThat(javaClassFile.exists()).isTrue()
38+
39+
coreNsSourceFile.delete()
40+
utilsNsSourceFile.writeText("""(ns clj-example.utils) (defn ping [] "pong")""")
41+
42+
// when
43+
val secondRunResult = projectBuildRunner().withArguments("build").build()
44+
45+
// then
46+
assertThat(secondRunResult.task(":compileClojure").outcome).isEqualTo(TaskOutcome.SUCCESS)
47+
assertThat(secondRunResult.task(":compileJava").outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
48+
assertSourceFileNotCopiedToOutputDir(coreNsSourceFile)
49+
assertSourceFileNotCompiledToOutputDir(coreNsSourceFile)
50+
assertSourceFileIsOnlyCompiledToOutputDir(utilsNsSourceFile)
51+
assertThat(javaClassFile.exists()).isTrue()
52+
}
53+
}

src/test/kotlin/cursive/MixedClojureJavaTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import org.junit.Test
2222

2323
class MixedClojureJavaTest : IntegrationTestBase() {
2424
@Test
25-
fun compilationWithJavaCodeDependingOnClojureCode() {
25+
fun `Compilation with Java code depending on Clojure code`() {
2626
// given
2727
val cljSourceDir = testProjectDir.resolve("src/cljSS/clojure")
2828
val cljExampleNsFile = cljSourceDir.resolve("cljSS/Example.clj")

src/test/kotlin/cursive/MixedJavaClojureTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import org.junit.Test
2222

2323
class MixedJavaClojureTest : IntegrationTestBase() {
2424
@Test
25-
fun compilationWithClojureCodeDependingOnJavaCode() {
25+
fun `Compilation with Clojure code depending on Java code`() {
2626
// given
2727
val javaOutputDir = testProjectDir.resolve("build/classes/javaSS")
2828
val javaClassFile = javaOutputDir.resolve("javaSS/Example.class")

src/test/kotlin/cursive/MultipleSourceSetsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import org.junit.Test
2222

2323
class MultipleSourceSetsTest : IntegrationTestBase() {
2424
@Test
25-
fun compilationWithMultipleSourceSets() {
25+
fun `Compilation with multiple source sets`() {
2626
// given
2727
val ss1SourceDir = testProjectDir.resolve("src/ss1/clojure")
2828
val ss1CoreNsFile = ss1SourceDir.resolve("ss1/core.clj")

src/test/kotlin/cursive/TestFailureFailsBuildTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import org.junit.Test
2323

2424
class TestFailureFailsBuildTest : IntegrationTestBase() {
2525
@Test
26-
fun testFailureFailsBuild() {
26+
fun `testClojure task failure fails build`() {
2727
// when
2828
val result = projectBuildRunner().withArguments("check").buildAndFail()
2929

0 commit comments

Comments
 (0)