Increase directory watcher test sleep time on macOS (decrease on others).
This commit is contained in:
parent
d60b0e4b64
commit
71a2172edf
|
@ -20,6 +20,11 @@ import std.typecons : No, Yes;
|
||||||
import core.exception : AssertError;
|
import core.exception : AssertError;
|
||||||
import core.time : msecs, seconds;
|
import core.time : msecs, seconds;
|
||||||
|
|
||||||
|
|
||||||
|
version (OSX) enum sleepTime = 3.seconds;
|
||||||
|
else enum sleepTime = 500.msecs;
|
||||||
|
|
||||||
|
|
||||||
void runTest()
|
void runTest()
|
||||||
{
|
{
|
||||||
auto dir = buildPath(tempDir, format("dirwatcher_test_%d", thisProcessID()));
|
auto dir = buildPath(tempDir, format("dirwatcher_test_%d", thisProcessID()));
|
||||||
|
@ -41,7 +46,7 @@ void runTest()
|
||||||
static DirectoryChange dc(Type t, string p) { return DirectoryChange(t, Path(p)); }
|
static DirectoryChange dc(Type t, string p) { return DirectoryChange(t, Path(p)); }
|
||||||
void check(DirectoryChange[] expected)
|
void check(DirectoryChange[] expected)
|
||||||
{
|
{
|
||||||
sleep(1500.msecs);
|
sleep(sleepTime);
|
||||||
assert(watcher.readChanges(changes, 100.msecs), "Could not read changes for " ~ expected.to!string);
|
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(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);
|
assert(!watcher.readChanges(changes, 0.msecs), "Changes were returned when they shouldn't have, for " ~ expected.to!string);
|
||||||
|
@ -49,15 +54,15 @@ void runTest()
|
||||||
|
|
||||||
write(foo, null);
|
write(foo, null);
|
||||||
check([dc(Type.added, foo)]);
|
check([dc(Type.added, foo)]);
|
||||||
sleep(1500.msecs);
|
sleep(sleepTime);
|
||||||
write(foo, [0, 1]);
|
write(foo, [0, 1]);
|
||||||
check([dc(Type.modified, foo)]);
|
check([dc(Type.modified, foo)]);
|
||||||
remove(foo);
|
remove(foo);
|
||||||
check([dc(Type.removed, foo)]);
|
check([dc(Type.removed, foo)]);
|
||||||
write(foo, null);
|
write(foo, null);
|
||||||
sleep(1500.msecs);
|
sleep(sleepTime);
|
||||||
write(foo, [0, 1]);
|
write(foo, [0, 1]);
|
||||||
sleep(1500.msecs);
|
sleep(sleepTime);
|
||||||
remove(foo);
|
remove(foo);
|
||||||
check([dc(Type.added, foo), dc(Type.modified, foo), dc(Type.removed, foo)]);
|
check([dc(Type.added, foo), dc(Type.modified, foo), dc(Type.removed, foo)]);
|
||||||
|
|
||||||
|
@ -70,23 +75,23 @@ void runTest()
|
||||||
remove(bar);
|
remove(bar);
|
||||||
watcher = Path(dir).watchDirectory(Yes.recursive);
|
watcher = Path(dir).watchDirectory(Yes.recursive);
|
||||||
write(foo, null);
|
write(foo, null);
|
||||||
sleep(1500.msecs);
|
sleep(sleepTime);
|
||||||
write(foo, [0, 1]);
|
write(foo, [0, 1]);
|
||||||
sleep(1500.msecs);
|
sleep(sleepTime);
|
||||||
remove(foo);
|
remove(foo);
|
||||||
|
|
||||||
write(bar, null);
|
write(bar, null);
|
||||||
sleep(1500.msecs);
|
sleep(sleepTime);
|
||||||
write(bar, [0, 1]);
|
write(bar, [0, 1]);
|
||||||
sleep(1500.msecs);
|
sleep(sleepTime);
|
||||||
remove(bar);
|
remove(bar);
|
||||||
check([dc(Type.added, foo), dc(Type.modified, foo), dc(Type.removed, foo),
|
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)]);
|
dc(Type.added, bar), dc(Type.modified, bar), dc(Type.removed, bar)]);
|
||||||
|
|
||||||
write(foo, null);
|
write(foo, null);
|
||||||
sleep(1500.msecs);
|
sleep(sleepTime);
|
||||||
rename(foo, bar);
|
rename(foo, bar);
|
||||||
sleep(1500.msecs);
|
sleep(sleepTime);
|
||||||
remove(bar);
|
remove(bar);
|
||||||
check([dc(Type.added, foo), dc(Type.removed, foo), dc(Type.added, bar), dc(Type.removed, bar)]);
|
check([dc(Type.added, foo), dc(Type.removed, foo), dc(Type.added, bar), dc(Type.removed, bar)]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue