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

@@ -165,7 +165,7 @@ class ConfigurationClassPostProcessorAotContributionTests {
.build());
});
generationContext.writeGeneratedContent();
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile(compiled ->
TestCompiler.forSystem().with(generationContext).compile(compiled ->
result.accept(compiled.getInstance(Consumer.class), compiled));
}
@@ -297,7 +297,7 @@ class ConfigurationClassPostProcessorAotContributionTests {
.build());
});
generationContext.writeGeneratedContent();
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile(compiled ->
TestCompiler.forSystem().with(generationContext).compile(compiled ->
result.accept(compiled.getInstance(Consumer.class), compiled));
}

View File

@@ -315,7 +315,7 @@ class ApplicationContextAotGeneratorTests {
@SuppressWarnings({ "rawtypes", "unchecked" })
private void testCompiledResult(TestGenerationContext generationContext,
BiConsumer<ApplicationContextInitializer<GenericApplicationContext>, Compiled> result) {
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile(compiled ->
TestCompiler.forSystem().with(generationContext).compile(compiled ->
result.accept(compiled.getInstance(ApplicationContextInitializer.class), compiled));
}

View File

@@ -86,7 +86,7 @@ class ApplicationContextAotGeneratorRuntimeHintsTests {
TestGenerationContext generationContext = new TestGenerationContext();
generator.processAheadOfTime(applicationContext, generationContext);
generationContext.writeGeneratedContent();
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile(compiled -> {
TestCompiler.forSystem().with(generationContext).compile(compiled -> {
ApplicationContextInitializer instance = compiled.getInstance(ApplicationContextInitializer.class);
GenericApplicationContext freshContext = new GenericApplicationContext();
RuntimeHintsInvocations recordedInvocations = RuntimeHintsRecorder.record(() -> {