Convert all tests to single-file packages.

This commit is contained in:
Sönke Ludwig 2016-10-24 08:32:16 +02:00
parent c08f101549
commit cd3e756dd6
8 changed files with 115 additions and 10 deletions

93
tests/std.concurrency.d Normal file
View file

@ -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);
});
}

View file

@ -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;

View file

@ -1,3 +0,0 @@
name "tests"
description "TCP disconnect task issue"
dependency "vibe-core" path="../../"

View file

@ -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;

View file

@ -1,3 +0,0 @@
name "tests"
description "TCP disconnect task issue"
dependency "vibe-core" path="../../"

View file

@ -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;

View file

@ -1,3 +0,0 @@
name "tests"
description "Invalid memory operation on TCP connection leakage at shutdown"
dependency "vibe-core" path="../../"

View file

@ -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