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.core;
|
||||
import vibe.core.process;
|
||||
import std.algorithm;
|
||||
import std.array;
|
||||
import std.range;
|
||||
import std.algorithm;
|
||||
|
||||
void testEcho()
|
||||
{
|
||||
|
@ -102,7 +102,8 @@ void testRandomDeath()
|
|||
sleep(800.msecs);
|
||||
try {
|
||||
process.kill();
|
||||
} catch (Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
process.wait();
|
||||
|
||||
assert(process.exited);
|
||||
|
@ -177,29 +178,40 @@ void testLineEndings()
|
|||
|
||||
void main()
|
||||
{
|
||||
import core.stdc.stdlib : abort;
|
||||
import core.time;
|
||||
import std.meta : AliasSeq;
|
||||
|
||||
// rdmd --eval is only supported in versions >= 2.080
|
||||
static if (__VERSION__ >= 2080) {
|
||||
runTask({
|
||||
auto tasks = [
|
||||
&testEcho,
|
||||
&testCat,
|
||||
&testStderr,
|
||||
&testRandomDeath,
|
||||
&testIgnoreSigterm,
|
||||
&testSimpleShell,
|
||||
&testLineEndings,
|
||||
].map!(fn => runTask({
|
||||
try {
|
||||
fn();
|
||||
} catch (Exception e) {
|
||||
logError("%s", e);
|
||||
throw e;
|
||||
}
|
||||
}));
|
||||
alias Tasks = AliasSeq!(
|
||||
testEcho,
|
||||
testCat,
|
||||
testStderr,
|
||||
testRandomDeath,
|
||||
testIgnoreSigterm,
|
||||
testSimpleShell,
|
||||
testLineEndings
|
||||
);
|
||||
|
||||
foreach (task; tasks) {
|
||||
task.join();
|
||||
static foreach (alias task; Tasks) {{
|
||||
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();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue