Skip to content

fix windows test failures: path separators and arch normalization - #1148

Merged
crazywhalecc merged 2 commits into
crazywhalecc:v3from
luthermonson:v3-fix-windows-test-paths
May 21, 2026
Merged

crazywhalecc merged 2 commits into
crazywhalecc:v3from
luthermonson:v3-fix-windows-test-paths

Conversation

@luthermonson

Copy link
Copy Markdown
Contributor

What does this PR do?

Running phpunit on Windows surfaces 12 problems (3 errors + 9 failures) that all pass on Linux CI. Reproducer: runtime\php.exe vendor\phpunit\phpunit\phpunit tests\ --no-coverage

Before the changes: Tests: 399, Assertions: 601, Errors: 3, Failures: 9, Warnings: 7, Deprecations: 4.

Three buckets of failures, all in tests/StaticPHP/Artifact/:

  • Invalid platform architecture 'AMD64' errors php_uname('m') returns uppercase AMD64 on Windows, and the test helper getCurrentPlatform() only normalized macOS's arm64. Affected: testHasPlatformBinaryReturnsTrueWithCustomCallback, testSetAndGetCustomBinaryCallback, testSetAndGetCustomBinaryCheckUpdateCallback, plus four
    downstream test failures that depend on the same helper (testHasPlatformBinaryReturnsTrueWhenConfigHasBinaryForCurrentPlatform,
    testSetAndGetBinaryExtractCallbackForCurrentPlatform, testGetBinaryExtractCallbackReturnsNullForNonMatchingPlatform,
    testShouldUseBinaryReturnsTrueWhenDownloadedAndHasBinaryConfig).
  • Mixed path separator — ArtifactCache::getCacheFullPath() produced \...\downloads/file.ext instead of \...\downloads\file.ext. Same shape in Artifact::getSourceRoot(). Affected: testGetCacheFullPathForArchiveType, testGetCacheFullPathForGitType, testGetCacheFullPathForFileType, testGetSourceRootUsesMetadataSourceRoot.
  • testGetSourceDirWithAbsoluteExtractInConfig — used a Unix-style /tmp/... as "absolute," but on Windows that has no drive letter so isRelativePath() returns true and the test landed in the wrong code branch.

After these changes we wrap path concatenations in the existing FileSystem::convertPath(), and the test helper uses the existing arch2gnu() (which already lowercases input and maps amd64/x64/x86_64 -> x86_64) instead of the hand-rolled partial fixup. Linux/macOS behavior is unchanged because the separator wraps are no-ops where slashes already match, the test's arch helper is now using what the rest of the codebase already uses everywhere, and the absolute-path test now picks a Windows-realistic absolute path on Windows only.

After the changes: Tests: 399, Assertions: 604, Failures: 0, Warnings: 7, Deprecations: 4.

@luthermonson
luthermonson force-pushed the v3-fix-windows-test-paths branch from 2a106b8 to 52d234f Compare May 20, 2026 04:59

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 fixes Windows-only PHPUnit failures in the artifact/cache path and platform-detection logic by normalizing architecture strings and ensuring generated filesystem paths use the correct platform separator.

Changes:

  • Update ArtifactTest platform helper to use the project’s arch2gnu() normalization (fixes AMD64 vs x86_64 mismatches on Windows).
  • Normalize generated download/cache paths via FileSystem::convertPath() to avoid mixed \.../file separators on Windows.
  • Adjust one test to use a truly-absolute path on Windows (drive-letter path) to match isRelativePath() behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/StaticPHP/Artifact/ArtifactTest.php Makes tests platform-aware for absolute paths on Windows and normalizes arch detection via arch2gnu().
src/StaticPHP/Artifact/ArtifactCache.php Ensures cache full paths are normalized via FileSystem::convertPath() for archive/file/git cache types.
src/StaticPHP/Artifact/Artifact.php Normalizes getSourceRoot() path concatenation via FileSystem::convertPath() to avoid mixed separators.

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

@crazywhalecc
crazywhalecc merged commit 01a4d87 into crazywhalecc:v3 May 21, 2026
7 checks passed
@luthermonson
luthermonson deleted the v3-fix-windows-test-paths branch May 21, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants