Skip to content

Commit

Permalink
Fix @arg file not being used for tests in Maven
Browse files Browse the repository at this point in the history
  • Loading branch information
melix committed Feb 22, 2022
1 parent 61499e8 commit 1f931e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.graalvm.buildtools.Utils;
import org.graalvm.buildtools.utils.NativeImageUtils;
import org.graalvm.junit.platform.JUnitPlatformFeature;

import java.io.File;
Expand Down Expand Up @@ -139,7 +140,6 @@ private void buildImage(String classpath, Path targetFolder) throws MojoExecutio
Path nativeImageExecutable = Utils.getNativeImage();

List<String> command = new ArrayList<>(Arrays.asList(
nativeImageExecutable.toString(),
"-cp", classpath,
"--features=org.graalvm.junit.platform.JUnitPlatformFeature",
"-Djunit.platform.listeners.uid.tracking.output.dir=" + NativeExtension.testIdsDirectory(buildDirectory.getAbsolutePath()),
Expand All @@ -151,10 +151,11 @@ private void buildImage(String classpath, Path targetFolder) throws MojoExecutio
command.addAll(buildArgs);
}

command.add("org.graalvm.junit.platform.NativeImageJUnitLauncher");

try {
ProcessBuilder processBuilder = new ProcessBuilder(command);
command = NativeImageUtils.convertToArgsFile(command);
ProcessBuilder processBuilder = new ProcessBuilder(nativeImageExecutable.toString());
processBuilder.command().addAll(command);
processBuilder.command().add("org.graalvm.junit.platform.NativeImageJUnitLauncher");
processBuilder.directory(new File(project.getBuild().getDirectory()));
processBuilder.inheritIO();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,14 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
private static String normalizeString(String input) {
input.replace("\r\n", "\n")
}

String getArgFileContents() {
result.stdOut.lines().filter {
it.contains('Executing:') && it.contains('bin/native-image')
}.map {
new File(it.substring(it.lastIndexOf('@') + 1))
}.findFirst()
.map { it.text }
.orElse("")
}
}

0 comments on commit 1f931e8

Please sign in to comment.