Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent builds from failing if no test list is present #239

Merged
merged 1 commit into from May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -410,7 +410,7 @@ private void configureNativeConfigurationRepo(ExtensionAware graalvmNative) {
configurationRepository.getEnabled().convention(false);
configurationRepository.getUri().convention(configurationRepository.getVersion().map(v -> {
try {
return new URI("https://github.com/graalvm/jvm-reachability-metadata/releases/download/" + v + "/jvm-reachability-metadata-" + v + ".zip");
return new URI("https://github.com/graalvm/graalvm-reachability-metadata/releases/download/" + v + "/graalvm-reachability-metadata-" + v + ".zip");
} catch (URISyntaxException e) {
return null;
}
Expand Down Expand Up @@ -471,7 +471,7 @@ public void registerTestBinary(Project project,
injectTestPluginDependencies(project, graalExtension.getTestSupport());

TaskProvider<BuildNativeImageTask> testImageBuilder = tasks.named(deriveTaskName(name, "native", "Compile"), BuildNativeImageTask.class, task -> {
task.setOnlyIf(t -> graalExtension.getTestSupport().get());
task.setOnlyIf(t -> graalExtension.getTestSupport().get() && testListDirectory.getAsFile().get().exists());
task.getTestListDirectory().set(testListDirectory);
testTask.get();
ConfigurableFileCollection testList = project.getObjects().fileCollection();
Expand All @@ -488,7 +488,7 @@ public void registerTestBinary(Project project,

tasks.named(isPrimaryTest ? NATIVE_TEST_TASK_NAME : "native" + capitalize(name), NativeRunTask.class, task -> {
task.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
task.setOnlyIf(t -> graalExtension.getTestSupport().get());
task.setOnlyIf(t -> graalExtension.getTestSupport().get() && testListDirectory.getAsFile().get().exists());
});
}

Expand Down
Expand Up @@ -60,7 +60,6 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URISyntaxException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -109,6 +108,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
configureEnvironment();
if (!hasTests()) {
logger.info("Skipped native-image tests since there are no test classes.");
return;
}

Expand Down Expand Up @@ -169,8 +169,8 @@ private void configureEnvironment() {
private boolean hasTests() {
Path testOutputPath = Paths.get(project.getBuild().getTestOutputDirectory());
if (Files.exists(testOutputPath) && Files.isDirectory(testOutputPath)) {
try (DirectoryStream<Path> directory = Files.newDirectoryStream(testOutputPath)) {
return directory.iterator().hasNext();
try (Stream<Path> testClasses = Files.walk(testOutputPath)) {
return testClasses.anyMatch(p -> p.getFileName().toString().endsWith(".class"));
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
Expand Down