[Test] Add ability to configure tests by negative test location regex
This commit is contained in:
committed by
TeamCityServer
parent
2cb9d1f287
commit
a9ff030c73
+18
-3
@@ -39,7 +39,8 @@ class TestConfigurationBuilder {
|
|||||||
private val directives: MutableList<DirectivesContainer> = mutableListOf()
|
private val directives: MutableList<DirectivesContainer> = mutableListOf()
|
||||||
val defaultRegisteredDirectivesBuilder: RegisteredDirectivesBuilder = RegisteredDirectivesBuilder()
|
val defaultRegisteredDirectivesBuilder: RegisteredDirectivesBuilder = RegisteredDirectivesBuilder()
|
||||||
|
|
||||||
private val configurationsByTestDataCondition: MutableList<Pair<Regex, TestConfigurationBuilder.() -> Unit>> = mutableListOf()
|
private val configurationsByPositiveTestDataCondition: MutableList<Pair<Regex, TestConfigurationBuilder.() -> Unit>> = mutableListOf()
|
||||||
|
private val configurationsByNegativeTestDataCondition: MutableList<Pair<Regex, TestConfigurationBuilder.() -> Unit>> = mutableListOf()
|
||||||
private val additionalServices: MutableList<ServiceRegistrationData> = mutableListOf()
|
private val additionalServices: MutableList<ServiceRegistrationData> = mutableListOf()
|
||||||
|
|
||||||
private var compilerConfigurationProvider: ((Disposable, List<EnvironmentConfigurator>) -> CompilerConfigurationProvider)? = null
|
private var compilerConfigurationProvider: ((Disposable, List<EnvironmentConfigurator>) -> CompilerConfigurationProvider)? = null
|
||||||
@@ -59,6 +60,11 @@ class TestConfigurationBuilder {
|
|||||||
forTestsMatching(regex, configuration)
|
forTestsMatching(regex, configuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun forTestsNotMatching(pattern: String, configuration: TestConfigurationBuilder.() -> Unit) {
|
||||||
|
val regex = pattern.toMatchingRegexString().toRegex()
|
||||||
|
forTestsNotMatching(regex, configuration)
|
||||||
|
}
|
||||||
|
|
||||||
infix fun String.or(other: String): String {
|
infix fun String.or(other: String): String {
|
||||||
return """$this|$other"""
|
return """$this|$other"""
|
||||||
}
|
}
|
||||||
@@ -66,7 +72,11 @@ class TestConfigurationBuilder {
|
|||||||
private fun String.toMatchingRegexString(): String = """^${replace("*", ".*")}$"""
|
private fun String.toMatchingRegexString(): String = """^${replace("*", ".*")}$"""
|
||||||
|
|
||||||
fun forTestsMatching(pattern: Regex, configuration: TestConfigurationBuilder.() -> Unit) {
|
fun forTestsMatching(pattern: Regex, configuration: TestConfigurationBuilder.() -> Unit) {
|
||||||
configurationsByTestDataCondition += pattern to configuration
|
configurationsByPositiveTestDataCondition += pattern to configuration
|
||||||
|
}
|
||||||
|
|
||||||
|
fun forTestsNotMatching(pattern: Regex, configuration: TestConfigurationBuilder.() -> Unit) {
|
||||||
|
configurationsByNegativeTestDataCondition += pattern to configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun globalDefaults(init: DefaultsProviderBuilder.() -> Unit) {
|
inline fun globalDefaults(init: DefaultsProviderBuilder.() -> Unit) {
|
||||||
@@ -148,11 +158,16 @@ class TestConfigurationBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun build(testDataPath: String): TestConfiguration {
|
fun build(testDataPath: String): TestConfiguration {
|
||||||
for ((regex, configuration) in configurationsByTestDataCondition) {
|
for ((regex, configuration) in configurationsByPositiveTestDataCondition) {
|
||||||
if (regex.matches(testDataPath)) {
|
if (regex.matches(testDataPath)) {
|
||||||
this.configuration()
|
this.configuration()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for ((regex, configuration) in configurationsByNegativeTestDataCondition) {
|
||||||
|
if (!regex.matches(testDataPath)) {
|
||||||
|
this.configuration()
|
||||||
|
}
|
||||||
|
}
|
||||||
return TestConfigurationImpl(
|
return TestConfigurationImpl(
|
||||||
testInfo,
|
testInfo,
|
||||||
defaultsProviderBuilder.build(),
|
defaultsProviderBuilder.build(),
|
||||||
|
|||||||
Reference in New Issue
Block a user