Skip to content

fix(tests): canonicalize hook CWD paths - #674

Closed
carlospedreira wants to merge 1 commit into
mainfrom
codex/fix-cwd-path-tests
Closed

fix(tests): canonicalize hook CWD paths#674
carlospedreira wants to merge 1 commit into
mainfrom
codex/fix-cwd-path-tests

Conversation

@carlospedreira

Copy link
Copy Markdown
Collaborator

Closes #672

Canonicalizes verify-hook working-directory comparisons before asserting equality.

  • resolves macOS /var and /private/var aliases through the physical filesystem path
  • expands Windows 8.3 short-path aliases with GetLongPathName
  • preserves the five-hook count and consistent-directory assertions

Validation:

  • Test-Hooks.ps1: 71 passed
  • Full Layers 1-3: all passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the hook/CWD assertions in tests/Test-Hooks.ps1 to compare canonicalized filesystem locations rather than raw path strings, avoiding platform-specific alias mismatches (notably macOS /var vs /private/var and Windows short/long path forms).

Changes:

  • Added Resolve-Issue628CanonicalPath to canonicalize paths via Resolve-Path, Windows GetLongPathName, and POSIX pwd -P.
  • Updated Assert-VerifyCwdMarker to compare canonical expected/actual CWD values and to enforce “all five markers resolve to one directory” using canonicalized values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Test-Hooks.ps1
Comment on lines +454 to +472
if ($IsWindows) {
if (-not ('DotbotTestNativePath' -as [type])) {
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
using System.Text;

public static class DotbotTestNativePath
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern uint GetLongPathName(string shortPath, StringBuilder longPath, uint bufferLength);
}
'@
}
$buffer = [System.Text.StringBuilder]::new(32768)
$length = [DotbotTestNativePath]::GetLongPathName($resolved, $buffer, [uint32]$buffer.Capacity)
if ($length -gt 0 -and $length -lt $buffer.Capacity) {
$resolved = $buffer.ToString()
}
Comment thread tests/Test-Hooks.ps1
Comment on lines +499 to +503
$canonicalLines = @($lines | ForEach-Object { Resolve-Issue628CanonicalPath -Path ([string]$_).Trim() })
Assert-Equal -Name "$Name`: verify chain cwd" -Expected $canonicalExpected -Actual ($canonicalLines | Select-Object -First 1) `
-Message "Expected every stub to run in '$ExpectedDir' ('$canonicalExpected' canonical), got: $($lines -join ', ')"
Assert-True -Name "$Name`: cwd consistent across the whole chain" `
-Condition (@($lines | Select-Object -Unique).Count -eq 1)
-Condition (@($canonicalLines | Select-Object -Unique).Count -eq 1)
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Dotbot Product Backlog Aug 2, 2026
@carlospedreira
carlospedreira deleted the codex/fix-cwd-path-tests branch August 2, 2026 23:08
carlospedreira pushed a commit that referenced this pull request Aug 2, 2026
Closes #657. Follow-up hardening is tracked in #670. Includes the canonical path regression fix formerly proposed in #674.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

tests: canonicalize verify-hook CWD comparisons on macOS

2 participants