aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/base-test-utils/src/main/kotlin/utils
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/base-test-utils/src/main/kotlin/utils')
-rw-r--r--plugins/base/base-test-utils/src/main/kotlin/utils/TestOutputWriter.kt47
-rw-r--r--plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt24
2 files changed, 0 insertions, 71 deletions
diff --git a/plugins/base/base-test-utils/src/main/kotlin/utils/TestOutputWriter.kt b/plugins/base/base-test-utils/src/main/kotlin/utils/TestOutputWriter.kt
deleted file mode 100644
index 089a94ca..00000000
--- a/plugins/base/base-test-utils/src/main/kotlin/utils/TestOutputWriter.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package utils
-
-import org.jetbrains.dokka.base.DokkaBase
-import org.jetbrains.dokka.base.renderers.OutputWriter
-import org.jetbrains.dokka.plugability.DokkaPlugin
-import org.jetbrains.dokka.plugability.DokkaPluginApiPreview
-import org.jetbrains.dokka.plugability.Extension
-import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement
-import java.util.*
-
-public class TestOutputWriterPlugin(failOnOverwrite: Boolean = true) : DokkaPlugin() {
- public val writer: TestOutputWriter = TestOutputWriter(failOnOverwrite)
-
- private val dokkaBase by lazy { plugin<DokkaBase>() }
-
- public val testWriter: Extension<OutputWriter, *, *> by extending {
- (dokkaBase.outputWriter
- with writer
- override dokkaBase.fileWriter)
- }
-
- @OptIn(DokkaPluginApiPreview::class)
- override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement =
- PluginApiPreviewAcknowledgement
-}
-
-public class TestOutputWriter(
- private val failOnOverwrite: Boolean = true
-) : OutputWriter {
- public val contents: Map<String, String> get() = _contents
- private val _contents = Collections.synchronizedMap(mutableMapOf<String, String>())
-
- override suspend fun write(path: String, text: String, ext: String) {
- val fullPath = "$path$ext"
- _contents.putIfAbsent(fullPath, text)?.also {
- if (failOnOverwrite) throw AssertionError("File $fullPath is being overwritten.")
- }
- }
-
- override suspend fun writeResources(pathFrom: String, pathTo: String) {
- write(pathTo, "*** content of $pathFrom ***", "")
- }
-}
diff --git a/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt b/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt
deleted file mode 100644
index 207ebb8a..00000000
--- a/plugins/base/base-test-utils/src/main/kotlin/utils/assertHtmlEqualsIgnoringWhitespace.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package utils
-
-import org.jsoup.Jsoup
-import org.jsoup.nodes.Document
-import kotlin.test.assertEquals
-
-/**
- * Parses it using JSOUP, trims whitespace at the end of the line and asserts if they are equal
- * parsing is required to unify the formatting
- */
-public fun assertHtmlEqualsIgnoringWhitespace(expected: String, actual: String) {
- val ignoreFormattingSettings = Document.OutputSettings().indentAmount(0).outline(true)
- assertEquals(
- Jsoup.parse(expected).outputSettings(ignoreFormattingSettings).outerHtml().trimSpacesAtTheEndOfLine(),
- Jsoup.parse(actual).outputSettings(ignoreFormattingSettings).outerHtml().trimSpacesAtTheEndOfLine()
- )
-}
-
-private fun String.trimSpacesAtTheEndOfLine(): String =
- replace(" \n", "\n")