From 9295988af3588618e4ccf866c556651a70671f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 22 Oct 2019 14:42:00 +0200 Subject: [PATCH 1/8] Test on macOS in addition to Linux/Windows. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index a2b7dc1..44ca372 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 From 262385e429afc57cf871564e6ef93e85bc0aa4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 22 Oct 2019 15:22:28 +0200 Subject: [PATCH 2/8] Fix test script macOS bash compatibility. --- travis-ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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}") From bef1c573153bc6c619302372e09325111a7faba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sat, 2 Nov 2019 14:56:57 +0100 Subject: [PATCH 3/8] Allow a single FD to be "leaked" in the TCP connect leak test. On macOS, the kqueue mechanism appears to create an internal FD that wrongly triggers the leak condition. --- tests/issue-115-connect-fail-leak.d | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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() From 5116ddbd57306f603db7045de46d80f50072877d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sat, 2 Nov 2019 15:41:31 +0100 Subject: [PATCH 4/8] Be more tolerant w.r.t. timing for macOS test due to CI VM timing issues. --- tests/std.concurrency.d | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } From f23b23f360b83e7aeb2ed7c3e4aeb6ecb7029f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sat, 2 Nov 2019 22:18:29 +0100 Subject: [PATCH 5/8] test kqueue instead of epoll on macos --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 44ca372..c44a1f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,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 @@ -32,6 +33,11 @@ matrix: allow_failures: - env: CONFIG=libasync - d: dmd-beta + exclude: + - os: linux + env: CONFIG=kqueue + - os: osx + env: CONFIG=epoll include: - d: dmd env: CONFIG='select' DUB_FLAGS='--build unittest-cov --build-mode=singleFile' From c717b8805736443afc0a84ca38211237bec132df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sat, 2 Nov 2019 22:52:56 +0100 Subject: [PATCH 6/8] Increase test timeout tolerance on macOS. --- tests/vibe.core.net.1429.d | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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(); } From d60b0e4b6425985b1698ac6bf3202ec204ee1c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 22 Nov 2019 20:52:54 +0100 Subject: [PATCH 7/8] Skip LDC/macOS tests due to ldc-developers/ldc#2187. --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.travis.yml b/.travis.yml index c44a1f7..2d86252 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,17 @@ matrix: 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' From 71a2172edf06d75476a8878bce5a315ae462d558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sat, 23 Nov 2019 09:36:07 +0100 Subject: [PATCH 8/8] Increase directory watcher test sleep time on macOS (decrease on others). --- tests/dirwatcher.d | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) 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)]);