Skip to content

Commit

Permalink
Reduce stdout logging during tests (#273)
Browse files Browse the repository at this point in the history
- Avoid forwarding Gradle TestKit logs, unless the test fails.
- Fix Kotest classpath scan warning.
- Don't log 'test started' events
  • Loading branch information
aSemy authored Sep 8, 2024
1 parent e9416bd commit 230e441
Show file tree
Hide file tree
Showing 21 changed files with 140 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ tasks.withType<AbstractTestTask>().configureEach {
TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STARTED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT,
)
Expand Down
22 changes: 7 additions & 15 deletions modules/dokkatoo-plugin-integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ testing.suites {
// workaround for lazy-properties not working https://github.com/gradle/gradle/issues/12247
systemProperty("exampleProjectsDir", dokkatooExamplesDir.get())
}

systemProperty(
"kotest.framework.config.fqn",
"dev.adamko.dokkatoo.utils.KotestProjectConfig",
)
// FIXME remove autoscan when Kotest >= 6.0
systemProperty("kotest.framework.classpath.scanning.autoscan.disable", "true")
}
}
}
Expand Down Expand Up @@ -129,21 +136,6 @@ tasks.withType<Test>().configureEach {
)

mustRunAfter(tasks.withType<AbstractPublishToMaven>())

