[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
+33
-23
@@ -382,32 +382,42 @@ 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()
|
||||||
val project = buildProjectWithMPP {
|
try {
|
||||||
kotlin {
|
Locale.setDefault(locale)
|
||||||
jvm()
|
code()
|
||||||
ios()
|
} finally {
|
||||||
|
Locale.setDefault(currentLocal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
project.evaluate()
|
|
||||||
|
|
||||||
val gradleEntityNames: List<String> = with (project) {
|
withLocale(Locale("tr", "TR")) {
|
||||||
listOf(
|
val project = buildProjectWithMPP {
|
||||||
tasks.names,
|
kotlin {
|
||||||
configurations.names,
|
jvm()
|
||||||
components.names,
|
ios()
|
||||||
extensions.asMap.keys,
|
}
|
||||||
kotlin.sourceSets.names,
|
}
|
||||||
kotlin.targets.names,
|
project.evaluate()
|
||||||
).flatten()
|
|
||||||
|
val gradleEntityNames: List<String> = with(project) {
|
||||||
|
listOf(
|
||||||
|
tasks.names,
|
||||||
|
configurations.names,
|
||||||
|
components.names,
|
||||||
|
extensions.asMap.keys,
|
||||||
|
kotlin.sourceSets.names,
|
||||||
|
kotlin.targets.names,
|
||||||
|
).flatten()
|
||||||
|
}
|
||||||
|
|
||||||
|
val entityNamesWithTurkishI = gradleEntityNames.filter { it.contains('İ') || it.contains('ı') }
|
||||||
|
assertTrue(
|
||||||
|
entityNamesWithTurkishI.isEmpty(),
|
||||||
|
"Following entities should not have turkish 'İ' or 'ı' in their names:\n" +
|
||||||
|
entityNamesWithTurkishI.joinToString("\n")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val entityNamesWithTurkishI = gradleEntityNames.filter { it.contains('İ') || it.contains('ı') }
|
|
||||||
assertTrue(
|
|
||||||
entityNamesWithTurkishI.isEmpty(),
|
|
||||||
"Following entities should not have turkish 'İ' or 'ı' in their names:\n" +
|
|
||||||
entityNamesWithTurkishI.joinToString("\n")
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user