alamar commented on a change in pull request #8367:
URL: https://github.com/apache/ignite/pull/8367#discussion_r569524476



##########
File path: 
modules/tools/src/main/java/org/apache/ignite/tools/surefire/testsuites/OrphanedTestCollection.java
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.tools.surefire.testsuites;
+
+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;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Represents a persisted list of orphaned tests.
+ */
+public class OrphanedTestCollection {
+    /** File to persist orphaned tests. */
+    private final Path path = initPath();
+
+    /** */
+    public Set<String> getOrphanedTests() throws Exception {
+        if (Files.notExists(path))
+            return new HashSet<>();
+
+        try (
+            BufferedReader testReader = new BufferedReader(new 
FileReader(path.toFile()))
+        ) {
+            String testClsName = testReader.readLine();
+
+            Set<String> testClasses = new HashSet<>();
+
+            while (testClsName != null) {
+                testClasses.add(testClsName);
+
+                testClsName = testReader.readLine();
+            }
+
+            return testClasses;
+        }
+    }
+
+    /** */
+    public void persistOrphanedTests(Collection<String> testClasses) throws 
Exception {
+        try (
+            BufferedWriter testWriter = new BufferedWriter(new 
FileWriter(path.toFile()))
+        ) {
+            for (String cls: testClasses) {
+                testWriter.write(cls);
+                testWriter.newLine();
+            }
+        }
+    }
+
+    /** */
+    public Path getPath() {
+        return path;
+    }
+
+    /**
+     * 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.
+     */
+    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())

Review comment:
       Multiline if() requires squirly bracket body even if it contains single 
statement.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to