fix(headless): S6 thread standardOutputIsTerminal instead of reading Console inside HeadlessProcessHost
HeadlessProcessHost read System.Console.IsOutputRedirected directly to pick the console renderer's color mode, which only Program.cs (the executable's own entry point) should ever touch -- the same reasoning that already put the stdin probe there. Resolve standardOutputIsTerminal next to the existing !Console.IsInputRedirected probe in Program.cs and thread it through HeadlessEntryPoint.Run into HeadlessProcessHost's constructor as a plain parameter. StandardOutputIsTerminalParameterControlsColorNotTheRealConsole was shown to fail with the parameter still unused (useColor still reading the real Console.IsOutputRedirected, which the test host always redirects): the standardOutputIsTerminal:true case expected dimmed lifecycle output but got none, since the real console read forced useColor=false regardless of what the test passed in. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
3328b2f2b3
commit
2ff1e1228c
4 changed files with 72 additions and 5 deletions
|
|
@ -47,7 +47,8 @@ internal static class HeadlessEntryPoint
|
|||
TextWriter output,
|
||||
TextWriter error,
|
||||
CancellationToken cancellationToken,
|
||||
bool standardInputIsTerminal = false)
|
||||
bool standardInputIsTerminal = false,
|
||||
bool standardOutputIsTerminal = false)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(arguments);
|
||||
ArgumentNullException.ThrowIfNull(standardInput);
|
||||
|
|
@ -85,7 +86,8 @@ internal static class HeadlessEntryPoint
|
|||
output,
|
||||
directCredentials:
|
||||
commandLine.DirectCredentials,
|
||||
consoleEnabled: consoleEnabled);
|
||||
consoleEnabled: consoleEnabled,
|
||||
standardOutputIsTerminal: standardOutputIsTerminal);
|
||||
return (int)host.RunAsync(cancellationToken)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ internal sealed class HeadlessProcessHost : IDisposable
|
|||
TimeProvider? timeProvider = null,
|
||||
IHeadlessProcessContentFactory? contentFactory = null,
|
||||
HeadlessDirectCredentials? directCredentials = null,
|
||||
bool consoleEnabled = false)
|
||||
bool consoleEnabled = false,
|
||||
bool standardOutputIsTerminal = false)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(configuration);
|
||||
ArgumentNullException.ThrowIfNull(paths);
|
||||
|
|
@ -163,7 +164,7 @@ internal sealed class HeadlessProcessHost : IDisposable
|
|||
HeadlessSessionHost session = _sessions[0];
|
||||
var renderer = new HeadlessConsoleRenderer(
|
||||
diagnostics,
|
||||
useColor: !System.Console.IsOutputRedirected);
|
||||
useColor: standardOutputIsTerminal);
|
||||
consoleRendererSubscription =
|
||||
session.Runtime.Subscribe(renderer);
|
||||
HeadlessConsoleController controller = new(
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ try
|
|||
Console.Out,
|
||||
Console.Error,
|
||||
cancellation.Token,
|
||||
standardInputIsTerminal: !Console.IsInputRedirected);
|
||||
standardInputIsTerminal: !Console.IsInputRedirected,
|
||||
standardOutputIsTerminal: !Console.IsOutputRedirected);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue