mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 14:10:30 +03:00
Use redirection of stderr to null
This commit is contained in:
parent
e28ac3c61d
commit
5da48602d8
2 changed files with 23 additions and 16 deletions
|
@ -1642,29 +1642,23 @@ static:
|
|||
@system unittest
|
||||
{
|
||||
// Temporarily disable output to stderr so as to not spam the build log.
|
||||
import std.stdio;
|
||||
import std.stdio : stderr;
|
||||
auto t = stderr;
|
||||
stderr.open("/dev/null", "w");
|
||||
version (Posix)
|
||||
stderr.open("/dev/null", "w");
|
||||
else
|
||||
stderr.open("nul", "w");
|
||||
scope(exit) stderr = t;
|
||||
|
||||
auto a = checked!Warn(int.min);
|
||||
auto b = checked!Warn(-1);
|
||||
assert(a / b == a * b);
|
||||
}
|
||||
|
||||
@system unittest
|
||||
{
|
||||
// Temporarily disable output to stderr so as to not spam the build log.
|
||||
import std.stdio;
|
||||
auto t = stderr;
|
||||
stderr.open("/dev/null", "w");
|
||||
scope(exit) stderr = t;
|
||||
|
||||
import std.exception : assertThrown;
|
||||
import core.exception : AssertError;
|
||||
|
||||
auto a = checked!Abort(int.min);
|
||||
auto b = checked!Abort(-1);
|
||||
assertThrown!AssertError(a / b);
|
||||
auto x = checked!Abort(int.min);
|
||||
auto y = checked!Abort(-1);
|
||||
assertThrown!AssertError(x / y);
|
||||
}
|
||||
|
||||
// ProperCompare
|
||||
|
|
|
@ -3122,7 +3122,20 @@ private auto executeImpl(alias pipeFunc, Cmd, ExtraPipeFuncArgs...)(
|
|||
auto r3 = executeShell("exit 123");
|
||||
assert(r3.status == 123);
|
||||
assert(r3.output.empty);
|
||||
auto r4 = executeShell("echo -n '\r' 1>&2",
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
// Temporarily disable output to stderr so as to not spam the build log.
|
||||
import std.stdio : stderr;
|
||||
auto t = stderr;
|
||||
version (Posix)
|
||||
stderr.open("/dev/null", "w");
|
||||
else
|
||||
stderr.open("nul", "w");
|
||||
scope(exit) stderr = t;
|
||||
|
||||
auto r4 = executeShell("echo This line should not be visible. 1>&2",
|
||||
null, Config.stderrPassThrough);
|
||||
assert(r4.status == 0);
|
||||
assert(r4.output.empty);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue