Skip to content

fix(test): make //tests:path_test work on Windows#1017

Merged
cgrindel merged 1 commit intobazelbuild:mainfrom
rdesgroppes:fix-path-test-windows
Feb 7, 2026
Merged

fix(test): make //tests:path_test work on Windows#1017
cgrindel merged 1 commit intobazelbuild:mainfrom
rdesgroppes:fix-path-test-windows

Conversation

@rdesgroppes
Copy link
Contributor

The test was failing on Windows:

FAIL: testDestPathExt (__main__.DestPathTest.testDestPathExt)
AssertionError: '/bar/baz' != 'external/repo\\foo/bar/baz'

FAIL: testDestPathExtWrong (__main__.DestPathTest.testDestPathExtWrong)
AssertionError: 'external/repo/foo/bar/baz' != 'external/repo\\foo/bar/baz'

FAIL: testSafeShortPathExt (__main__.SafeShortPathTest.testSafeShortPathExt)
AssertionError: 'external/repo/foo/bar/baz' != 'external/repo\\foo/bar/baz'

FAIL: testSafeShortPathGenExt (__main__.SafeShortPathTest.testSafeShortPathGenExt)
AssertionError: 'external/repo/foo/bar/baz' != 'external/repo\\foo/bar/baz'

FAIL: testShortPathDirnameExt (__main__.ShortPathDirnameTest.testShortPathDirnameExt)
AssertionError: 'external/repo/foo/bar' != 'external/repo\\foo/bar'

FAIL: testShortPathDirnameGenExt (__main__.ShortPathDirnameTest.testShortPathDirnameGenExt)
AssertionError: 'external/repo/foo/bar' != 'external/repo\\foo/bar'

FAIL: testTopLevelExt (__main__.ShortPathDirnameTest.testTopLevelExt)
AssertionError: 'external/repo' != 'external'

The mock File class used os.path.join() which produces platform-specific path separators (backslashes on Windows), which doesn't match Bazel's behavior which always uses forward slashes regardless of platform:

  • use posixpath.join() instead,
  • enable the test in Windows CI since it now passes.

@rdesgroppes rdesgroppes force-pushed the fix-path-test-windows branch from 3f2ffbd to 1609a80 Compare February 6, 2026 18:55
The test was failing on Windows:
```
FAIL: testDestPathExt (__main__.DestPathTest.testDestPathExt)
AssertionError: '/bar/baz' != 'external/repo\\foo/bar/baz'

FAIL: testDestPathExtWrong (__main__.DestPathTest.testDestPathExtWrong)
AssertionError: 'external/repo/foo/bar/baz' != 'external/repo\\foo/bar/baz'

FAIL: testSafeShortPathExt (__main__.SafeShortPathTest.testSafeShortPathExt)
AssertionError: 'external/repo/foo/bar/baz' != 'external/repo\\foo/bar/baz'

FAIL: testSafeShortPathGenExt (__main__.SafeShortPathTest.testSafeShortPathGenExt)
AssertionError: 'external/repo/foo/bar/baz' != 'external/repo\\foo/bar/baz'

FAIL: testShortPathDirnameExt (__main__.ShortPathDirnameTest.testShortPathDirnameExt)
AssertionError: 'external/repo/foo/bar' != 'external/repo\\foo/bar'

FAIL: testShortPathDirnameGenExt (__main__.ShortPathDirnameTest.testShortPathDirnameGenExt)
AssertionError: 'external/repo/foo/bar' != 'external/repo\\foo/bar'

FAIL: testTopLevelExt (__main__.ShortPathDirnameTest.testTopLevelExt)
AssertionError: 'external/repo' != 'external'
```

The mock `File` class used `os.path.join()` which produces
platform-specific path separators (backslashes on Windows), which
doesn't match Bazel's behavior which always uses forward slashes
regardless of platform:
- use `posixpath.join()` instead,
- enable the test in Windows CI since it now passes.
@rdesgroppes rdesgroppes force-pushed the fix-path-test-windows branch from 1609a80 to 2c320e9 Compare February 6, 2026 18:57
@rdesgroppes rdesgroppes marked this pull request as ready for review February 6, 2026 19:00
Copy link
Collaborator

@cgrindel cgrindel left a comment

Choose a reason for hiding this comment

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

Thank you!

@cgrindel cgrindel merged commit d11b728 into bazelbuild:main Feb 7, 2026
6 checks passed
@rdesgroppes rdesgroppes deleted the fix-path-test-windows branch February 7, 2026 15:33
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.

2 participants