diff --git a/.travis.yml b/.travis.yml index a2b7dc1..2d86252 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: d +os: + - linux + - osx + d: # order: latest DMD, oldest DMD, LDC/GDC, remaining DMD versions # this way the overall test time gets cut down (GDC/LDC are a lot @@ -21,6 +25,7 @@ d: env: - CONFIG=select - CONFIG=epoll + - CONFIG=kqueue # disabled until the libasync driver of eventcore is more than a stub #- CONFIG=libasync @@ -28,6 +33,22 @@ matrix: allow_failures: - env: CONFIG=libasync - d: dmd-beta + exclude: + - os: linux + env: CONFIG=kqueue + - os: osx + env: CONFIG=epoll + # see https://github.com/ldc-developers/ldc/issues/2187 + - d: ldc-1.17.0 + os: osx + - d: ldc-1.16.0 + os: osx + - d: ldc-1.15.0 + os: osx + - d: ldc-1.14.0 + os: osx + - d: ldc-1.9.0 + os: osx include: - d: dmd env: CONFIG='select' DUB_FLAGS='--build unittest-cov --build-mode=singleFile' diff --git a/tests/dirwatcher.d b/tests/dirwatcher.d index 8f0ef92..d1f739f 100644 --- a/tests/dirwatcher.d +++ b/tests/dirwatcher.d @@ -20,6 +20,11 @@ import std.typecons : No, Yes; import core.exception : AssertError; import core.time : msecs, seconds; + +version (OSX) enum sleepTime = 3.seconds; +else enum sleepTime = 500.msecs; + + void runTest() { 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)); } void check(DirectoryChange[] expected) { - sleep(1500.msecs); + sleep(sleepTime); 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 +54,15 @@ void runTest() write(foo, null); check([dc(Type.added, foo)]); - sleep(1500.msecs); + sleep(sleepTime); write(foo, [0, 1]); check([dc(Type.modified, foo)]); remove(foo); check([dc(Type.removed, foo)]); write(foo, null); - sleep(1500.msecs); + sleep(sleepTime); write(foo, [0, 1]); - sleep(1500.msecs); + sleep(sleepTime); remove(foo); check([dc(Type.added, foo), dc(Type.modified, foo), dc(Type.removed, foo)]); @@ -70,23 +75,23 @@ void runTest() remove(bar); watcher = Path(dir).watchDirectory(Yes.recursive); write(foo, null); - sleep(1500.msecs); + sleep(sleepTime); write(foo, [0, 1]); - sleep(1500.msecs); + sleep(sleepTime); remove(foo); write(bar, null); - sleep(1500.msecs); + sleep(sleepTime); write(bar, [0, 1]); - sleep(1500.msecs); + sleep(sleepTime); 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(1500.msecs); + sleep(sleepTime); rename(foo, bar); - sleep(1500.msecs); + sleep(sleepTime); remove(bar); check([dc(Type.added, foo), dc(Type.removed, foo), dc(Type.added, bar), dc(Type.removed, bar)]); diff --git a/tests/issue-115-connect-fail-leak.d b/tests/issue-115-connect-fail-leak.d index 9af3afc..95afedb 100644 --- a/tests/issue-115-connect-fail-leak.d +++ b/tests/issue-115-connect-fail-leak.d @@ -19,15 +19,19 @@ void main() auto initial = determineSocketCount(); + foreach (i; 0 .. 3) + test(); + + assert(determineSocketCount() <= initial + 1, "Sockets leaked!"); +} + +void test() +{ TCPConnection conn; try { conn = connectTCP("127.0.0.1", 16565); - logError("Connection: %s", conn); - conn.close(); assert(false, "Didn't expect TCP connection on port 16565 to succeed"); } catch (Exception) { } - - assert(determineSocketCount() == initial, "Sockets leaked!"); } size_t determineSocketCount() diff --git a/tests/std.concurrency.d b/tests/std.concurrency.d index b7a7a55..f310a9a 100644 --- a/tests/std.concurrency.d +++ b/tests/std.concurrency.d @@ -47,7 +47,9 @@ void main() catch (Exception e) assert(false, "Receiver thread failed: "~e.msg); logInfo("Receive loop finished."); - if (wc < 6*4-1) { + version (OSX) enum tolerance = 4; // macOS CI VMs have particularly bad timing behavior + else enum tolerance = 1; + if (wc < 6 * 4 - tolerance) { logError("Receiver watchdog failure."); exit(1); } diff --git a/tests/vibe.core.net.1429.d b/tests/vibe.core.net.1429.d index 14c7fcc..0b38bc8 100644 --- a/tests/vibe.core.net.1429.d +++ b/tests/vibe.core.net.1429.d @@ -26,8 +26,11 @@ void main() assert(false, "Timeout did not occur."); } catch (Exception e) { auto duration = MonoTime.currTime() - start; + version (OSX) enum maxtolerance = 150.msecs; + else enum maxtolerance = 50.msecs; assert(duration >= 99.msecs, "Timeout occurred too early"); - assert(duration >= 99.msecs && duration < 150.msecs, "Timeout occurred too late."); + assert(duration >= 99.msecs && duration < 100.msecs + maxtolerance, + "Timeout occurred too late."); logInfo("UDP receive timeout test was successful."); exitEventLoop(); } diff --git a/travis-ci.sh b/travis-ci.sh index 439a8eb..2b91b6b 100755 --- a/travis-ci.sh +++ b/travis-ci.sh @@ -26,7 +26,7 @@ if [ ${BUILD_EXAMPLE=1} -eq 1 ]; then fi if [ ${RUN_TEST=1} -eq 1 ]; then for ex in `\ls -1 tests/*.d`; do - script="${ex:0:-2}.sh" + script="${ex%.d}.sh" if [ -e "$script" ]; then echo "[INFO] Running test scipt $script" (cd tests && "./${script:6}")