Skip to content

Commit 390d8aa

Browse files
committed
Cleanup externally set directories in session tests #903
The customizations for session tests to define custom workspaces and configurations currently only cleanup the contents of the used test directories if they are created by the customization implementation on their own. When a path is passed from outside, e.g., injected via a JUnit TempDir annotation, the folder is not cleaned up, but usually the provider will not do that on its own. In particular, JUnit only removes an injected temporary directory but not its contents. With this change, the data created by session tests in custom workspace or configuration folders is always cleaned up after the test, no matter who created the temporary directory. Contributes to #903
1 parent 0f64336 commit 390d8aa

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/session/customization/CustomSessionConfigurationImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ public CustomSessionConfiguration setReadOnly() {
138138
public CustomSessionConfiguration setConfigurationDirectory(Path configurationDirectory) {
139139
Objects.requireNonNull(configurationDirectory);
140140
this.configurationDirectory = configurationDirectory;
141+
deleteOnShutdownRecursively(configurationDirectory);
141142
return this;
142143
}
143144

144145
private Path getConfigurationDirectory() throws IOException {
145146
if (configurationDirectory == null) {
146-
this.configurationDirectory = Files.createTempDirectory(TEMP_DIR_PREFIX);
147-
deleteOnShutdownRecursively(configurationDirectory);
147+
setConfigurationDirectory(Files.createTempDirectory(TEMP_DIR_PREFIX));
148148
}
149149
return configurationDirectory;
150150
}

runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/session/customization/CustomSessionWorkspaceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ public CustomSessionWorkspaceImpl() {
3434
public CustomSessionWorkspace setWorkspaceDirectory(Path workspaceDirectory) {
3535
Objects.requireNonNull(workspaceDirectory);
3636
this.workspaceDirectory = workspaceDirectory;
37+
deleteOnShutdownRecursively(workspaceDirectory);
3738
return this;
3839
}
3940

4041
@Override
4142
public Path getWorkspaceDirectory() throws IOException {
4243
if (workspaceDirectory == null) {
43-
this.workspaceDirectory = Files.createTempDirectory(TEMP_DIR_PREFIX);
44-
deleteOnShutdownRecursively(workspaceDirectory);
44+
setWorkspaceDirectory(Files.createTempDirectory(TEMP_DIR_PREFIX));
4545
}
4646
return workspaceDirectory;
4747
}

0 commit comments

Comments
 (0)