Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -318,21 +317,19 @@ public void execute() throws MojoExecutionException, MojoFailureException {
return;
}

Set<String> artifactIds = new HashSet<>();
Map<Integer, Map<String, String>> variations = filterVariations();
for (Map.Entry<Integer, Map<String, String>> entry : variations.entrySet()) {
index = entry.getKey();
Map<String, String> variation = entry.getValue();
String artifactId = variation.getOrDefault("artifactId", "myproject");
if (!artifactIds.add(artifactId)) {
if (index > 1) {
variation.put("artifactId", artifactId + "-" + index);
}
processIntegrationTest(testName, variation, archetypeFile);
}
} else {
processIntegrationTest(testName, externalValues, archetypeFile);
}

} catch (IOException e) {
Log.error(e, "Integration test failed with error(s)");
throw new MojoExecutionException("Integration test failed with error(s)");
Expand Down Expand Up @@ -509,7 +506,8 @@ private void logVariations(String testName) {
private void logTestDescription(String testName, Map<String, String> externalValues) {
String description = Bold.apply("Test: ") + BoldBlue.apply(testName);
if (variations != null && index > 0) {
description += BoldBlue.apply(String.format(", progress: %s/%s", index, variations.size()));
int total = endIndex == -1 ? variations.size() : endIndex;
description += BoldBlue.apply(String.format(", progress: %s/%s", index, total));
}
Log.info("");
Log.info("-------------------------------------");
Expand Down Expand Up @@ -693,7 +691,7 @@ private FileLogger setupBuildLogger(Path basedir) throws IOException {
return logger;
}

private static final class FileLogger implements InvocationOutputHandler, Closeable {
private final class FileLogger implements InvocationOutputHandler, Closeable {

private final PrintStream printer;
private final boolean streamLogs;
Expand All @@ -709,7 +707,7 @@ public void consumeLine(String line) {
printer.println(line);
printer.flush();
if (streamLogs) {
Log.info(line);
getLog().info(line);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

import io.helidon.build.common.test.utils.BuildLog;
Expand All @@ -29,10 +30,12 @@
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import org.junit.jupiter.params.ParameterizedTest;

import static io.helidon.build.common.FileUtils.fileName;
import static io.helidon.build.common.test.utils.BuildLog.assertDiffs;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;

/**
* Integration test that verifies the projects under {@code src/it/projects}.
Expand Down Expand Up @@ -135,31 +138,44 @@ private static Path projectsDir(String baseDir, String prefix) {
return projectsDir;
}

private static void assertProjectCount(Path projectsDir, int expectedCount) throws IOException {
int projectCount = 0;
private static List<Path> testProjects(Path projectsDir) throws IOException {
List<Path> projects = new ArrayList<>();
try (DirectoryStream<Path> paths = Files.newDirectoryStream(projectsDir)) {
for (Path path : paths) {
if (path.getFileName().toString().endsWith("-project")) {
assertThat(Files.isDirectory(path), is(true));
projectCount++;
if (fileName(path).matches(".*-project(-[0-9]+)?$")) {
projects.add(path);
}
}
assertThat(projectCount, is(expectedCount));
}
return projects;
}

private static void assertProjectCount(Path projectsDir, int expectedCount) throws IOException {
int projectCount = 0;
for (Path path : testProjects(projectsDir)) {
assertThat(Files.isDirectory(path), is(true));
projectCount++;
}
assertThat(projectCount, is(expectedCount));
}

private static void assertProjectShape(Path projectsDir, String shape) throws IOException {
// Check project directory
Path outputDir = projectsDir.resolve(shape + "-project");
Path outputDir = testProjects(projectsDir).stream()
.filter(p -> fileName(p).contains(shape + "-project"))
.findFirst()
.orElse(null);
assertThat(outputDir, is(not(nullValue())));
assertThat(Files.exists(outputDir), is(true));

// Check pom file
Path pomFile = outputDir.resolve("pom.xml");
String fileName = fileName(outputDir);
assertContains(pomFile, List.of(
"<groupId>io.helidon.build.maven.archetype.tests</groupId>",
"<artifactId>" + shape + "-project</artifactId>",
"<artifactId>" + fileName + "</artifactId>",
"<version>0.1-SNAPSHOT</version>",
"<name>" + shape + "-project</name>"
"<name>" + fileName + "</name>"
));

// Check source file
Expand Down