Skip to content

Commit

Permalink
Fix sanity checker: don't use the fakeTty when no colored output is
Browse files Browse the repository at this point in the history
needed
  • Loading branch information
wilzbach committed Feb 16, 2018
1 parent 8fc3f3a commit e164434
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ private void doSanityCheck(ContentProvider contentProvider, IExecProvider execPr
section.language, section.title);

IExecProvider.RunInput input = {
source: section.sourceCode
source: section.sourceCode,
color: false,
};
auto result = execProvider.compileAndExecute(input);
enforce(result.success,
Expand Down
25 changes: 15 additions & 10 deletions source/exec/stupidlocal.d
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,24 @@ class StupidLocal: IExecProvider
{
args = [dCompiler];
args ~= input.args.split(" ");
args ~= "-color=" ~ (input.color ? "on " : "off ");
args ~= "-color=" ~ (input.color ? "on" : "off");
args ~= "-run";
args ~= tmpfile.name;

// DMD requires a TTY for colored output
auto env = [
"TERM": "dtour"
];
auto fakeTty = `
faketty () { script -qfc "$(printf "%q " "$@")" /dev/null ; }
faketty ` ~ args.join(" ") ~ ` | cat | sed 's/\r$//'`;

res = fakeTty.executeShell(env);
if (input.color)
{
// DMD requires a TTY for colored output
auto env = [
"TERM": "dtour"
];
auto fakeTty = `
faketty () { script -qfc "$(printf "%q " "$@")" /dev/null ; }
faketty ` ~ args.join(" ") ~ ` | cat | sed 's/\r$//'`;

res = fakeTty.executeShell(env);
} else {
res = execute(args);
}
}
result.success = res.status == 0;
result.output = res.output;
Expand Down

0 comments on commit e164434

Please sign in to comment.