Removed global std.exception import from std.process

This commit is contained in:
Jack Stouffer 2016-07-03 16:17:06 -04:00
parent 703566e28e
commit fd1afb27b2

View file

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