mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-01-30 12:51:17 +08:00
Nest snapshot test dbs in a root temp folder
Allows us to clean it all up easily. Closes #558.
This commit is contained in:
parent
b4d2db3dee
commit
e6d5950b59
@ -31,6 +31,7 @@
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStoreHelper;
|
||||
import com.sk89q.worldedit.world.storage.McRegionReader;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.DynamicNode;
|
||||
@ -76,6 +77,8 @@ class FileSystemSnapshotDatabaseTest {
|
||||
.atZone(ZoneId.systemDefault());
|
||||
static final ZonedDateTime TIME_TWO = TIME_ONE.minusDays(1);
|
||||
|
||||
private static Path TEMP_DIR;
|
||||
|
||||
@BeforeAll
|
||||
static void setUpStatic() throws IOException, DataException {
|
||||
try (InputStream in = Resources.getResource("world_region.mca.gzip").openStream();
|
||||
@ -104,10 +107,17 @@ static void setUpStatic() throws IOException, DataException {
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
|
||||
TEMP_DIR = Files.createTempDirectory("worldedit-fs-snap-dbs");
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void afterAll() throws IOException {
|
||||
deleteTree(TEMP_DIR);
|
||||
}
|
||||
|
||||
private static Path newTempDb() throws IOException {
|
||||
return Files.createTempDirectory("worldedit-fs-snap-db");
|
||||
return Files.createTempDirectory(TEMP_DIR, "db");
|
||||
}
|
||||
|
||||
private static void deleteTree(Path root) throws IOException {
|
||||
@ -175,7 +185,6 @@ private static Stream<? extends DynamicNode> getTests(ArchiveNioSupport nioSuppo
|
||||
try {
|
||||
Path dbRoot = root.resolve("snapshots");
|
||||
Files.createDirectories(dbRoot);
|
||||
// we leak `root` here, but I can't see a good way to clean it up.
|
||||
return type.getNamedTests(new FSSDContext(nioSupport, dbRoot));
|
||||
} catch (Throwable t) {
|
||||
deleteTree(root);
|
||||
|
Loading…
Reference in New Issue
Block a user