From 0218b2017a454d1c7ace8ea22c81dd16763d5548 Mon Sep 17 00:00:00 2001 From: Iurie Caraion Date: Mon, 21 Sep 2026 23:16:09 +0300 Subject: [PATCH] Fix Unix-only expectations in Console manual tests 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 #133898 Co-Authored-By: Claude Opus 5 --- .../System.Console/tests/ManualTests/ManualTests.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Console/tests/ManualTests/ManualTests.cs b/src/libraries/System.Console/tests/ManualTests/ManualTests.cs index 0471be86c002a7..c5090a85847c52 100644 --- a/src/libraries/System.Console/tests/ManualTests/ManualTests.cs +++ b/src/libraries/System.Console/tests/ManualTests/ManualTests.cs @@ -59,6 +59,10 @@ public static void ReadFromOpenStandardInput() { Assert.Equal((byte)expectedLine[i], inputStream.ReadByte()); } + if (OperatingSystem.IsWindows()) + { + Assert.Equal((byte)'\r', inputStream.ReadByte()); + } Assert.Equal((byte)'\n', inputStream.ReadByte()); AssertUserExpectedResults("the characters you typed properly echoed as you typed"); } @@ -66,7 +70,7 @@ public static void ReadFromOpenStandardInput() [ConditionalFact(typeof(ConsoleManualTests), nameof(ManualTestsEnabled))] public static void ConsoleReadSupportsBackspace() { - const string expectedLine = "aab\r"; + string expectedLine = OperatingSystem.IsWindows() ? "aab\r\n" : "aab\r"; Console.WriteLine($"Please type 'a' 3 times, press 'Backspace' to erase 1, then type a single 'b' and press 'Enter'."); foreach (char c in expectedLine) @@ -322,6 +326,7 @@ public static void EncodingTest() } [ConditionalFact(typeof(ConsoleManualTests), nameof(ManualTestsEnabled))] + [PlatformSpecific(TestPlatforms.AnyUnix)] // Tests the Unix cached cursor position. public static void CursorLeftFromLastColumn() { Console.CursorLeft = Console.BufferWidth - 1;