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

Support platform IT tests in IntegrationTestUtil.determineBuildOutputDirectory(url) #23081

Merged
merged 1 commit into from
Jan 24, 2022
Merged
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 @@ -4,7 +4,6 @@
import static io.quarkus.test.common.PathTestHelper.getTestClassesLocation;
import static java.lang.ProcessBuilder.Redirect.DISCARD;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
Expand Down Expand Up @@ -468,12 +467,12 @@ static Path determineBuildOutputDirectory(ExtensionContext context) {
final CodeSource codeSource = testClass.getProtectionDomain().getCodeSource();
if (codeSource != null) {
URL codeSourceLocation = codeSource.getLocation();
File artifactPropertiesDirectory = determineBuildOutputDirectory(codeSourceLocation);
Path artifactPropertiesDirectory = determineBuildOutputDirectory(codeSourceLocation);
if (artifactPropertiesDirectory == null) {
throw new IllegalStateException(
"Unable to determine the output of the Quarkus build. Consider setting the 'build.output.directory' system property.");
}
result = artifactPropertiesDirectory.toPath();
result = artifactPropertiesDirectory;
}
}
if (result == null) {
Expand All @@ -487,24 +486,37 @@ static Path determineBuildOutputDirectory(ExtensionContext context) {
return result;
}

private static File determineBuildOutputDirectory(final URL url) {
private static Path determineBuildOutputDirectory(final URL url) {
if (url == null) {
return null;
}
if (url.getProtocol().equals("file") && url.getPath().endsWith("test-classes/")) {
//we have the maven test classes dir
return toPath(url).getParent().toFile();
} else if (url.getProtocol().equals("file") && url.getPath().endsWith("test/")) {
//we have the gradle test classes dir, build/classes/java/test
return toPath(url).getParent().getParent().getParent().toFile();
} else if (url.getProtocol().equals("file") && url.getPath().contains("/target/surefire/")) {
//this will make mvn failsafe:integration-test work
String path = url.getPath();
int index = path.lastIndexOf("/target/");
try {
return Paths.get(new URI("file:" + (path.substring(0, index) + "/target/"))).toFile();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
if (url.getProtocol().equals("file")) {
if (url.getPath().endsWith("test-classes/")) {
// we have the maven test classes dir
return toPath(url).getParent();
} else if (url.getPath().endsWith("test/")) {
// we have the gradle test classes dir, build/classes/java/test
return toPath(url).getParent().getParent().getParent();
} else if (url.getPath().contains("/target/surefire/")) {
// this will make mvn failsafe:integration-test work
String path = url.getPath();
int index = path.lastIndexOf("/target/");
try {
return Paths.get(new URI("file:" + (path.substring(0, index) + "/target/")));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
} else if (url.getPath().endsWith("-tests.jar")) {
// integration platform test
final Path baseDir = Path.of("").normalize().toAbsolutePath();
Path outputDir = baseDir.resolve("target");
if (Files.exists(outputDir)) {
return outputDir;
}
outputDir = baseDir.resolve("build");
if (Files.exists(outputDir)) {
return outputDir;
}
}
}
return null;
Expand Down