testLogging {
events = setOf(
TestLogEvent.STARTED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.FAILED,
TestLogEvent.STANDARD_OUT,
TestLogEvent.STANDARD_ERROR,
)
showStandardStreams = true
showExceptions = true
showCauses = true
showStackTraces = true
}
}
//endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class CompositeBuildExampleTest : FunSpec({
":build",
"--stacktrace",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"
}
Expand All @@ -39,8 +38,9 @@ class CompositeBuildExampleTest : FunSpec({
test("expect file trees are the same") {
val expectedFileTree = exampleDataDir.toTreeString()
val actualFileTree = dokkatooHtmlDir.toTreeString()
println((actualFileTree to expectedFileTree).sideBySide())
expectedFileTree shouldBe actualFileTree
withClue((actualFileTree to expectedFileTree).sideBySide()) {
expectedFileTree shouldBe actualFileTree
}
}

test("expect directories are the same") {
Expand All @@ -64,7 +64,6 @@ class CompositeBuildExampleTest : FunSpec({
":build",
"--stacktrace",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"
}
Expand All @@ -75,7 +74,6 @@ class CompositeBuildExampleTest : FunSpec({
"--stacktrace",
"--build-cache",
)
.forwardOutput()
.build {
output shouldContainAll listOf(
"> Task :module-kakapo:dokkatooGenerateModuleHtml UP-TO-DATE",
Expand Down Expand Up @@ -105,7 +103,6 @@ class CompositeBuildExampleTest : FunSpec({
"--no-build-cache",
"--configuration-cache",
)
.forwardOutput()

test("first build should store the configuration cache") {
configCacheRunner.build {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class CustomFormatExampleTest : FunSpec({
"--stacktrace",
"--info",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"
output shouldContain "Generation completed successfully"
Expand All @@ -47,7 +46,6 @@ class CustomFormatExampleTest : FunSpec({
"--stacktrace",
"--info",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"

Expand All @@ -67,9 +65,10 @@ class CustomFormatExampleTest : FunSpec({
test("expect file trees are the same") {
val expectedFileTree = dokkaHtmlDir.toTreeString()
val actualFileTree = dokkatooHtmlDir.toTreeString()
println((actualFileTree to expectedFileTree).sideBySide())
// drop the first line from each, since the directory name is different
expectedFileTree.substringAfter("\n") shouldBe actualFileTree.substringAfter("\n")
withClue((actualFileTree to expectedFileTree).sideBySide()) {
// drop the first line from each, since the directory name is different
expectedFileTree.substringAfter("\n") shouldBe actualFileTree.substringAfter("\n")
}
}

test("expect directories are the same") {
Expand All @@ -89,7 +88,6 @@ class CustomFormatExampleTest : FunSpec({
"--stacktrace",
"--info",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"

Expand All @@ -108,7 +106,6 @@ class CustomFormatExampleTest : FunSpec({
"--build-cache",
"--info",
)
.forwardOutput()
.build {
output shouldContainAll listOf(
"> Task :dokkatooGeneratePublicationHtml UP-TO-DATE",
Expand All @@ -134,7 +131,6 @@ class CustomFormatExampleTest : FunSpec({
"--no-build-cache",
"--configuration-cache",
)
.forwardOutput()

test("first build should store the configuration cache") {
configCacheRunner.build {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class GradleExampleTest : FunSpec({
"--stacktrace",
"--info",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"
output shouldContain "Generation completed successfully"
Expand All @@ -49,7 +48,6 @@ class GradleExampleTest : FunSpec({
"--stacktrace",
"--info",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"

Expand All @@ -69,8 +67,9 @@ class GradleExampleTest : FunSpec({
test("expect file trees are the same") {
val expectedFileTree = dokkaHtmlDir.toTreeString()
val actualFileTree = dokkatooHtmlDir.toTreeString()
println((actualFileTree to expectedFileTree).sideBySide())
expectedFileTree shouldBe actualFileTree
withClue((actualFileTree to expectedFileTree).sideBySide()) {
expectedFileTree shouldBe actualFileTree
}
}

test("expect directories are the same") {
Expand All @@ -90,7 +89,6 @@ class GradleExampleTest : FunSpec({
"--stacktrace",
"--info",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"

Expand All @@ -110,7 +108,6 @@ class GradleExampleTest : FunSpec({
"--info",
"--build-cache",
)
.forwardOutput()
.build {
output shouldContainAll listOf(
"> Task :dokkatooGeneratePublicationHtml UP-TO-DATE",
Expand All @@ -136,7 +133,6 @@ class GradleExampleTest : FunSpec({
"--no-build-cache",
"--configuration-cache",
)
.forwardOutput()

test("first build should store the configuration cache") {
configCacheRunner.build {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class JavaExampleTest : FunSpec({
":dokkatooGeneratePublicationHtml",
"--stacktrace",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"
}
Expand All @@ -39,8 +38,9 @@ class JavaExampleTest : FunSpec({
test("expect file trees are the same") {
val expectedFileTree = exampleDataDir.toTreeString()
val actualFileTree = dokkatooHtmlDir.toTreeString()
println((actualFileTree to expectedFileTree).sideBySide())
expectedFileTree shouldBe actualFileTree
withClue((actualFileTree to expectedFileTree).sideBySide()) {
expectedFileTree shouldBe actualFileTree
}
}

test("expect directories are the same") {
Expand All @@ -64,7 +64,6 @@ class JavaExampleTest : FunSpec({
":dokkatooGeneratePublicationHtml",
"--stacktrace",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"
}
Expand All @@ -75,7 +74,6 @@ class JavaExampleTest : FunSpec({
"--stacktrace",
"--build-cache",
)
.forwardOutput()
.build {
output shouldContainAll listOf(
"> Task :my-java-application:dokkatooGenerateModuleHtml UP-TO-DATE",
Expand Down Expand Up @@ -106,7 +104,6 @@ class JavaExampleTest : FunSpec({
"--no-build-cache",
"--configuration-cache",
)
.forwardOutput()

test("first build should store the configuration cache") {
configCacheRunner.build {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class KotlinMultiplatformExampleTest : FunSpec({
"--stacktrace",
"--info",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"
output shouldContain "Generation completed successfully"
Expand All @@ -46,7 +45,6 @@ class KotlinMultiplatformExampleTest : FunSpec({
"--stacktrace",
"--info",
)
.forwardOutput()
.build {
test("expect build is successful") {
output shouldContain "BUILD SUCCESSFUL"
Expand Down Expand Up @@ -74,8 +72,9 @@ class KotlinMultiplatformExampleTest : FunSpec({
test("expect file trees are the same") {
val expectedFileTree = dokkaHtmlDir.toTreeString()
val actualFileTree = dokkatooHtmlDir.toTreeString()
println((actualFileTree to expectedFileTree).sideBySide())
expectedFileTree shouldBe actualFileTree
withClue((actualFileTree to expectedFileTree).sideBySide()) {
expectedFileTree shouldBe actualFileTree
}
}

test("expect directories are the same") {
Expand All @@ -95,7 +94,6 @@ class KotlinMultiplatformExampleTest : FunSpec({
":dokkatooGeneratePublicationHtml",
"--stacktrace",
)
.forwardOutput()
.build {
test("expect build is successful") {
output shouldContain "BUILD SUCCESSFUL"
Expand All @@ -122,7 +120,6 @@ class KotlinMultiplatformExampleTest : FunSpec({
"--info",
"--build-cache",
)
.forwardOutput()
.build {

output shouldContainAll listOf(
Expand Down Expand Up @@ -150,7 +147,6 @@ class KotlinMultiplatformExampleTest : FunSpec({
"--no-build-cache",
"--configuration-cache",
)
.forwardOutput()

test("first build should store the configuration cache") {
configCacheRunner.build {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.adamko.dokkatoo.tests.examples
import dev.adamko.dokkatoo.internal.DokkatooConstants.DOKKA_VERSION
import dev.adamko.dokkatoo.utils.*
import dev.adamko.dokkatoo.utils.GradleProjectTest.Companion.projectTestTempDir
import io.kotest.assertions.withClue
import io.kotest.core.spec.style.FunSpec
import io.kotest.inspectors.shouldForAll
import io.kotest.matchers.collections.shouldHaveSize
Expand Down Expand Up @@ -34,7 +35,6 @@ class MultimoduleExampleTest : FunSpec({
"--stacktrace",
"--info",
)
.forwardOutput()
.build {
output shouldContain "BUILD SUCCESSFUL"
output shouldContain "Generation completed successfully"
Expand All @@ -49,7 +49,6 @@ class MultimoduleExampleTest : FunSpec({
"--stacktrace",
"--info",
)
.forwardOutput()
.build {
test("expect build is successful") {
output shouldContain "BUILD SUCCESSFUL"
Expand Down Expand Up @@ -77,8 +76,9 @@ class MultimoduleExampleTest : FunSpec({
test("expect file trees are the same") {
val expectedFileTree = dokkaHtmlDir.toTreeString()
val actualFileTree = dokkatooHtmlDir.toTreeString()
println((actualFileTree to expectedFileTree).sideBySide())
expectedFileTree shouldBe actualFileTree
withClue((actualFileTree to expectedFileTree).sideBySide()) {
expectedFileTree shouldBe actualFileTree
}
}

test("expect directories are the same") {
Expand All @@ -98,7 +98,6 @@ class MultimoduleExampleTest : FunSpec({
":parentProject:dokkatooGeneratePublicationHtml",
"--stacktrace",
)
.forwardOutput()
.build {
test("expect first build is successful") {
output shouldContain "BUILD SUCCESSFUL"
Expand All @@ -124,7 +123,6 @@ class MultimoduleExampleTest : FunSpec({
"--info",
"--build-cache",
)
.forwardOutput()
.build {
test("expect second build is successful") {
output shouldContain "BUILD SUCCESSFUL"
Expand Down Expand Up @@ -160,7 +158,6 @@ class MultimoduleExampleTest : FunSpec({
"--no-build-cache",
"--configuration-cache",
)
.forwardOutput()

test("first build should store the configuration cache") {
configCacheRunner.build {
Expand Down
Loading

0 comments on commit 230e441

Please sign in to comment.