diff --git a/ktlint-cli-reporter-baseline/src/test/kotlin/com/pinterest/ktlint/cli/reporter/baseline/BaselineTest.kt b/ktlint-cli-reporter-baseline/src/test/kotlin/com/pinterest/ktlint/cli/reporter/baseline/BaselineTest.kt index 50f83d7246..d95348f06e 100644 --- a/ktlint-cli-reporter-baseline/src/test/kotlin/com/pinterest/ktlint/cli/reporter/baseline/BaselineTest.kt +++ b/ktlint-cli-reporter-baseline/src/test/kotlin/com/pinterest/ktlint/cli/reporter/baseline/BaselineTest.kt @@ -12,6 +12,8 @@ import io.github.oshai.kotlinlogging.KotlinLogging import nl.altindag.log.LogCaptor import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatExceptionOfType +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir @@ -20,6 +22,7 @@ import org.junit.jupiter.params.provider.EnumSource import org.xml.sax.SAXParseException import java.nio.file.Path import java.nio.file.Paths +import java.util.Locale import kotlin.io.path.Path import kotlin.io.path.copyTo import kotlin.io.path.pathString @@ -43,6 +46,17 @@ private fun KLogger.underlyingLogger(): Logger? = ?.underlyingLogger class BaselineTest { + private val currentLocale = Locale.getDefault() + + @BeforeEach + fun setLocaleEnglish() { + // SAXParseException messages are localized. Prevent tests from failing when run on a system for which local is not set to English. + Locale.setDefault(Locale.ENGLISH) + } + + @AfterEach + fun resetLocaleDefault() = Locale.setDefault(currentLocale) + @Nested inner class `Given a valid baseline file` { @Test