cli icon indicating copy to clipboard operation
cli copied to clipboard

fix: cross-platform test compatibility

Open theRealThomasDavidson opened this issue 11 months ago • 0 comments

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

theRealThomasDavidson avatar Feb 18 '25 01:02 theRealThomasDavidson