Skip to content

Commit

Permalink
test/dshell: Expose 'stderr' for run/tryRun
Browse files Browse the repository at this point in the history
The compiler actually outputs on 'stderr' messages coming from 'pragma(msg)' so we should expose it.
  • Loading branch information
Geod24 committed Apr 14, 2020
1 parent 67b11e0 commit 4157298
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion test/dshell/test_shared.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main()
}

run("$DMD -m$MODEL -of$OUTPUT_BASE/a$EXE -defaultlib=libphobos2.so $EXTRA_FILES/test_shared.d");
run("$OUTPUT_BASE/a$EXE", stdout, [
run("$OUTPUT_BASE/a$EXE", stdout, stderr, [
"LD_LIBRARY_PATH" : "../../phobos/generated/"~OS~'/'~BUILD~'/'~MODEL
]);

Expand Down
15 changes: 9 additions & 6 deletions test/tools/dshell_prebuilt/dshell_prebuilt.d
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ void mkdirFor(string filename)
Run the given command. The `tryRun` variants return the exit code, whereas the `run` variants
will assert on a non-zero exit code.
*/
auto tryRun(scope const(char[])[] args, File stdout = std.stdio.stdout, string[string] env = null)
auto tryRun(scope const(char[])[] args, File stdout = std.stdio.stdout,
File stderr = std.stdio.stderr, string[string] env = null)
{
std.stdio.stdout.write("[RUN]");
if (env)
Expand All @@ -168,26 +169,28 @@ auto tryRun(scope const(char[])[] args, File stdout = std.stdio.stdout, string[s
}
std.stdio.stdout.writeln();
std.stdio.stdout.flush();
auto proc = spawnProcess(args, stdin, stdout, std.stdio.stderr, env);
auto proc = spawnProcess(args, stdin, stdout, stderr, env);
return wait(proc);
}
/// ditto
void run(scope const(char[])[] args, File stdout = std.stdio.stdout, string[string] env = null)
void run(scope const(char[])[] args, File stdout = std.stdio.stdout,
File stderr = std.stdio.stderr, string[string] env = null)
{
const exitCode = tryRun(args, stdout, env);
const exitCode = tryRun(args, stdout, stderr, env);
if (exitCode != 0)
{
writefln("Error: last command exited with code %s", exitCode);
assert(0, "last command failed");
}
}
/// ditto
void run(string cmd, File stdout = std.stdio.stdout, string[string] env = null)
void run(string cmd, File stdout = std.stdio.stdout,
File stderr = std.stdio.stderr, string[string] env = null)
{
// TODO: option to disable this?
if (SEP != "/")
cmd = cmd.replace("/", SEP);
run(parseCommand(cmd), stdout, env);
run(parseCommand(cmd), stdout, stderr, env);
}

/**
Expand Down

0 comments on commit 4157298

Please sign in to comment.