kgusakov commented on a change in pull request #196:
URL: https://github.com/apache/ignite-3/pull/196#discussion_r664669438



##########
File path: 
modules/core/src/test/java/org/apache/ignite/internal/testframework/WorkDirectoryExtension.java
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.internal.testframework;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteSystemProperties;
+import org.jetbrains.annotations.Nullable;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+import org.junit.platform.commons.support.AnnotationSupport;
+import org.junit.platform.commons.support.HierarchyTraversalMode;
+
+/**
+ * JUnit extension for injecting temporary folders into test classes.
+ * <p>
+ * This extension supports both field and parameter injection of {@link Path} 
parameters annotated with the
+ * {@link WorkDirectory} annotation.
+ * <p>
+ * A new temporary folder is created for every test method and will be located 
relative to the module,
+ * where the tests are being run, by the following path: "work/{@literal 
<name-of-the-test-method>}". It is removed
+ * after a test has finished running, but this behaviour can be controlled by 
setting the
+ * {@link WorkDirectoryExtension#KEEP_WORK_DIR_PROPERTY} property to {@code 
true}, in which case the created folder can
+ * be kept intact for debugging purposes.
+ */
+public class WorkDirectoryExtension implements BeforeEachCallback, 
AfterEachCallback, ParameterResolver {
+    /**
+     * System property that, when set to {@code true}, will make the extension 
preserve the created directories.
+     * Default is {@code false}.
+     */
+    public static final String KEEP_WORK_DIR_PROPERTY = "KEEP_WORK_DIR";
+
+    /** Base path for all temporary folders in a module. */
+    private static final Path BASE_PATH = Paths.get("work");

Review comment:
       Could we use `target/work` directory of the module instead? It will give 
us free benefits like cleaning by `mvn clean`.




-- 
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.

To unsubscribe, e-mail: [email protected]

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


Reply via email to