Skip to content

fix: cross-platform test compatibility #3157

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

theRealThomasDavidson
Copy link

@theRealThomasDavidson theRealThomasDavidson commented Feb 18, 2025

This PR fixes various cross-platform compatibility issues in tests, particularly between Windows and Unix-like systems.

Changes Made:

  1. Path Separator Handling:
  • Added filepath.ToSlash() for error message comparison and import map paths in deploy_test.go
  • Added filepath.ToSlash() conversion for URL paths in storage operations
  • Normalized path comparisons using filepath.ToSlash() for cross-platform compatibility in deno_test.go
  1. Line Ending Normalization:
  • Added comprehensive string normalization for form comparisons in upload_test.go:
    • Path separator normalization
    • Line ending normalization (\r\n -> \n)
    • Consecutive newline normalization
    • Backslash escaping normalization
  • Added line ending normalization for diff comparisons in squash_test.go
  • Added normalizeLineEndings() helper function in auth_test.go and token_test.go
  1. Test Data Handling:
  • Replaced testImports with in-memory filesystem setup using afero.NewMemMapFs()
  • Added proper path handling for test file creation

Testing:

  • Verified tests pass on both Windows and Unix systems
  • Ensured URL paths consistently use forward slashes
  • Confirmed line ending normalization works across platforms

Related Issue:

Fixes #3158

Improve test reliability across Windows and Unix systems:

* Add path separator normalization (filepath.ToSlash/FromSlash)

* Normalize line endings (\\r\\n -> \\n) in test comparisons

* Fix URL path handling in storage operations

* Replace testImports with in-memory filesystem

* Add helper functions for consistent line ending handling
@theRealThomasDavidson theRealThomasDavidson requested a review from a team as a code owner February 18, 2025 01:23
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

improve cross-platform test compatibility
1 participant