Skip to content

Commit

Permalink
Merge pull request quarkusio#37063 from zakkak/2023-11-14-fix-main-it
Browse files Browse the repository at this point in the history
Make testLambdaCapturing test conditional on GraalVM version
  • Loading branch information
zakkak authored Nov 14, 2023
2 parents bb0352b + 4f6c97e commit c1af049
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public final class ArtifactResultBuildItem extends MultiBuildItem {

private final Path path;
private final String type;
private final Map<String, Object> metadata;
private final Map<String, String> metadata;

public ArtifactResultBuildItem(Path path, String type, Map<String, Object> metadata) {
public ArtifactResultBuildItem(Path path, String type, Map<String, String> metadata) {
this.path = path;
this.type = type;
this.metadata = metadata;
Expand All @@ -32,7 +32,7 @@ public String getType() {
return type;
}

public Map<String, Object> getMetadata() {
public Map<String, String> getMetadata() {
return metadata;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ OutputTargetBuildItem outputTarget(BuildSystemTargetBuildItem bst, PackageConfig
ArtifactResultBuildItem jarOutput(JarBuildItem jarBuildItem) {
if (jarBuildItem.getLibraryDir() != null) {
return new ArtifactResultBuildItem(jarBuildItem.getPath(), PackageConfig.JAR,
Collections.singletonMap("library-dir", jarBuildItem.getLibraryDir()));
Collections.singletonMap("library-dir", jarBuildItem.getLibraryDir().toString()));
} else {
return new ArtifactResultBuildItem(jarBuildItem.getPath(), PackageConfig.JAR, Collections.emptyMap());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -89,12 +87,8 @@ void nativeImageFeatures(BuildProducer<NativeImageFeatureBuildItem> features) {
@BuildStep(onlyIf = NativeBuild.class)
ArtifactResultBuildItem result(NativeImageBuildItem image) {
NativeImageBuildItem.GraalVMVersion graalVMVersion = image.getGraalVMInfo();
Map<String, Object> graalVMInfoProps = new HashMap<>();
graalVMInfoProps.put("graalvm.version.full", graalVMVersion.getFullVersion());
graalVMInfoProps.put("graalvm.version.version", graalVMVersion.getVersion());
graalVMInfoProps.put("graalvm.version.javaVersion", "" + graalVMVersion.getJavaVersion());
graalVMInfoProps.put("graalvm.version.distribution", graalVMVersion.getDistribution());
return new ArtifactResultBuildItem(image.getPath(), PackageConfig.NATIVE, graalVMInfoProps);
return new ArtifactResultBuildItem(image.getPath(), PackageConfig.BuiltInType.NATIVE.getValue(),
graalVMVersion.toMap());
}

@BuildStep(onlyIf = NativeSourcesBuild.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,10 @@ private void writeArtifactResultMetadataFile(BuildSystemTargetBuildItem outputTa
if (lastResult.getPath() != null) {
properties.put("path", outputTargetBuildItem.getOutputDirectory().relativize(lastResult.getPath()).toString());
}
Map<String, Object> metadata = lastResult.getMetadata();
Map<String, String> metadata = lastResult.getMetadata();
if (metadata != null) {
for (Map.Entry<String, Object> entry : metadata.entrySet()) {
if (entry.getValue() instanceof String) {
properties.put("metadata." + entry.getKey(), entry.getValue());
}
for (Map.Entry<String, String> entry : metadata.entrySet()) {
properties.put("metadata." + entry.getKey(), entry.getValue());
}
}
try (FileOutputStream fos = new FileOutputStream(quarkusArtifactMetadataPath.toFile())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public class ArtifactResult {

private final Path path;
private final String type;
private final Map<String, Object> metadata;
private final Map<String, String> metadata;

public ArtifactResult(Path path, String type, Map<String, Object> metadata) {
public ArtifactResult(Path path, String type, Map<String, String> metadata) {
this.path = path;
this.type = type;
this.metadata = metadata;
Expand All @@ -23,7 +23,7 @@ public String getType() {
return type;
}

public Map<String, Object> getMetadata() {
public Map<String, String> getMetadata() {
return metadata;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.DisableIfBuiltWithGraalVMNewerThan;
import io.quarkus.test.junit.DisableIfBuiltWithGraalVMOlderThan;
import io.quarkus.test.junit.GraalVMVersion;
import io.quarkus.test.junit.QuarkusIntegrationTest;
import io.restassured.RestAssured;

Expand Down Expand Up @@ -56,14 +59,21 @@ public void testTargetWithoutNested() {
}

@Test
public void testLambdaCapturing() {
final String resourceLambda = BASE_PKG + ".ResourceLambda";

@DisableIfBuiltWithGraalVMNewerThan(GraalVMVersion.GRAALVM_23_1_0)
public void testLambdaCapturingPre24_0() {
// Starting with GraalVM 22.1 support Lambda functions serialization
// (see https://github.com/oracle/graal/issues/3756)
RestAssured.given().when().get("/reflection/lambda").then().body(startsWith("Comparator$$Lambda$"));
}

@Test
@DisableIfBuiltWithGraalVMOlderThan(GraalVMVersion.GRAALVM_24_0_0)
public void testLambdaCapturingPost23_1() {
// Starting with GraalVM 24.0 lambda class names match the ones from HotSpot
// (see https://github.com/oracle/graal/pull/7775)
RestAssured.given().when().get("/reflection/lambda").then().body(startsWith("Comparator$$Lambda/"));
}

private void assertRegistration(String expected, String queryParam) {
RestAssured.given().queryParam("className", queryParam).when().get(ENDPOINT).then().body(is(expected));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
Properties quarkusArtifactProperties = readQuarkusArtifactProperties(context);
try {
GraalVM.Version version = GraalVM.Version
.of(quarkusArtifactProperties.getProperty("metadata.graalvm.version.version").lines());
.of(quarkusArtifactProperties.getProperty("metadata.graalvm.version.full").lines());
int comparison = annotationValue.getVersion().compareTo(version);
if (comparison < 0) {
return ConditionEvaluationResult.disabled("Native binary was built with GraalVM{version=" + version.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
Properties quarkusArtifactProperties = readQuarkusArtifactProperties(context);
try {
GraalVM.Version version = GraalVM.Version
.of(quarkusArtifactProperties.getProperty("metadata.graalvm.version.version").lines());
.of(quarkusArtifactProperties.getProperty("metadata.graalvm.version.full").lines());
int comparison = annotationValue.getVersion().compareTo(version);
if (comparison > 0) {
return ConditionEvaluationResult.disabled("Native binary was built with GraalVM{version=" + version.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import io.quarkus.deployment.pkg.steps.GraalVM;

public enum GraalVMVersion {
GRAALVM_23_1_0(GraalVM.Version.VERSION_23_1_0);
GRAALVM_23_1_0(GraalVM.Version.VERSION_23_1_0),
GRAALVM_24_0_0(GraalVM.Version.VERSION_24_0_0);

private final GraalVM.Version version;

Expand Down

0 comments on commit c1af049

Please sign in to comment.