-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
490 additions
and
56 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.jetbrains.dokka | ||
|
||
class DokkaException(message: String) : RuntimeException(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
117 changes: 117 additions & 0 deletions
117
plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package basic | ||
|
||
import org.jetbrains.dokka.DokkaException | ||
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest | ||
import org.jetbrains.dokka.utilities.DokkaConsoleLogger | ||
import org.jetbrains.dokka.utilities.DokkaLogger | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.assertThrows | ||
|
||
class FailOnWarningTest : AbstractCoreTest() { | ||
|
||
@Test | ||
fun `throws exception if one or more warnings were emitted`() { | ||
val configuration = dokkaConfiguration { | ||
failOnWarning = true | ||
passes { | ||
pass { | ||
sourceRoots = listOf("src/main/kotlin") | ||
} | ||
} | ||
} | ||
|
||
assertThrows<DokkaException> { | ||
testInline( | ||
""" | ||
|/src/main/kotlin | ||
|package sample | ||
""".trimIndent(), configuration | ||
) { | ||
analysisSetupStage = { | ||
logger.warn("Warning!") | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `throws exception if one or more error were emitted`() { | ||
val configuration = dokkaConfiguration { | ||
failOnWarning = true | ||
passes { | ||
pass { | ||
sourceRoots = listOf("src/main/kotlin") | ||
} | ||
} | ||
} | ||
|
||
assertThrows<DokkaException> { | ||
testInline( | ||
""" | ||
|/src/main/kotlin | ||
|package sample | ||
""".trimIndent(), configuration | ||
) { | ||
analysisSetupStage = { | ||
logger.error("Error!") | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `does not throw if now warning or error was emitted`() { | ||
logger = ZeroErrorOrWarningCountDokkaLogger() | ||
|
||
val configuration = dokkaConfiguration { | ||
failOnWarning = true | ||
passes { | ||
pass { | ||
sourceRoots = listOf("src/main/kotlin") | ||
} | ||
} | ||
} | ||
|
||
|
||
testInline( | ||
""" | ||
|/src/main/kotlin | ||
|package sample | ||
""".trimIndent(), configuration | ||
) { | ||
/* We expect no Exception */ | ||
} | ||
} | ||
|
||
@Test | ||
fun `does not throw if disabled`() { | ||
val configuration = dokkaConfiguration { | ||
failOnWarning = false | ||
passes { | ||
pass { | ||
sourceRoots = listOf("src/main/kotlin") | ||
} | ||
} | ||
} | ||
|
||
|
||
testInline( | ||
""" | ||
|/src/main/kotlin | ||
|package sample | ||
""".trimIndent(), configuration | ||
) { | ||
analysisSetupStage = { | ||
logger.warn("Error!") | ||
logger.error("Error!") | ||
} | ||
} | ||
} | ||
} | ||
|
||
private class ZeroErrorOrWarningCountDokkaLogger( | ||
logger: DokkaLogger = DokkaConsoleLogger | ||
) : DokkaLogger by logger { | ||
override var warningsCount: Int = 0 | ||
override var errorsCount: Int = 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.