Skip to content

Commit

Permalink
Fix gradle integration test to work with GraalVM >= 22.0
Browse files Browse the repository at this point in the history
Starting with GraalVM 22.0 `native-image` will produce different
output (see oracle/graal#3955)

This patch makes the gradle integration test whether the GraalVM being
used is < 22.0 and perform the corresponding assertions.
  • Loading branch information
zakkak committed Nov 29, 2021
1 parent ebd6d37 commit dd61064
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

public class BasicJavaNativeBuildIT extends QuarkusNativeGradleITBase {

public static final String NATIVE_IMAGE_NAME = "foo-1.0.0-SNAPSHOT-runner";

@Test
public void shouldBuildNativeImage() throws Exception {
final File projectDir = getProjectDir("basic-java-native-module");
Expand All @@ -22,10 +24,17 @@ public void shouldBuildNativeImage() throws Exception {
assertThat(build.getTasks().get(":quarkusBuild")).isEqualTo(BuildResult.SUCCESS_OUTCOME);
final String buildOutput = build.getOutput();
// make sure the output log during the build contains some expected logs from the native-image process
CharSequence[] expectedOutput;
if (buildOutput.contains("Version info:")) { // Starting with 22.0 the native-image output changed
expectedOutput = new CharSequence[] { "Initializing...", "Performing analysis...",
"Finished generating '" + NATIVE_IMAGE_NAME + "' in" };
} else {
expectedOutput = new CharSequence[] { "(clinit):", "(typeflow):", "[total]:" };
}
assertThat(buildOutput)
.withFailMessage("native-image build log is missing certain expected log messages: \n\n %s", buildOutput)
.contains("(clinit):", "(typeflow):", "[total]:");
Path nativeImagePath = projectDir.toPath().resolve("build").resolve("foo-1.0.0-SNAPSHOT-runner");
.contains(expectedOutput);
Path nativeImagePath = projectDir.toPath().resolve("build").resolve(NATIVE_IMAGE_NAME);
assertThat(nativeImagePath).exists();
Process nativeImageProcess = runNativeImage(nativeImagePath.toAbsolutePath().toString());
try {
Expand Down

0 comments on commit dd61064

Please sign in to comment.