sashapolo commented on a change in pull request #357:
URL: https://github.com/apache/ignite-3/pull/357#discussion_r718317601
##########
File path:
modules/core/src/test/java/org/apache/ignite/internal/testframework/WorkDirectoryExtension.java
##########
@@ -34,61 +39,112 @@
import org.junit.platform.commons.support.AnnotationSupport;
import org.junit.platform.commons.support.HierarchyTraversalMode;
+import static org.junit.jupiter.api.extension.ExtensionContext.Namespace;
+
/**
* 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:
- * "target/work/{@literal
<name-of-the-test-class>/<name-of-the-test-method>_<current_time_millis>}".
- * It is removed after a test has finished running, but this behaviour can be
controlled by setting the
+ * A new temporary folder can be created for every test method (when used as a
test parameter or as a member field)
+ * or a single time in a test class' lifetime (when used as a parameter in a
{@link BeforeAll} hook or as a static
+ * field). Temporary folders are located relative to the module, where the
tests are being run, and their paths depends
+ * on the lifecycle of the folder:
+ *
+ * <ol>
+ * <li>For test methods: "target/work/{@literal
<name-of-the-test-class>/<name-of-the-test-method>_<current_time_millis>}"</li>
+ * <li>For test classes: "target/work/{@literal
<name-of-the-test-class>/static_<current_time_millis>}"</li>
+ * </ol>
+ *
+ * Temporary folders are removed after tests have 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 {
+public class WorkDirectoryExtension
+ implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback,
AfterEachCallback, ParameterResolver {
+ /** JUnit namespace for the extension. */
+ private static final Namespace NAMESPACE =
Namespace.create(WorkDirectoryExtension.class);
+
/**
* 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";
+ private 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 = Path.of("target", "work");
+ /** Name of the work directory that will be injected into {@link
BeforeAll} methods or static members. */
+ private static final String STATIC_FOLDER_NAME = "static";
+
+ /**
+ * Flag that, when set to {@code true}, indicates that the extension
should remove the created directories.
+ */
+ private static final boolean SHOULD_REMOVE_DIR =
!IgniteSystemProperties.getBoolean(KEEP_WORK_DIR_PROPERTY);
Review comment:
I didn't know about this extension. This is an easy change, so let's do
it
--
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]