Skip to content

Fix Unix-only expectations in three System.Console manual tests - #134372

Open
caraioniurie47 wants to merge 1 commit into
dotnet:mainfrom
caraioniurie47:issue-133898
Open

caraioniurie47 wants to merge 1 commit into
dotnet:mainfrom
caraioniurie47:issue-133898

Conversation

@caraioniurie47

Copy link
Copy Markdown
Contributor

Three manual tests in System.Console.Manual.Tests fail on Windows even when every prompt is followed (#133898). Each expectation came with a Unix-only fix:

  • ReadFromOpenStandardInput expects \n right after the typed sentence; the Windows console ends the line with \r\n. On Windows it now expects \r first.
  • ConsoleReadSupportsBackspace reads aab\r with Console.Read() and leaves the \n in Console.In, so ReadLine_BackSpaceCanMoveAcrossWrappedLines, which xunit runs next, returns "" before anything is typed. On Windows it now reads aab\r\n.
  • CursorLeftFromLastColumn checks the cached cursor position that only ConsolePal.Unix.cs keeps (Console.Unix: don't calculate cached cursor position from the last column. #78466). It is now [PlatformSpecific(TestPlatforms.AnyUnix)], like EchoWorksDuringAndAfterProcessThatUsesTerminal.

The Unix expectations are unchanged.

Tests

Manual tests don't run in CI. xunit.console was run by hand in a console window, with the test project built from this branch, asked for the four tests, with the trait filters from the generated RunTests.cmd. CursorLeftFromLastColumn was filtered out (3 of 19 test cases found), and the other three passed, ConsoleReadSupportsBackspace running directly before ReadLine_BackSpaceCanMoveAcrossWrappedLines, which now waited for input. Not run on Linux or macOS.

Resolves #133898

Note

AI-generated, written at my direction and reviewed by me before posting. The manual tests ran on Windows 11 x64 (build 26200) in inbox conhost, typed by hand, on the repo's Debug testhost.

Three System.Console manual tests failed on Windows because they expect
Unix behaviour:

- ReadFromOpenStandardInput expected '\n' right after the typed text;
  the Windows console ends the line with "\r\n".
- ConsoleReadSupportsBackspace read "aab\r" and left the '\n' in
  Console.In, so ReadLine_BackSpaceCanMoveAcrossWrappedLines, which
  xunit runs next, returned "" without waiting for input.
- CursorLeftFromLastColumn checks the Unix cached cursor position; on
  Windows the '1' lands on the row after the '2'. It is now
  [PlatformSpecific(TestPlatforms.AnyUnix)].

Fix dotnet#133898

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Sep 21, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-console
See info in area-owners.md if you want to be subscribed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Console community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Three System.Console manual tests fail on Windows because they expect Unix behaviour

1 participant