Skip to content

Commit

Permalink
Fix directory management (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
grafnu committed Apr 21, 2022
1 parent 8372575 commit fcbd85e
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,7 @@ public abstract class SequenceValidator {
deviceMetadata = readDeviceMetadata();

deviceOutputDir = new File(new File(siteModel), "out/devices/" + deviceId);
try {
deviceOutputDir.mkdirs();
File testsOutputDir = new File(deviceOutputDir, TESTS_OUT_DIR);
FileUtils.deleteDirectory(testsOutputDir);
} catch (Exception e) {
throw new RuntimeException("While preparing " + deviceOutputDir.getAbsolutePath(), e);
}
deviceOutputDir.mkdirs();

resultSummary = new File(deviceOutputDir, RESULT_LOG_FILE);
resultSummary.delete();
Expand Down Expand Up @@ -171,8 +165,15 @@ public abstract class SequenceValidator {
public TestWatcher testWatcher = new TestWatcher() {
@Override
protected void starting(Description description) {
testName = description.getMethodName();
notice("starting test " + testName);
try {
testName = description.getMethodName();
File testsOutputDir = new File(new File(deviceOutputDir, TESTS_OUT_DIR), testName);
FileUtils.deleteDirectory(testsOutputDir);
testsOutputDir.mkdirs();
notice("starting test " + testName);
} catch (Exception e) {
throw new RuntimeException("While preparing " + deviceOutputDir.getAbsolutePath(), e);
}
}

@Override
Expand Down Expand Up @@ -368,7 +369,6 @@ private void recordRawMessage(Map<String, Object> message, String messageBase) {

String testOutDirName = TESTS_OUT_DIR + "/" + checkNotNull(testName);
File testOutDir = new File(deviceOutputDir, testOutDirName);
testOutDir.mkdirs();

File messageFile = new File(testOutDir, messageBase + ".json");
try {
Expand Down Expand Up @@ -418,7 +418,6 @@ private String writeLogEntry(Entry logEntry, String filename) {

String testOutDirName = TESTS_OUT_DIR + "/" + checkNotNull(testName);
File testOutDir = new File(deviceOutputDir, testOutDirName);
testOutDir.mkdirs();

File logFile = new File(testOutDir, filename);
try (PrintWriter logAppend = new PrintWriter(new FileOutputStream(logFile, true))) {
Expand Down

0 comments on commit fcbd85e

Please sign in to comment.