Skip to content

Commit

Permalink
Merge pull request #9568 from oleksabor/clearTempTest
Browse files Browse the repository at this point in the history
clearing temp directories from CodegenIgnoreProcessorTest
  • Loading branch information
HugoMario authored Jul 23, 2019
2 parents 5fdfaa4 + d0180a6 commit 6f7f156
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.ConcurrentLinkedQueue;

public class CodegenIgnoreProcessorTest {

Expand All @@ -25,6 +26,7 @@ public class CodegenIgnoreProcessorTest {
private String outputDir;
private File target;
private Path temp;
private static final ConcurrentLinkedQueue<Path> tempQueue = new ConcurrentLinkedQueue<>();

private CodegenIgnoreProcessorTest(String filename, String ignoreDefinition, String description) throws IOException {
this.filename = filename;
Expand All @@ -51,6 +53,7 @@ private void prepareTestFiles() throws IOException {
// NOTE: Each test needs its own directory because .swagger-codegen-ignore needs to exist at the root.
temp = Files.createTempDirectory(getClass().getSimpleName());
this.outputDir = temp.toFile().getAbsolutePath();
tempQueue.add(temp);

target = new File(this.outputDir, this.filename);

Expand All @@ -73,9 +76,11 @@ private void prepareTestFiles() throws IOException {

@AfterTest
public void afterTest() throws IOException {
if(temp != null && temp.toFile().exists() && temp.toFile().isDirectory()) {
FileUtils.deleteDirectory(temp.toFile());
}
Path t;
while ((t = tempQueue.poll()) != null)
if(t != null && t.toFile().exists() && t.toFile().isDirectory()) {
FileUtils.deleteDirectory(t.toFile());
}
}

@Test
Expand Down

0 comments on commit 6f7f156

Please sign in to comment.