forked from jasder/antlr
improve management of test directories
This commit is contained in:
parent
84fbdc8038
commit
e38eec4d95
|
@ -148,10 +148,15 @@ public abstract class BaseTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// new output dir for each test
|
||||
tmpdir = new File(System.getProperty("java.io.tmpdir"),
|
||||
String prop = System.getProperty("antlr-java-test-dir");
|
||||
if(prop!=null && prop.length()>0)
|
||||
tmpdir = prop;
|
||||
else
|
||||
// new output dir for each test
|
||||
tmpdir = new File(System.getProperty("java.io.tmpdir"),
|
||||
getClass().getSimpleName()+"-"+System.currentTimeMillis()).getAbsolutePath();
|
||||
// tmpdir = "/tmp";
|
||||
if(new File(tmpdir).exists())
|
||||
eraseFiles();
|
||||
}
|
||||
|
||||
protected org.antlr.v4.Tool newTool(String[] args) {
|
||||
|
@ -1175,10 +1180,17 @@ public abstract class BaseTest {
|
|||
}
|
||||
|
||||
protected void eraseTempDir() {
|
||||
File tmpdirF = new File(tmpdir);
|
||||
if ( tmpdirF.exists() ) {
|
||||
eraseFiles();
|
||||
tmpdirF.delete();
|
||||
boolean doErase = true;
|
||||
String propName = "antlr-java-erase-test-dir";
|
||||
String prop = System.getProperty(propName);
|
||||
if(prop!=null && prop.length()>0)
|
||||
doErase = Boolean.getBoolean(prop);
|
||||
if(doErase) {
|
||||
File tmpdirF = new File(tmpdir);
|
||||
if ( tmpdirF.exists() ) {
|
||||
eraseFiles();
|
||||
tmpdirF.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue