Increase test delays to accommodate for the polling directory watcher.

This commit is contained in:
Sönke Ludwig 2017-12-01 20:32:07 +01:00
parent d0d8b78568
commit aa300d39ca

View file

@ -33,7 +33,7 @@ void runTest()
return;
}
DirectoryChange[] changes;
assert(!watcher.readChanges(changes, 500.msecs));
assert(!watcher.readChanges(changes, 1500.msecs));
auto foo = dir.buildPath("foo");
@ -41,7 +41,7 @@ void runTest()
static DirectoryChange dc(Type t, string p) { return DirectoryChange(t, Path(p)); }
void check(DirectoryChange[] expected)
{
sleep(100.msecs);
sleep(1500.msecs);
assert(watcher.readChanges(changes, 100.msecs), "Could not read changes for " ~ expected.to!string);
assert(expected.all!((a)=> changes.canFind(a))(), "Change is not what was expected, got: " ~ changes.to!string ~ " but expected: " ~ expected.to!string);
assert(!watcher.readChanges(changes, 0.msecs), "Changes were returned when they shouldn't have, for " ~ expected.to!string);
@ -49,15 +49,15 @@ void runTest()
write(foo, null);
check([dc(Type.added, foo)]);
sleep(1.seconds); // OSX has a second resolution on file modification times
sleep(1500.msecs);
write(foo, [0, 1]);
check([dc(Type.modified, foo)]);
remove(foo);
check([dc(Type.removed, foo)]);
write(foo, null);
sleep(1.seconds);
sleep(1500.msecs);
write(foo, [0, 1]);
sleep(100.msecs);
sleep(1500.msecs);
remove(foo);
check([dc(Type.added, foo), dc(Type.modified, foo), dc(Type.removed, foo)]);
@ -70,23 +70,23 @@ void runTest()
remove(bar);
watcher = Path(dir).watchDirectory(Yes.recursive);
write(foo, null);
sleep(1.seconds);
sleep(1500.msecs);
write(foo, [0, 1]);
sleep(100.msecs);
sleep(1500.msecs);
remove(foo);
write(bar, null);
sleep(1.seconds);
sleep(1500.msecs);
write(bar, [0, 1]);
sleep(100.msecs);
sleep(1500.msecs);
remove(bar);
check([dc(Type.added, foo), dc(Type.modified, foo), dc(Type.removed, foo),
dc(Type.added, bar), dc(Type.modified, bar), dc(Type.removed, bar)]);
write(foo, null);
sleep(100.msecs);
sleep(1500.msecs);
rename(foo, bar);
sleep(100.msecs);
sleep(1500.msecs);
remove(bar);
check([dc(Type.added, foo), dc(Type.removed, foo), dc(Type.added, bar), dc(Type.removed, bar)]);