From cd3e756dd69d7d2fc3fb8648dcc4d7c4cc93fa45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Mon, 24 Oct 2016 08:32:16 +0200 Subject: [PATCH] Convert all tests to single-file packages. --- tests/std.concurrency.d | 93 +++++++++++++++++++ .../source/app.d => vibe.core.net.1429.d} | 7 ++ tests/vibe.core.net.1429/dub.sdl | 3 - .../source/app.d => vibe.core.net.1441.d} | 7 ++ tests/vibe.core.net.1441/dub.sdl | 3 - .../source/app.d => vibe.core.net.1452.d} | 7 ++ tests/vibe.core.net.1452/dub.sdl | 3 - travis-ci.sh | 2 +- 8 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 tests/std.concurrency.d rename tests/{vibe.core.net.1429/source/app.d => vibe.core.net.1429.d} (86%) delete mode 100644 tests/vibe.core.net.1429/dub.sdl rename tests/{vibe.core.net.1441/source/app.d => vibe.core.net.1441.d} (80%) delete mode 100644 tests/vibe.core.net.1441/dub.sdl rename tests/{vibe.core.net.1452/source/app.d => vibe.core.net.1452.d} (63%) delete mode 100644 tests/vibe.core.net.1452/dub.sdl diff --git a/tests/std.concurrency.d b/tests/std.concurrency.d new file mode 100644 index 0000000..891dc8f --- /dev/null +++ b/tests/std.concurrency.d @@ -0,0 +1,93 @@ +/++ dub.json: +{ + "name": "test", + "description": "Tests vibe.d's std.concurrency integration", + "dependencies": { + "vibe-core": {"path": "../../"} + }, + "versions": ["VibeDefaultMain"] +} ++/ +module test; + +import vibe.appmain; +import vibe.core.core; +import vibe.core.log; +import std.concurrency; +import core.atomic; +import core.time; +import core.stdc.stdlib : exit; + +__gshared Tid t1, t2; +shared watchdog_count = 0; + +shared static this() +{ + t1 = spawn({ + // ensure that asynchronous operations run in parallel to receive() + int wc = 0; + runTask({ while (true) { sleep(250.msecs); wc++; logInfo("Watchdog receiver %s", wc); } }); + + bool finished = false; + try while (!finished) { + logDebug("receive1"); + receive( + (string msg) { + logInfo("Received string message: %s", msg); + }, + (int msg) { + logInfo("Received int message: %s", msg); + }); + logDebug("receive2"); + receive( + (double msg) { + logInfo("Received double: %s", msg); + }, + (int a, int b, int c) { + logInfo("Received iii: %s %s %s", a, b, c); + + if (a == 1 && b == 2 && c == 3) + finished = true; + }); + } + catch (Exception e) assert(false, "Receiver thread failed: "~e.msg); + + logInfo("Receive loop finished."); + if (wc < 6*4-1) { + logError("Receiver watchdog failure."); + exit(1); + } + logInfo("Exiting normally"); + }); + + t2 = spawn({ + scope (failure) assert(false); + sleep(1.seconds()); + logInfo("send Hello World"); + t1.send("Hello, World!"); + + sleep(1.seconds()); + logInfo("send int 1"); + t1.send(1); + + sleep(1.seconds()); + logInfo("send double 1.2"); + t1.send(1.2); + + sleep(1.seconds()); + logInfo("send int 2"); + t1.send(2); + + sleep(1.seconds()); + logInfo("send 3xint 1 2 3"); + t1.send(1, 2, 3); + + sleep(1.seconds()); + logInfo("send string Bye bye"); + t1.send("Bye bye"); + + sleep(100.msecs); + logInfo("Exiting."); + exitEventLoop(true); + }); +} diff --git a/tests/vibe.core.net.1429/source/app.d b/tests/vibe.core.net.1429.d similarity index 86% rename from tests/vibe.core.net.1429/source/app.d rename to tests/vibe.core.net.1429.d index 53c9485..bc68283 100644 --- a/tests/vibe.core.net.1429/source/app.d +++ b/tests/vibe.core.net.1429.d @@ -1,3 +1,10 @@ +/++ dub.sdl: +name "test" +description "TCP disconnect task issue" +dependency "vibe-core" path="../../" ++/ +module test; + import vibe.core.core; import vibe.core.log : logInfo; import vibe.core.net; diff --git a/tests/vibe.core.net.1429/dub.sdl b/tests/vibe.core.net.1429/dub.sdl deleted file mode 100644 index 7fef4bd..0000000 --- a/tests/vibe.core.net.1429/dub.sdl +++ /dev/null @@ -1,3 +0,0 @@ -name "tests" -description "TCP disconnect task issue" -dependency "vibe-core" path="../../" diff --git a/tests/vibe.core.net.1441/source/app.d b/tests/vibe.core.net.1441.d similarity index 80% rename from tests/vibe.core.net.1441/source/app.d rename to tests/vibe.core.net.1441.d index 412bbfd..7e73baf 100644 --- a/tests/vibe.core.net.1441/source/app.d +++ b/tests/vibe.core.net.1441.d @@ -1,3 +1,10 @@ +/++ dub.sdl: +name "test" +description "TCP disconnect task issue" +dependency "vibe-core" path="../../" ++/ +module test; + import vibe.core.core; import vibe.core.net; import core.time : msecs; diff --git a/tests/vibe.core.net.1441/dub.sdl b/tests/vibe.core.net.1441/dub.sdl deleted file mode 100644 index 7fef4bd..0000000 --- a/tests/vibe.core.net.1441/dub.sdl +++ /dev/null @@ -1,3 +0,0 @@ -name "tests" -description "TCP disconnect task issue" -dependency "vibe-core" path="../../" diff --git a/tests/vibe.core.net.1452/source/app.d b/tests/vibe.core.net.1452.d similarity index 63% rename from tests/vibe.core.net.1452/source/app.d rename to tests/vibe.core.net.1452.d index 3420b06..4c7b7f5 100644 --- a/tests/vibe.core.net.1452/source/app.d +++ b/tests/vibe.core.net.1452.d @@ -1,3 +1,10 @@ +/++ dub.sdl: +name "test" +description "Invalid memory operation on TCP connection leakage at shutdown" +dependency "vibe-core" path="../../" ++/ +module test; + import vibe.core.core; import vibe.core.net; import core.time : msecs; diff --git a/tests/vibe.core.net.1452/dub.sdl b/tests/vibe.core.net.1452/dub.sdl deleted file mode 100644 index c67f01c..0000000 --- a/tests/vibe.core.net.1452/dub.sdl +++ /dev/null @@ -1,3 +0,0 @@ -name "tests" -description "Invalid memory operation on TCP connection leakage at shutdown" -dependency "vibe-core" path="../../" diff --git a/travis-ci.sh b/travis-ci.sh index ee3ffb9..08cc2ce 100755 --- a/travis-ci.sh +++ b/travis-ci.sh @@ -21,6 +21,6 @@ fi if [ ${RUN_TEST=1} -eq 1 ]; then for ex in `\ls -1 tests/`; do echo "[INFO] Running test $ex" - (cd tests/$ex && dub --compiler=$DC && dub clean) + (cd tests && dub --compiler=$DC --single $ex && dub clean) done fi