Fix Issue 10902 - some phobos unittests take an excessive amount of time

This commit is contained in:
Bernhard Seckinger 2019-11-12 17:14:13 +01:00
parent 073960ecae
commit 97abb91952
4 changed files with 16 additions and 16 deletions

View file

@ -485,7 +485,7 @@ if (!allSatisfy!(isForwardRange, R1, R2, RR) ||
assert(is(ElementType!(typeof(N3)) == Tuple!(size_t,size_t,size_t)));
assert(canFind(N3, tuple(0, 27, 7)));
assert(canFind(N3, tuple(50, 23, 71)));
assert(canFind(N3, tuple(50, 23, 11)));
assert(canFind(N3, tuple(9, 3, 0)));
}
@ -503,7 +503,7 @@ if (!allSatisfy!(isForwardRange, R1, R2, RR) ||
assert(canFind(N4, tuple(1, 2, 3, 4)));
assert(canFind(N4, tuple(4, 3, 2, 1)));
assert(canFind(N4, tuple(10, 3, 7, 2)));
assert(canFind(N4, tuple(10, 3, 1, 2)));
}
// Issue 9878

View file

@ -4372,25 +4372,25 @@ version (unittest)
assert(equal(nums, iota(1000)));
assert(equal(
poolInstance.map!"a * a"(iota(30_000_001), 10_000),
map!"a * a"(iota(30_000_001))
poolInstance.map!"a * a"(iota(3_000_001), 10_000),
map!"a * a"(iota(3_000_001))
));
// The filter is to kill random access and test the non-random access
// branch.
assert(equal(
poolInstance.map!"a * a"(
filter!"a == a"(iota(30_000_001)
filter!"a == a"(iota(3_000_001)
), 10_000, 1000),
map!"a * a"(iota(30_000_001))
map!"a * a"(iota(3_000_001))
));
assert(
reduce!"a + b"(0UL,
poolInstance.map!"a * a"(iota(3_000_001), 10_000)
poolInstance.map!"a * a"(iota(300_001), 10_000)
) ==
reduce!"a + b"(0UL,
map!"a * a"(iota(3_000_001))
map!"a * a"(iota(300_001))
)
);

View file

@ -1137,7 +1137,7 @@ version (Posix) @system unittest
wait(pid);
else
// We need to wait a little to ensure that the process has finished and data was written to files
Thread.sleep(2.seconds);
Thread.sleep(500.msecs);
assert(readText(patho).chomp() == "INPUT output bar");
assert(readText(pathe).chomp().stripRight() == "INPUT error baz");
remove(pathi);
@ -1861,13 +1861,13 @@ void kill(Pid pid, int codeOrSignal)
version (Android)
Thread.sleep(dur!"msecs"(5));
else
Thread.sleep(dur!"seconds"(1));
Thread.sleep(dur!"msecs"(500));
kill(pid);
version (Windows) assert(wait(pid) == 1);
else version (Posix) assert(wait(pid) == -SIGTERM);
pid = spawnProcess(prog.path);
Thread.sleep(dur!"seconds"(1));
Thread.sleep(dur!"msecs"(500));
auto s = tryWait(pid);
assert(!s.terminated && s.status == 0);
assertThrown!ProcessException(kill(pid, -123)); // Negative code not allowed.
@ -1891,7 +1891,7 @@ void kill(Pid pid, int codeOrSignal)
This leads to the annoying message like "/bin/sh: 0: Can't open /tmp/std.process temporary file" to appear when running tests.
It does not happen in unittests with non-detached processes because we always wait() for them to finish.
*/
Thread.sleep(1.seconds);
Thread.sleep(500.msecs);
assert(!pid.owned);
version (Windows) assert(pid.osHandle == INVALID_HANDLE_VALUE);
assertThrown!ProcessException(wait(pid));

View file

@ -3995,7 +3995,7 @@ if (isInputRange!Range && hasLength!Range && isUniformRNG!UniformRNG)
*/
{
size_t count0, count1, count99;
foreach (_; 0 .. 100_000)
foreach (_; 0 .. 50_000)
{
auto sample = randomSample(iota(100), 5, &rng);
sample.popFront();
@ -4030,9 +4030,9 @@ if (isInputRange!Range && hasLength!Range && isUniformRNG!UniformRNG)
* the variance can be quite high.
*/
assert(count0 == 0);
assert(count1 < 300, text("1: ", count1, " > 300."));
assert(4_700 < count99, text("99: ", count99, " < 4700."));
assert(count99 < 5_300, text("99: ", count99, " > 5300."));
assert(count1 < 150, text("1: ", count1, " > 150."));
assert(2_200 < count99, text("99: ", count99, " < 2200."));
assert(count99 < 2_800, text("99: ", count99, " > 2800."));
}
/* Odd corner-cases: RandomSample has 2 constructors that are not called