diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-04-19 13:51:02 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-04-19 19:27:41 +0200 |
commit | e19c6389966216af5925d2917a206cedc40540e8 (patch) | |
tree | 4b26ca122518e979bddb2ba0db66a46d5718379a /libphobos/src | |
parent | 6eae7549b8a350b92435be904efed195bd190bae (diff) | |
download | gcc-e19c6389966216af5925d2917a206cedc40540e8.zip gcc-e19c6389966216af5925d2917a206cedc40540e8.tar.gz gcc-e19c6389966216af5925d2917a206cedc40540e8.tar.bz2 |
libphobos: Merge upstream druntime 89f870b7, phobos e6907ff3e
Phobos changes:
- Synchronize C bindings with the latest port fixes in upstream
druntime.
- Add Config.stderrPassThrough to std.process (PR98494).
Reviewed-on: https://github.com/dlang/druntime/pull/3448
https://github.com/dlang/phobos/pull/7984
libphobos/ChangeLog:
PR d/98494
* libdruntime/MERGE: Merge upstream druntime 89f870b7.
* src/MERGE: Merge upstream phobos e6907ff3e.
Diffstat (limited to 'libphobos/src')
-rw-r--r-- | libphobos/src/MERGE | 2 | ||||
-rw-r--r-- | libphobos/src/std/process.d | 51 |
2 files changed, 48 insertions, 5 deletions
diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index 4f6a168..6f97404 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -f89dc217a680fa1a83f2999fea04b7c562f705ee +e6907ff3e28d3c43469c46df4a0426726ecb8631 The first line of this file holds the git revision number of the last merge done from the dlang/phobos repository. diff --git a/libphobos/src/std/process.d b/libphobos/src/std/process.d index b0310a8..9cbeca8e 100644 --- a/libphobos/src/std/process.d +++ b/libphobos/src/std/process.d @@ -1358,7 +1358,8 @@ version (Windows) /** -Flags that control the behaviour of $(LREF spawnProcess) and +Flags that control the behaviour of process creation functions in this +module. Most flags only apply to $(LREF spawnProcess) and $(LREF spawnShell). Use bitwise OR to combine flags. @@ -1433,6 +1434,21 @@ enum Config Calling $(LREF wait) or $(LREF kill) with the resulting $(D Pid) is invalid. */ detached = 64, + + /** + By default, the $(LREF execute) and $(LREF executeShell) functions + will capture child processes' both stdout and stderr. This can be + undesirable if the standard output is to be processed or otherwise + used by the invoking program, as `execute`'s result would then + contain a mix of output and warning/error messages. + + Specify this flag when calling `execute` or `executeShell` to + cause invoked processes' stderr stream to be sent to $(REF stderr, + std,stdio), and only capture and return standard output. + + This flag has no effect on $(LREF spawnProcess) or $(LREF spawnShell). + */ + stderrPassThrough = 128, } @@ -2487,7 +2503,11 @@ private auto executeImpl(alias pipeFunc, Cmd, ExtraPipeFuncArgs...)( import std.array : appender; import std.typecons : Tuple; - auto p = pipeFunc(commandLine, Redirect.stdout | Redirect.stderrToStdout, + auto redirect = (config & Config.stderrPassThrough) + ? Redirect.stdout + : Redirect.stdout | Redirect.stderrToStdout; + + auto p = pipeFunc(commandLine, redirect, env, config, workDir, extraArgs); auto a = appender!(ubyte[])(); @@ -2551,6 +2571,30 @@ private auto executeImpl(alias pipeFunc, Cmd, ExtraPipeFuncArgs...)( assert(r3.output.empty); } +@system unittest +{ + // Temporarily disable output to stderr so as to not spam the build log. + import std.stdio : stderr; + import std.typecons : Tuple; + import std.file : readText; + import std.traits : ReturnType; + + ReturnType!executeShell r; + auto tmpname = uniqueTempPath; + auto t = stderr; + // Open a new scope to minimize code ran with stderr redirected. + { + stderr.open(tmpname, "w"); + scope(exit) stderr = t; + r = executeShell("echo D rox>&2", null, Config.stderrPassThrough); + } + assert(r.status == 0); + assert(r.output.empty); + auto witness = readText(tmpname); + import std.ascii : newline; + assert(witness == "D rox" ~ newline, "'" ~ witness ~ "'"); +} + @safe unittest { import std.typecons : Tuple; @@ -2750,8 +2794,7 @@ private struct TestScript string path; } -version (unittest) -private string uniqueTempPath() @safe +package(std) string uniqueTempPath() @safe { import std.file : tempDir; import std.path : buildPath; |