Add timeouts to avoid the compile time effects of rdmd on tests passing

This commit is contained in:
Benjamin Schaaf 2019-05-05 18:02:26 +10:00
parent 83e2d391e6
commit 65980326a1

View file

@ -61,6 +61,9 @@ void testStderr()
}; };
auto procPipes = pipeProcess(["rdmd", "--eval", program], Redirect.stdin | Redirect.stderr); auto procPipes = pipeProcess(["rdmd", "--eval", program], Redirect.stdin | Redirect.stderr);
// Wait for rdmd to compile
sleep(1.seconds);
string output; string output;
auto outputTask = runTask({ auto outputTask = runTask({
output = procPipes.stderr.collectOutput(); output = procPipes.stderr.collectOutput();
@ -83,12 +86,15 @@ void testStderr()
void testRandomDeath() void testRandomDeath()
{ {
foreach (i; 0..20) {
auto program = q{ auto program = q{
import core.thread; import core.thread;
import std.random; import std.random;
Thread.sleep(dur!"msecs"(uniform(0, 1000))); Thread.sleep(dur!"msecs"(uniform(0, 1000)));
}; };
// Prime rdmd
execute(["rdmd", "--eval", program]);
foreach (i; 0..20) {
auto process = spawnProcess(["rdmd", "--eval", program]); auto process = spawnProcess(["rdmd", "--eval", program]);
assert(!process.exited); assert(!process.exited);
@ -131,8 +137,8 @@ void testIgnoreSigterm()
assert(!procPipes.process.exited); assert(!procPipes.process.exited);
// Give the program some time to install the signal handler // Give the program some time to compile and install the signal handler
sleep(1.seconds); sleep(2.seconds);
procPipes.process.kill(); procPipes.process.kill();
procPipes.stdin.write("foo\n"); procPipes.stdin.write("foo\n");