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:
Stephane Nicoll
2022-09-20 14:24:22 +02:00
parent 2f84096af1
commit 4625e92eb8
17 changed files with 108 additions and 37 deletions

View File

@@ -109,7 +109,7 @@ class PersistenceManagedTypesBeanRegistrationAotProcessorTests {
TestGenerationContext generationContext = new TestGenerationContext();
generator.processAheadOfTime(applicationContext, generationContext);
generationContext.writeGeneratedContent();
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile(compiled ->
TestCompiler.forSystem().with(generationContext).compile(compiled ->
result.accept(compiled.getInstance(ApplicationContextInitializer.class), compiled));
}

View File

@@ -175,7 +175,7 @@ class PersistenceAnnotationBeanPostProcessorAotContributionTests {
BeanRegistrationCode beanRegistrationCode = mock(BeanRegistrationCode.class);
contribution.applyTo(generationContext, beanRegistrationCode);
generationContext.writeGeneratedContent();
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles())
TestCompiler.forSystem().with(generationContext)
.compile(compiled -> result.accept(new Invoker(compiled), compiled));
}