Skip to content

Commit 46c6709

Browse files
yotsudaclaude
andcommitted
fix(test): make CwdDrift revert-hint assertion platform-agnostic
InvokeExpression_CwdDriftNotice_EscapesSingleQuotesInRevertHint asserted the literal substring "Set-Location -LiteralPath ''C:" in the bail response. That worked on Windows where Path.GetTempPath() returns a C:\... path, but on Linux (/tmp/...) and macOS (/var/folders/...) the "C:" prefix never appeared, so the test was failing in CI on both non-Windows runners while staying green locally. The intent of the assertion is to confirm the apostrophe-doubling escape (' -> '') gets applied to the AI''s intended cwd before it reaches the AI as part of a single-quoted PowerShell literal. Build the expected substring from aiCwd itself (with the same Replace applied) so the test exercises the escape contract on every platform without baking in a path prefix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b76e9e2 commit 46c6709

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Tests/Unit/Proxy/PowerShellToolsTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,9 +1189,14 @@ public async Task InvokeExpression_CwdDriftNotice_EscapesSingleQuotesInRevertHin
11891189
"Get-Date",
11901190
agent_id: TestAgentId);
11911191

1192-
// Assert: apostrophe doubled inside the literal-path argument
1192+
// Assert: apostrophe doubled inside the literal-path argument.
1193+
// Build the expected substring from aiCwd itself so the test passes on every
1194+
// platform — Path.GetTempPath() returns /tmp/... on Linux and /var/folders/...
1195+
// on macOS, neither of which starts with "C:". The escape rule (' -> '') is
1196+
// what we actually want to lock in.
1197+
var expectedRevertHint = $"Set-Location -LiteralPath '{aiCwd.Replace("'", "''")}'";
11931198
Assert.Contains("Pipeline NOT executed", result);
1194-
Assert.Contains("Set-Location -LiteralPath 'C:", result);
1199+
Assert.Contains(expectedRevertHint, result);
11951200
Assert.Contains("o''brien", result);
11961201

11971202
// Cleanup

0 commit comments

Comments
 (0)