Updated test db cache dir to cleanup once per test file when not in

batch mode
This commit is contained in:
dragonmacher
2022-04-19 18:07:18 -04:00
parent d7f9cdfe5c
commit 9e9e64dc4c
2 changed files with 17 additions and 0 deletions

View File

@@ -21,6 +21,8 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
import org.junit.BeforeClass;
import docking.test.AbstractDockingTest;
import ghidra.GhidraTestApplicationLayout;
import ghidra.app.events.ProgramLocationPluginEvent;
@@ -96,6 +98,15 @@ public abstract class AbstractGhidraHeadlessIntegrationTest extends AbstractDock
System.setProperty(GhidraScriptConstants.USER_SCRIPTS_DIR_PROPERTY, getTestDirectoryPath());
}
@BeforeClass
public static void cleanDbTestDir() {
// keep files around in batch mode to allow tests to run faster; assume batch mode performs
// its own cleanup; only run once per class to allow subsequent tests to be faster
if (!BATCH_MODE) {
TestProgramManager.cleanDbTestDir();
}
}
public static boolean deleteProject(String directory, String name) {
return ProjectTestUtils.deleteProject(directory, name);
}

View File

@@ -431,6 +431,12 @@ public class TestProgramManager {
return dbTestDir;
}
public static void cleanDbTestDir() {
File dir = getDbTestDir();
Msg.debug(TestProgramManager.class, "Deleting test db cache dir: " + dir);
FileUtilities.deleteDir(dir);
}
private static File getTestDBDirectory() {
String testDirPath = AbstractGTest.getTestDirectoryPath();
File dir = new File(testDirPath, DB_DIR_NAME);