Skip to content

Commit

Permalink
Silence noisy tests
Browse files Browse the repository at this point in the history
Signed-off-by: Lazar Mitrović <lazar.mitrovic@oracle.com>
  • Loading branch information
lazar-mitrovic committed Aug 3, 2022
1 parent 805e218 commit c6b6b52
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
when:
// Run Maven in debug mode (-X) in order to capture the command line arguments
// used to launch Surefire with the agent.
mvn '-X', '-Pnative', 'test', '-DskipNativeTests'
mvnDebug '-Pnative', 'test', '-DskipNativeTests'

then:
// Agent is used with Surefire
Expand Down Expand Up @@ -85,7 +85,7 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
when:
// Run Maven in debug mode (-X) in order to capture the command line arguments
// used to launch Surefire with the agent.
mvn '-X', '-Pnative', 'test'
mvnDebug '-Pnative', 'test'

then:
outputContains """
Expand Down Expand Up @@ -162,7 +162,7 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
when:
// Run Maven in debug mode (-X) in order to capture the command line arguments
// used to launch Surefire with the agent.
mvn '-X', '-Pnative', '-DagentOptions=periodic-config', 'test'
mvnDebug '-Pnative', '-DagentOptions=periodic-config', 'test'

then:
outputContains """
Expand Down Expand Up @@ -214,7 +214,7 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
withSample("java-application-with-reflection")

when:
mvn '-X', '-Pnative', '-DskipTests=true', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
mvnDebug '-Pnative', '-DskipTests=true', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'

then:
['jni', 'proxy', 'reflect', 'resource', 'serialization'].each { name ->
Expand Down Expand Up @@ -246,7 +246,7 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
withSample("java-application-with-reflection")

when:
mvn '-X', '-Pnative', '-Dagent=false', '-DskipTests=true', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
mvnDebug '-Pnative', '-Dagent=false', '-DskipTests=true', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'

then:
outputDoesNotContain '-agentlib:native-image-agent'
Expand All @@ -263,7 +263,7 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
withSample("java-application-with-reflection")

when:
mvn '-X', '-Pnative', '-DagentOptions=periodic-config', '-DskipTests=true', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
mvnDebug '-Pnative', '-DagentOptions=periodic-config', '-DskipTests=true', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'

then:
['jni', 'proxy', 'reflect', 'resource', 'serialization'].each { name ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class NativeExtension extends AbstractMavenLifecycleParticipant implement
private static final String JUNIT_PLATFORM_LISTENERS_UID_TRACKING_OUTPUT_DIR = "junit.platform.listeners.uid.tracking.output.dir";
private static final String NATIVEIMAGE_IMAGECODE = "org.graalvm.nativeimage.imagecode";

private Logger logger;
private static Logger logger;

@Override
public void enableLogging(Logger logger) {
Expand Down Expand Up @@ -318,6 +318,12 @@ private static void configureAgentForSurefire(Plugin surefirePlugin, String agen
Xpp3Dom argLine = new Xpp3Dom("argLine");
argLine.setValue(agentArgument);
configuration.addChild(argLine);
Xpp3Dom jvm = findOrAppend(configuration, "jvm");
try {
jvm.setValue(Utils.getNativeImage(logger).getParent().resolve("java").toString());
} catch (MojoExecutionException e) {
throw new RuntimeException(e);
}
});
}

Expand Down
6 changes: 6 additions & 0 deletions native-maven-plugin/src/seeding-build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.jupiter.version>5.8.1</junit.jupiter.version>
<graalvm.version>22.0.0</graalvm.version>
<mainClass>org.graalvm.demo.Application</mainClass>
</properties>

Expand All @@ -62,6 +63,11 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<version>${graalvm.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,61 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
}

void mvn(List<String> args) {
mvn(args as String[])
Map<String, String> systemProperties = [
"org.apache.http" : "off",
"org.apache.http.wire" : "off",
].collectEntries { key, value ->
["org.slf4j.simpleLogger.log.${key}".toString(), value]
}
mvn(args, systemProperties)
}

void mvn(String... args) {
System.out.println("Running copy of maven project `" + testOrigin + "` with `" + args + "`");
mvn(args.toList())
}

void mvn(List<String> args, Map<String, String> systemProperties) {
System.out.println("Running copy of maven project `" + testOrigin + "` with " + args);
var resultingSystemProperties = [
"common.repo.uri": System.getProperty("common.repo.uri"),
"seed.repo.uri": System.getProperty("seed.repo.uri"),
"maven.repo.local": testDirectory.resolve("local-repo").toFile().absolutePath
]
resultingSystemProperties.putAll(systemProperties)

result = executor.execute(
testDirectory.toFile(),
[
"org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener": "warn",
"common.repo.uri": System.getProperty("common.repo.uri"),
"seed.repo.uri": System.getProperty("seed.repo.uri"),
"maven.repo.local": testDirectory.resolve("local-repo").toFile().absolutePath
],
resultingSystemProperties,
[*injectedSystemProperties,
*args],
new File(System.getProperty("maven.settings"))
)
System.out.println("Exit code is ${result.exitCode}")

}

void mvnDebug(String... args) {
Map<String, String> systemProperties = [
"org.apache.http" : "off",
"org.apache.http.wire" : "off",
"org.apache.maven.cli.transfer.Slf4jMavenTransferListener" : "warn",
"org.eclipse.aether.internal.impl.DefaultTransporterProvider" : "error",
"org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider": "error",
"org.eclipse.aether.internal.impl.TrackingFileManager" : "error",
"org.eclipse.aether.internal.impl.DefaultArtifactResolver" : "error",
"org.codehaus.plexus.PlexusContainer" : "error",
"org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver" : "error",
"org.apache.maven.shared.filtering.DefaultMavenFileFilter" : "error",
"org.codehaus.mojo.exec.ExecMojo" : "debug",
// This is THE logger we need for checking java execution
"org.apache.maven.lifecycle.internal.LifecycleDebugLogger" : "error"
].collectEntries { key, value ->
["org.slf4j.simpleLogger.log.${key}".toString(), value]
}

ArrayList<String> resultingArgs = args.toList()
resultingArgs.add(0, "-X")
mvn(resultingArgs, systemProperties)
}

boolean isDidNotCrash() {
Expand Down
2 changes: 1 addition & 1 deletion samples/java-application-with-custom-packaging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<micronaut.version>3.3.4</micronaut.version>
<exec.mainClass>org.graalvm.demo.Application</exec.mainClass>
<micronaut.runtime>netty</micronaut.runtime>
<maven.native.plugin.version>0.9.13-SNAPSHOT</maven.native.plugin.version>
<maven.native.plugin.version>0.9.14-SNAPSHOT</maven.native.plugin.version>
</properties>

<repositories>
Expand Down

0 comments on commit c6b6b52

Please sign in to comment.