script tests should wipe the directory after each test

This commit is contained in:
Jason P. Leasure 2020-03-20 16:33:34 -04:00
parent 4c655c2e92
commit b569c79baf

View file

@ -20,6 +20,7 @@ import static org.junit.Assert.*;
import java.awt.Window;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -165,9 +166,21 @@ public abstract class AbstractGhidraScriptMgrPluginTest
testScriptFile.delete();
}
wipeUserScripts();
env.dispose();
}
protected void wipeUserScripts() throws IOException {
java.nio.file.Path userScriptDir =
java.nio.file.Paths.get(GhidraScriptUtil.USER_SCRIPTS_DIR);
Iterator<java.nio.file.Path> it = Files.list(userScriptDir).iterator();
while (it.hasNext()) {
Files.walk(it.next()).sorted(Comparator.reverseOrder()).map(
java.nio.file.Path::toFile).forEach(File::delete);
}
}
//==================================================================================================
// Private Methods
//==================================================================================================