Break dependency between TestCompiler and AOT
This commit improves `TestCompiler` with a `with` function that allows to customize a test compiler instance. Rather than `TestCompiler` knowing about `TestGenerationContext`, the latter implements the function so that it can be passed as is. See gh-29175
This commit is contained in:
@@ -176,7 +176,7 @@ class AutowiredAnnotationBeanRegistrationAotContributionTests {
|
||||
|
||||
});
|
||||
this.generationContext.writeGeneratedContent();
|
||||
TestCompiler.forSystem().withFiles(this.generationContext.getGeneratedFiles()).compile(compiled ->
|
||||
TestCompiler.forSystem().with(this.generationContext).compile(compiled ->
|
||||
result.accept(compiled.getInstance(BiFunction.class), compiled));
|
||||
}
|
||||
|
||||
|
||||
@@ -425,7 +425,7 @@ class BeanDefinitionMethodGeneratorTests {
|
||||
.addCode("return $L;", methodInvocation).build());
|
||||
});
|
||||
this.generationContext.writeGeneratedContent();
|
||||
TestCompiler.forSystem().withFiles(this.generationContext.getGeneratedFiles()).compile(compiled ->
|
||||
TestCompiler.forSystem().with(this.generationContext).compile(compiled ->
|
||||
result.accept((RootBeanDefinition) compiled.getInstance(Supplier.class).get(), compiled));
|
||||
}
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
||||
.addStatement("return beanDefinition").build());
|
||||
});
|
||||
this.generationContext.writeGeneratedContent();
|
||||
TestCompiler.forSystem().withFiles(this.generationContext.getGeneratedFiles()).compile(compiled -> {
|
||||
TestCompiler.forSystem().with(this.generationContext).compile(compiled -> {
|
||||
RootBeanDefinition suppliedBeanDefinition = (RootBeanDefinition) compiled
|
||||
.getInstance(Supplier.class).get();
|
||||
result.accept(suppliedBeanDefinition, compiled);
|
||||
|
||||
@@ -76,7 +76,7 @@ class BeanDefinitionPropertyValueCodeGeneratorTests {
|
||||
.returns(Object.class).addStatement("return $L", generatedCode).build());
|
||||
});
|
||||
generationContext.writeGeneratedContent();
|
||||
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile(compiled ->
|
||||
TestCompiler.forSystem().with(generationContext).compile(compiled ->
|
||||
result.accept(compiled.getInstance(Supplier.class).get(), compiled));
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ class BeanRegistrationsAotContributionTests {
|
||||
.build());
|
||||
});
|
||||
this.generationContext.writeGeneratedContent();
|
||||
TestCompiler.forSystem().withFiles(this.generationContext.getGeneratedFiles()).compile(compiled ->
|
||||
TestCompiler.forSystem().with(this.generationContext).compile(compiled ->
|
||||
result.accept(compiled.getInstance(Consumer.class), compiled));
|
||||
}
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ class InstanceSupplierCodeGeneratorTests {
|
||||
.addStatement("return $L", generatedCode).build());
|
||||
});
|
||||
this.generationContext.writeGeneratedContent();
|
||||
TestCompiler.forSystem().withFiles(this.generationContext.getGeneratedFiles()).compile(compiled ->
|
||||
TestCompiler.forSystem().with(this.generationContext).compile(compiled ->
|
||||
result.accept((InstanceSupplier<?>) compiled.getInstance(Supplier.class).get(), compiled));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user