Skip to content

Commit 93b2e99

Browse files
committed
Fix error message command
1 parent e31ea15 commit 93b2e99

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/ExecuteCommandTest.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,18 @@ class ExecuteCommandTest {
9898
@Test
9999
fun testErrorReturnsStderr() = runTest {
100100
val errorCommand = when (provider.osInfo().family) {
101-
OsFamily.Windows -> "<nul set /p=\"Error message\\r\\n\" 1>&2 & exit /b 13"
101+
OsFamily.Windows -> "echo Error message 1>&2 & exit /b 13"
102102
else -> "echo 'Error message' >&2; exit 13"
103103
}
104104

105+
// Windows command output has an extra space at the end
106+
// Can't wrap it in quotes because Windows just echoes them back
107+
// Can't use `<nul set /p` because that doesn't terminate with CRLF
108+
val expectedOutput = when (provider.osInfo().family) {
109+
OsFamily.Windows -> "Error message "
110+
else -> "Error message"
111+
}
112+
105113
val result = executeCommand(
106114
command = errorCommand,
107115
platformProvider = provider,
@@ -110,6 +118,6 @@ class ExecuteCommandTest {
110118
)
111119

112120
assertEquals(13, result.first)
113-
assertEquals("Error message$platformNewline", result.second)
121+
assertEquals("$expectedOutput$platformNewline", result.second)
114122
}
115123
}

0 commit comments

Comments
 (0)