mirror of
https://github.com/frohoff/ysoserial.git
synced 2026-09-21 22:50:46 +08:00
fix (hopefully) test flakiness
This commit is contained in:
@@ -47,9 +47,12 @@ public class FileUploadTest implements CustomTest {
|
|||||||
payload.call();
|
payload.call();
|
||||||
|
|
||||||
File found = null;
|
File found = null;
|
||||||
for ( File f : this.repo.listFiles()) {
|
for (int i = 0; i < 50 && found == null; i++) { // try for 5s before failing
|
||||||
found = f;
|
for (File f : this.repo.listFiles()) {
|
||||||
break;
|
found = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
Assert.assertNotNull("File not copied", found);
|
Assert.assertNotNull("File not copied", found);
|
||||||
if (OS.get() != OS.WINDOWS) {
|
if (OS.get() != OS.WINDOWS) {
|
||||||
@@ -60,11 +63,21 @@ public class FileUploadTest implements CustomTest {
|
|||||||
} finally {
|
} finally {
|
||||||
if ( this.repo.exists()) {
|
if ( this.repo.exists()) {
|
||||||
for ( File f : this.repo.listFiles()) {
|
for ( File f : this.repo.listFiles()) {
|
||||||
f.deleteOnExit();
|
safeDeleteOnExit(f);
|
||||||
}
|
}
|
||||||
this.repo.deleteOnExit();
|
safeDeleteOnExit(this.repo);
|
||||||
}
|
}
|
||||||
this.source.deleteOnExit();
|
safeDeleteOnExit(this.source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void safeDeleteOnExit(File f) {
|
||||||
|
try {
|
||||||
|
if (f.exists()) {
|
||||||
|
f.deleteOnExit();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user