diff --git a/TODO.md b/TODO.md index 31b99fd..824b466 100644 --- a/TODO.md +++ b/TODO.md @@ -8,11 +8,14 @@ ## Medium Projects * [ ] Figure out how to use newer versions of GraalVM on all platforms for the JS parser. -* [ ] Finish and test the comment writer functionality from PR 48. -* [ ] Add test coverage for any other code that isn't already covered. +* [ ] Write tests: + * [ ] PR #48 (write descriptions as comments in exported config values) + * [ ] File watcher on Windows/Linux (inc. `InvalidWatchKeyException`) + * [ ] Description of required, optional, and lazy config items + * [ ] Other random areas that aren't explicitly listed in this ## Large Projects * [ ] Move all configuration format parsers to KotlinX Serialization instead of a mix of Jackson modules and various third-party parsers. - * This would enable use of Konf on Kotlin Multiplatform projects! \ No newline at end of file + * This could help enable use of Konf on Kotlin Multiplatform projects, but it would be extremely challenging. \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 3094545..0ca05d7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -40,6 +40,7 @@ develocity { dependencyResolutionManagement { versionCatalogs { create("libs") { + // Shared versions version("jackson", "2.17.1") // WARNING! // Don't upgrade the GraalVM dependency version! @@ -47,12 +48,14 @@ dependencyResolutionManagement { // There is no documented fix on non-Graal JDKs. version("graal", "22.3.5") + // Gradle plugins plugin("dokka", "org.jetbrains.dokka").version("1.9.20") plugin("kover", "org.jetbrains.kotlinx.kover").version("0.8.0") plugin("benchmark", "org.jetbrains.kotlinx.benchmark").version("0.4.10") plugin("sonatype-publisher", "net.thebugmc.gradle.sonatype-central-portal-publisher").version("1.2.3") plugin("solo-publisher", "ca.solo-studios.sonatype-publish").version("0.1.3") + // Dependencies library("kotlinx-coroutines-core", "org.jetbrains.kotlinx", "kotlinx-coroutines-core").version("1.8.1") library("reflections", "org.reflections", "reflections").version("0.10.2") library("commons-text", "org.apache.commons", "commons-text").version("1.12.0") @@ -69,11 +72,16 @@ dependencyResolutionManagement { library("dom4j", "org.dom4j", "dom4j").version("2.1.4") library("jaxen", "jaxen", "jaxen").version("2.0.0") library("snakeyaml", "org.yaml", "snakeyaml").version("2.2") + + // Test dependencies library("junit-params", "org.junit.jupiter", "junit-jupiter-params").version("5.10.2") library("spark", "com.sparkjava", "spark-core").version("2.9.4") library("slf4j-simple", "org.slf4j", "slf4j-simple").version("2.0.13") + + // Benchmark dependencies library("kotlinx-benchmark-runtime", "org.jetbrains.kotlinx", "kotlinx-benchmark-runtime").version("0.4.10") + // Library bundles bundle("jackson", listOf("jackson-core", "jackson-annotations", "jackson-databind", "jackson-kotlin", "jackson-jsr310")) bundle("graal", listOf("graal-sdk", "graal-js")) } diff --git a/src/test/kotlin/io/github/nhubbard/konf/TestInvalidWatchKey.kt b/src/test/kotlin/io/github/nhubbard/konf/TestInvalidWatchKey.kt index ae3ba3b..9801d41 100644 --- a/src/test/kotlin/io/github/nhubbard/konf/TestInvalidWatchKey.kt +++ b/src/test/kotlin/io/github/nhubbard/konf/TestInvalidWatchKey.kt @@ -18,10 +18,13 @@ package io.github.nhubbard.konf import io.github.nhubbard.konf.helpers.InvalidWatchKey -import org.junit.jupiter.api.AfterAll +import kotlinx.coroutines.MainScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance -import java.nio.file.Paths +import java.util.concurrent.TimeUnit import kotlin.io.path.deleteIfExists import kotlin.io.path.writeText @@ -34,24 +37,33 @@ class TestInvalidWatchKey { | "second": "test_data" |} """.trimMargin() - private val inputFile = Paths.get("src/test/resources/invalid_watch.json") + private val inputFile = tempFileOf(input, suffix = ".json").toPath() + + @BeforeAll + fun preTestSetup() { + inputFile.writeText(input) + } @Test fun testWatchKey_onBecomingInvalid_itThrows() { + // This test does not cover the correct branches on macOS if ("mac" !in System.getProperty("os.name").lowercase()) { // Write valid test data to input file inputFile.writeText(input) // Open valid data - Config { + val config = Config { addSpec(InvalidWatchKey) - }.from.json.watchFile(inputFile.toFile()) - // Overwrite the file with invalid data - inputFile.writeText("asofidmaposidfmpoasimdf") + }.from.json.watchFile(inputFile.toFile(), delayTime = 50, unit = TimeUnit.MILLISECONDS) + // Make watch key invalid??? + inputFile.deleteIfExists() + // Wait for several seconds... + MainScope().launch { + delay(10000) + println(config[InvalidWatchKey.first]) + println(config[InvalidWatchKey.second]) + } + // Attempt to access invalid value??? + config[InvalidWatchKey.second] } } - - @AfterAll - fun postTestCleanup() { - inputFile.deleteIfExists() - } } \ No newline at end of file