Add watchdog and log output to vibe.core.process test.
This commit is contained in:
parent
c74ce47cc9
commit
3e619560af
|
@ -9,9 +9,9 @@ import core.thread;
|
||||||
import vibe.core.log;
|
import vibe.core.log;
|
||||||
import vibe.core.core;
|
import vibe.core.core;
|
||||||
import vibe.core.process;
|
import vibe.core.process;
|
||||||
|
import std.algorithm;
|
||||||
import std.array;
|
import std.array;
|
||||||
import std.range;
|
import std.range;
|
||||||
import std.algorithm;
|
|
||||||
|
|
||||||
void testEcho()
|
void testEcho()
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,8 @@ void testRandomDeath()
|
||||||
sleep(800.msecs);
|
sleep(800.msecs);
|
||||||
try {
|
try {
|
||||||
process.kill();
|
process.kill();
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
process.wait();
|
process.wait();
|
||||||
|
|
||||||
assert(process.exited);
|
assert(process.exited);
|
||||||
|
@ -177,29 +178,40 @@ void testLineEndings()
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
import core.stdc.stdlib : abort;
|
||||||
|
import core.time;
|
||||||
|
import std.meta : AliasSeq;
|
||||||
|
|
||||||
// rdmd --eval is only supported in versions >= 2.080
|
// rdmd --eval is only supported in versions >= 2.080
|
||||||
static if (__VERSION__ >= 2080) {
|
static if (__VERSION__ >= 2080) {
|
||||||
runTask({
|
runTask({
|
||||||
auto tasks = [
|
alias Tasks = AliasSeq!(
|
||||||
&testEcho,
|
testEcho,
|
||||||
&testCat,
|
testCat,
|
||||||
&testStderr,
|
testStderr,
|
||||||
&testRandomDeath,
|
testRandomDeath,
|
||||||
&testIgnoreSigterm,
|
testIgnoreSigterm,
|
||||||
&testSimpleShell,
|
testSimpleShell,
|
||||||
&testLineEndings,
|
testLineEndings
|
||||||
].map!(fn => runTask({
|
);
|
||||||
try {
|
|
||||||
fn();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logError("%s", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
foreach (task; tasks) {
|
static foreach (alias task; Tasks) {{
|
||||||
task.join();
|
auto t = runTask({
|
||||||
|
logInfo("Running test %s...", __traits(identifier, task));
|
||||||
|
auto tm = setTimer(60.seconds, {
|
||||||
|
logError("Test %s timed out!", __traits(identifier, task));
|
||||||
|
abort();
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
task();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logError("Test %s failed: %s", __traits(identifier, task), e);
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
|
tm.stop();
|
||||||
|
});
|
||||||
|
t.join();
|
||||||
|
}}
|
||||||
|
|
||||||
exitEventLoop();
|
exitEventLoop();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue