This is an automated email from the ASF dual-hosted git repository. av pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push: new 4455b54eabf IGNITE-19236 orphaned_tests.txt location calculation simplification (#10625) 4455b54eabf is described below commit 4455b54eabfc6c6e7253a7e43414c70b154859c0 Author: Anton Vinogradov <a...@apache.org> AuthorDate: Thu Apr 6 12:46:05 2023 +0300 IGNITE-19236 orphaned_tests.txt location calculation simplification (#10625) --- .../testsuites/OrphanedTestCollection.java | 34 +++++----------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/modules/tools/src/main/java/org/apache/ignite/tools/surefire/testsuites/OrphanedTestCollection.java b/modules/tools/src/main/java/org/apache/ignite/tools/surefire/testsuites/OrphanedTestCollection.java index cefee5b82b7..b87d828f878 100644 --- a/modules/tools/src/main/java/org/apache/ignite/tools/surefire/testsuites/OrphanedTestCollection.java +++ b/modules/tools/src/main/java/org/apache/ignite/tools/surefire/testsuites/OrphanedTestCollection.java @@ -21,7 +21,6 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; -import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -40,7 +39,7 @@ public class OrphanedTestCollection { private static final String FINAL_MARK = "---"; /** File to persist orphaned tests. */ - private final Path path = initPath(); + private final Path path = orphanedTestsFilePath(); /** @return {@link Set} of orphaned test names. */ public Set<String> getOrphanedTests() throws Exception { @@ -93,31 +92,12 @@ public class OrphanedTestCollection { } /** - * Structure of Ignite modules is flat but there are some exceptions. Unfortunately it's impossible to - * get access to root directory of repository so use this hack to find it. + * Path to the common orphaned_tests.txt file. */ - private static Path initPath() { - Path curPath = Paths.get("").toAbsolutePath(); - - while (!curPath.equals(curPath.getRoot())) { - if (curPath.resolve("modules").toFile().exists()) { - Path targetPath = curPath.resolve("target"); - - if (!targetPath.toFile().exists()) { - try { - Files.createDirectory(targetPath); - } - catch (IOException e) { - throw new RuntimeException("Failed to create target directory.", e); - } - } - - return curPath.resolve("target").resolve("orphaned_tests.txt"); - } - - curPath = curPath.getParent(); - } - - throw new IllegalStateException("Can't find repository root directory."); + private static Path orphanedTestsFilePath() { + return Paths + .get(OrphanedTestCollection.class.getProtectionDomain().getCodeSource().getLocation().getPath()) + .getParent() + .resolve("orphaned_tests.txt"); } }