Test infra: allow adding new AnalysisHandler's when existing ones present
This commit is contained in:
committed by
TeamCityServer
parent
451464d635
commit
7ed4984d11
+14
-8
@@ -115,12 +115,15 @@ class TestConfigurationBuilder {
|
|||||||
artifactKind: TestArtifactKind<I>,
|
artifactKind: TestArtifactKind<I>,
|
||||||
init: HandlersStepBuilder<I>.() -> Unit
|
init: HandlersStepBuilder<I>.() -> Unit
|
||||||
): HandlersStepBuilder<I> {
|
): HandlersStepBuilder<I> {
|
||||||
val step = handlersStep(artifactKind, init)
|
val previouslyContainedStep = namedStepOfType<I>(name)
|
||||||
val previouslyContainedStep = namedSteps.put(name, step)
|
if (previouslyContainedStep == null) {
|
||||||
if (previouslyContainedStep != null) {
|
val step = handlersStep(artifactKind, init)
|
||||||
error { "Step with name \"$name\" already registered" }
|
namedSteps[name] = step
|
||||||
|
return step
|
||||||
|
} else {
|
||||||
|
configureNamedHandlersStep(name, artifactKind, init)
|
||||||
|
return previouslyContainedStep
|
||||||
}
|
}
|
||||||
return step
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <I : ResultingArtifact<I>> configureNamedHandlersStep(
|
inline fun <I : ResultingArtifact<I>> configureNamedHandlersStep(
|
||||||
@@ -128,11 +131,14 @@ class TestConfigurationBuilder {
|
|||||||
artifactKind: TestArtifactKind<I>,
|
artifactKind: TestArtifactKind<I>,
|
||||||
init: HandlersStepBuilder<I>.() -> Unit
|
init: HandlersStepBuilder<I>.() -> Unit
|
||||||
) {
|
) {
|
||||||
val step = namedSteps[name] ?: error { "Step \"$name\" not found" }
|
val step = namedStepOfType<I>(name) ?: error { "Step \"$name\" not found" }
|
||||||
require(step is HandlersStepBuilder<*>) { "Step '$name' is not a handlers step" }
|
|
||||||
require(step.artifactKind == artifactKind) { "Step kind: ${step.artifactKind}, passed kind is $artifactKind" }
|
require(step.artifactKind == artifactKind) { "Step kind: ${step.artifactKind}, passed kind is $artifactKind" }
|
||||||
|
step.apply(init)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <I : ResultingArtifact<I>> namedStepOfType(name: String): HandlersStepBuilder<I>? {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
(step as HandlersStepBuilder<I>).apply(init)
|
return namedSteps[name] as HandlersStepBuilder<I>?
|
||||||
}
|
}
|
||||||
|
|
||||||
fun useSourcePreprocessor(vararg preprocessors: Constructor<SourceFilePreprocessor>, needToPrepend: Boolean = false) {
|
fun useSourcePreprocessor(vararg preprocessors: Constructor<SourceFilePreprocessor>, needToPrepend: Boolean = false) {
|
||||||
|
|||||||
Reference in New Issue
Block a user