[Gradle, Test] Reset locale to default when changing it for tests
Since `Locale.setDefault` is a global operation it will take effect on other test causing them to produce unexpectable results. ^KT-38712
This commit is contained in:
committed by
Space Team
parent
f09fb5ed09
commit
a37b548b9f
+12
-2
@@ -382,8 +382,17 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun `gradle entities should have correct names when default locale is turkish`() {
|
fun `gradle entities should have correct names when default locale is turkish`() {
|
||||||
Locale.setDefault(Locale("tr", "TR"))
|
fun withLocale(locale: Locale, code: () -> Unit) {
|
||||||
|
val currentLocal = Locale.getDefault()
|
||||||
|
try {
|
||||||
|
Locale.setDefault(locale)
|
||||||
|
code()
|
||||||
|
} finally {
|
||||||
|
Locale.setDefault(currentLocal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
withLocale(Locale("tr", "TR")) {
|
||||||
val project = buildProjectWithMPP {
|
val project = buildProjectWithMPP {
|
||||||
kotlin {
|
kotlin {
|
||||||
jvm()
|
jvm()
|
||||||
@@ -392,7 +401,7 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
|
|||||||
}
|
}
|
||||||
project.evaluate()
|
project.evaluate()
|
||||||
|
|
||||||
val gradleEntityNames: List<String> = with (project) {
|
val gradleEntityNames: List<String> = with(project) {
|
||||||
listOf(
|
listOf(
|
||||||
tasks.names,
|
tasks.names,
|
||||||
configurations.names,
|
configurations.names,
|
||||||
@@ -410,4 +419,5 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
|
|||||||
entityNamesWithTurkishI.joinToString("\n")
|
entityNamesWithTurkishI.joinToString("\n")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user