Skip to content

Commit

Permalink
Try to reduce flakiness on Windows for BwoB tests
Browse files Browse the repository at this point in the history
  • Loading branch information
coeuvre committed Feb 13, 2023
1 parent 9f2c62a commit 80fdafd
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
import java.net.DatagramSocket;
import java.net.ServerSocket;
import java.net.SocketException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.Random;

/** Integration test utilities. */
Expand Down Expand Up @@ -140,8 +144,17 @@ private WorkerInstance(
this.pidPath = pidPath;
}

public void stop() {
public void stop() throws IOException {
process.destroyAndWait();
deleteDir(workPath);
deleteDir(casPath);
new File(pidPath.getSafePathString()).delete();
}

private static void deleteDir(PathFragment path) throws IOException {
try (var stream = Files.walk(Paths.get(path.getSafePathString()))) {
stream.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
}
}

public int getPort() {
Expand Down

0 comments on commit 80fdafd

Please sign in to comment.