mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
Removed global std.exception import from std.process
This commit is contained in:
parent
703566e28e
commit
fd1afb27b2
1 changed files with 17 additions and 2 deletions
|
@ -102,7 +102,6 @@ version (Windows)
|
||||||
}
|
}
|
||||||
|
|
||||||
import std.range.primitives;
|
import std.range.primitives;
|
||||||
import std.exception;
|
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import std.internal.processinit;
|
import std.internal.processinit;
|
||||||
import std.internal.cstring;
|
import std.internal.cstring;
|
||||||
|
@ -912,6 +911,7 @@ unittest // Stream redirection in spawnProcess().
|
||||||
|
|
||||||
unittest // Error handling in spawnProcess()
|
unittest // Error handling in spawnProcess()
|
||||||
{
|
{
|
||||||
|
import std.exception : assertThrown;
|
||||||
assertThrown!ProcessException(spawnProcess("ewrgiuhrifuheiohnmnvqweoijwf"));
|
assertThrown!ProcessException(spawnProcess("ewrgiuhrifuheiohnmnvqweoijwf"));
|
||||||
assertThrown!ProcessException(spawnProcess("./rgiuhrifuheiohnmnvqweoijwf"));
|
assertThrown!ProcessException(spawnProcess("./rgiuhrifuheiohnmnvqweoijwf"));
|
||||||
}
|
}
|
||||||
|
@ -932,6 +932,7 @@ unittest // Specifying a working directory.
|
||||||
|
|
||||||
unittest // Specifying a bad working directory.
|
unittest // Specifying a bad working directory.
|
||||||
{
|
{
|
||||||
|
import std.exception : assertThrown;
|
||||||
TestScript prog = "echo";
|
TestScript prog = "echo";
|
||||||
|
|
||||||
auto directory = uniqueTempPath();
|
auto directory = uniqueTempPath();
|
||||||
|
@ -1522,6 +1523,7 @@ void kill(Pid pid, int codeOrSignal)
|
||||||
unittest // tryWait() and kill()
|
unittest // tryWait() and kill()
|
||||||
{
|
{
|
||||||
import core.thread;
|
import core.thread;
|
||||||
|
import std.exception : assertThrown;
|
||||||
// The test script goes into an infinite loop.
|
// The test script goes into an infinite loop.
|
||||||
version (Windows)
|
version (Windows)
|
||||||
{
|
{
|
||||||
|
@ -1985,6 +1987,7 @@ unittest
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
import std.exception : assertThrown;
|
||||||
TestScript prog = "exit 0";
|
TestScript prog = "exit 0";
|
||||||
assertThrown!StdioException(pipeProcess(
|
assertThrown!StdioException(pipeProcess(
|
||||||
prog.path,
|
prog.path,
|
||||||
|
@ -2258,6 +2261,7 @@ unittest
|
||||||
/// An exception that signals a problem with starting or waiting for a process.
|
/// An exception that signals a problem with starting or waiting for a process.
|
||||||
class ProcessException : Exception
|
class ProcessException : Exception
|
||||||
{
|
{
|
||||||
|
import std.exception : basicExceptionCtors;
|
||||||
mixin basicExceptionCtors;
|
mixin basicExceptionCtors;
|
||||||
|
|
||||||
// Creates a new ProcessException based on errno.
|
// Creates a new ProcessException based on errno.
|
||||||
|
@ -2607,6 +2611,7 @@ private string escapeWindowsShellCommand(in char[] command) @safe pure
|
||||||
private string escapeShellArguments(in char[][] args...)
|
private string escapeShellArguments(in char[][] args...)
|
||||||
@trusted pure nothrow
|
@trusted pure nothrow
|
||||||
{
|
{
|
||||||
|
import std.exception : assumeUnique;
|
||||||
char[] buf;
|
char[] buf;
|
||||||
|
|
||||||
@safe nothrow
|
@safe nothrow
|
||||||
|
@ -2649,7 +2654,7 @@ string escapeWindowsArgument(in char[] arg) @trusted pure nothrow
|
||||||
// Rationale for leaving this function as public:
|
// Rationale for leaving this function as public:
|
||||||
// this algorithm of escaping paths is also used in other software,
|
// this algorithm of escaping paths is also used in other software,
|
||||||
// e.g. DMD's response files.
|
// e.g. DMD's response files.
|
||||||
|
import std.exception : assumeUnique;
|
||||||
auto buf = escapeWindowsArgumentImpl!charAllocator(arg);
|
auto buf = escapeWindowsArgumentImpl!charAllocator(arg);
|
||||||
return assumeUnique(buf);
|
return assumeUnique(buf);
|
||||||
}
|
}
|
||||||
|
@ -2789,6 +2794,7 @@ version(Windows) version(unittest)
|
||||||
|
|
||||||
private string escapePosixArgument(in char[] arg) @trusted pure nothrow
|
private string escapePosixArgument(in char[] arg) @trusted pure nothrow
|
||||||
{
|
{
|
||||||
|
import std.exception : assumeUnique;
|
||||||
auto buf = escapePosixArgumentImpl!charAllocator(arg);
|
auto buf = escapePosixArgumentImpl!charAllocator(arg);
|
||||||
return assumeUnique(buf);
|
return assumeUnique(buf);
|
||||||
}
|
}
|
||||||
|
@ -2995,6 +3001,7 @@ static:
|
||||||
*/
|
*/
|
||||||
string opIndex(in char[] name) @safe
|
string opIndex(in char[] name) @safe
|
||||||
{
|
{
|
||||||
|
import std.exception : enforce;
|
||||||
string value;
|
string value;
|
||||||
enforce(getImpl(name, value), "Environment variable not found: "~name);
|
enforce(getImpl(name, value), "Environment variable not found: "~name);
|
||||||
return value;
|
return value;
|
||||||
|
@ -3050,6 +3057,7 @@ static:
|
||||||
{
|
{
|
||||||
version (Posix)
|
version (Posix)
|
||||||
{
|
{
|
||||||
|
import std.exception : enforce, errnoEnforce;
|
||||||
if (core.sys.posix.stdlib.setenv(name.tempCString(), value.tempCString(), 1) != -1)
|
if (core.sys.posix.stdlib.setenv(name.tempCString(), value.tempCString(), 1) != -1)
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
|
@ -3064,6 +3072,7 @@ static:
|
||||||
}
|
}
|
||||||
else version (Windows)
|
else version (Windows)
|
||||||
{
|
{
|
||||||
|
import std.exception : enforce;
|
||||||
enforce(
|
enforce(
|
||||||
SetEnvironmentVariableW(name.tempCStringW(), value.tempCStringW()),
|
SetEnvironmentVariableW(name.tempCStringW(), value.tempCStringW()),
|
||||||
sysErrorString(GetLastError())
|
sysErrorString(GetLastError())
|
||||||
|
@ -3125,6 +3134,7 @@ static:
|
||||||
}
|
}
|
||||||
else version (Windows)
|
else version (Windows)
|
||||||
{
|
{
|
||||||
|
import std.exception : enforce;
|
||||||
import std.uni : toUpper;
|
import std.uni : toUpper;
|
||||||
auto envBlock = GetEnvironmentStringsW();
|
auto envBlock = GetEnvironmentStringsW();
|
||||||
enforce(envBlock, "Failed to retrieve environment variables.");
|
enforce(envBlock, "Failed to retrieve environment variables.");
|
||||||
|
@ -3203,6 +3213,7 @@ private:
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
import std.exception : assertThrown;
|
||||||
// New variable
|
// New variable
|
||||||
environment["std_process"] = "foo";
|
environment["std_process"] = "foo";
|
||||||
assert (environment["std_process"] == "foo");
|
assert (environment["std_process"] == "foo");
|
||||||
|
@ -3656,6 +3667,7 @@ string shell(string cmd)
|
||||||
version(Windows)
|
version(Windows)
|
||||||
{
|
{
|
||||||
import std.array : appender;
|
import std.array : appender;
|
||||||
|
import std.exception : errnoEnforce;
|
||||||
// Generate a random filename
|
// Generate a random filename
|
||||||
auto a = appender!string();
|
auto a = appender!string();
|
||||||
foreach (ref e; 0 .. 8)
|
foreach (ref e; 0 .. 8)
|
||||||
|
@ -3691,6 +3703,7 @@ string shell(string cmd)
|
||||||
|
|
||||||
deprecated unittest
|
deprecated unittest
|
||||||
{
|
{
|
||||||
|
import std.exception : assertThrown;
|
||||||
auto x = shell("echo wyda");
|
auto x = shell("echo wyda");
|
||||||
// @@@ This fails on wine
|
// @@@ This fails on wine
|
||||||
//assert(x == "wyda" ~ newline, text(x.length));
|
//assert(x == "wyda" ~ newline, text(x.length));
|
||||||
|
@ -3722,6 +3735,7 @@ else version(Posix)
|
||||||
deprecated("Please use environment.opIndexAssign instead.")
|
deprecated("Please use environment.opIndexAssign instead.")
|
||||||
void setenv(in char[] name, in char[] value, bool overwrite)
|
void setenv(in char[] name, in char[] value, bool overwrite)
|
||||||
{
|
{
|
||||||
|
import std.exception : errnoEnforce;
|
||||||
errnoEnforce(
|
errnoEnforce(
|
||||||
core.sys.posix.stdlib.setenv(name.tempCString(), value.tempCString(), overwrite) == 0);
|
core.sys.posix.stdlib.setenv(name.tempCString(), value.tempCString(), overwrite) == 0);
|
||||||
}
|
}
|
||||||
|
@ -3732,6 +3746,7 @@ else version(Posix)
|
||||||
deprecated("Please use environment.remove instead")
|
deprecated("Please use environment.remove instead")
|
||||||
void unsetenv(in char[] name)
|
void unsetenv(in char[] name)
|
||||||
{
|
{
|
||||||
|
import std.exception : errnoEnforce;
|
||||||
errnoEnforce(core.sys.posix.stdlib.unsetenv(name.tempCString()) == 0);
|
errnoEnforce(core.sys.posix.stdlib.unsetenv(name.tempCString()) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue