Skip to content

Commit 858911e

Browse files
authored
Merge pull request #370 from Kotlin/korro-outputs
Korro outputs
2 parents 649226a + 37f670a commit 858911e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+57
-877
lines changed

core/build.gradle.kts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import com.google.devtools.ksp.gradle.KspTaskJvm
22
import com.google.devtools.ksp.gradle.KspTask
3+
import io.github.devcrocod.korro.KorroTask
34
import nl.jolanrensen.docProcessor.defaultProcessors.*
45
import nl.jolanrensen.docProcessor.gradle.creatingProcessDocTask
56
import org.gradle.jvm.tasks.Jar
@@ -76,7 +77,7 @@ val samplesImplementation by configurations.getting {
7677
extendsFrom(configurations.testImplementation.get())
7778
}
7879

79-
val myKotlinCompileTask = tasks.named<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>("compileSamplesKotlin") {
80+
val compileSamplesKotlin = tasks.named<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>("compileSamplesKotlin") {
8081
friendPaths.from(sourceSets["main"].output.classesDirs)
8182
source(sourceSets["test"].kotlin)
8283
destinationDirectory.set(file("$buildDir/classes/testWithOutputs/kotlin"))
@@ -94,17 +95,17 @@ tasks.named("lintKotlinSamples") {
9495
onlyIf { false }
9596
}
9697

98+
val clearTestResults by tasks.creating(Delete::class) {
99+
delete(File(buildDir, "dataframes"))
100+
delete(File(buildDir, "korroOutputLines"))
101+
}
102+
97103
val samplesTest = tasks.register<Test>("samplesTest") {
98104
group = "Verification"
99105
description = "Runs the custom tests."
100106

101-
dependsOn(myKotlinCompileTask)
102-
103-
doFirst {
104-
delete {
105-
delete(fileTree(File(buildDir, "dataframes")))
106-
}
107-
}
107+
dependsOn(compileSamplesKotlin)
108+
dependsOn(clearTestResults)
108109

109110
environment("DATAFRAME_SAVE_OUTPUTS", "")
110111

@@ -132,11 +133,15 @@ val copySamplesOutputs = tasks.register<JavaExec>("copySamplesOutputs") {
132133
group = "documentation"
133134
mainClass.set("org.jetbrains.kotlinx.dataframe.explainer.SampleAggregatorKt")
134135

135-
dependsOn(samplesTest)
136136
dependsOn(clearSamplesOutputs)
137+
dependsOn(samplesTest)
137138
classpath = sourceSets.test.get().runtimeClasspath
138139
}
139140

141+
tasks.withType<KorroTask> {
142+
dependsOn(copySamplesOutputs)
143+
}
144+
140145
val generatedSourcesFolderName = "generated-sources"
141146
val addGeneratedSourcesToGit by tasks.creating(GitTask::class) {
142147
directory.set(file("."))
@@ -217,6 +222,10 @@ korro {
217222
include("src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/*.kt")
218223
}
219224

225+
outputs = fileTree(project.buildDir) {
226+
include("korroOutputLines/*")
227+
}
228+
220229
groupSamples {
221230

222231
beforeSample.set("<tab title=\"NAME\">\n")

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/explainer/PluginCallbackProxy.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@ object PluginCallbackProxy : PluginCallback {
130130
it.mkdirs()
131131
}
132132
output.writeHTML(File(destination, "$name.html"))
133+
val korro = File("build/korroOutputLines").also {
134+
it.mkdirs()
135+
}
136+
137+
val group = name.substringBefore("_")
138+
File(korro, group).writeText(
139+
"""
140+
141+
<dataFrame src="$group.html"/>
142+
""".trimIndent()
143+
)
133144
}
134145

135146
private fun statementOutput(

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Render.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class Render : TestBase() {
2626
}
2727

2828
@Test
29-
@TransformDataFrameExpressions
3029
fun composeTables() {
3130
// SampleStart
3231
val df1 = df.reorderColumnsByName()

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/explainer/PluginCallbackProxy.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@ object PluginCallbackProxy : PluginCallback {
130130
it.mkdirs()
131131
}
132132
output.writeHTML(File(destination, "$name.html"))
133+
val korro = File("build/korroOutputLines").also {
134+
it.mkdirs()
135+
}
136+
137+
val group = name.substringBefore("_")
138+
File(korro, group).writeText(
139+
"""
140+
141+
<dataFrame src="$group.html"/>
142+
""".trimIndent()
143+
)
133144
}
134145

135146
private fun statementOutput(

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Render.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class Render : TestBase() {
2626
}
2727

2828
@Test
29-
@TransformDataFrameExpressions
3029
fun composeTables() {
3130
// SampleStart
3231
val df1 = df.reorderColumnsByName()

0 commit comments

Comments
 (0)