std.process: Skip permission test when running as root

A spawnProcess unittest checks that we are unable to enter a directory
if we don't have the right permissions.  However, programs running
under the root user can chdir to a directory, despite it not having
execute permissions.

Thus, skip this test when running as root.
This commit is contained in:
Alexandru Jercaianu 2017-10-30 18:06:48 +03:00
parent 2882ff113f
commit d777855000

View file

@ -1187,6 +1187,8 @@ version (Posix) @system unittest
// can't run in directory if user does not have search permission on this directory
version(Posix)
{
if (core.sys.posix.unistd.getuid() != 0)
{
import core.sys.posix.sys.stat : S_IRUSR;
auto directoryNoSearch = uniqueTempPath();
@ -1196,6 +1198,7 @@ version (Posix) @system unittest
assertThrown!ProcessException(spawnProcess(prog.path, null, Config.none, directoryNoSearch));
assertThrown!ProcessException(spawnProcess(prog.path, null, Config.detached, directoryNoSearch));
}
}
}
@system unittest // Specifying empty working directory.