fix(test): make //tests/mappings/filter_directory work on Windows#1020
Merged
aiuto merged 1 commit intobazelbuild:mainfrom Feb 10, 2026
Merged
Conversation
The `filter_directory` tests were failing on Windows:
```
ERROR: test_directory_structure_matches_global (__main__.DirectoryStructureTest.test_directory_structure_matches_global)
[...]
os.path.isdir(real_directory_root),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[...]
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
```
This was because `Rlocation()` expects POSIX-style paths (forward
slashes), but `os.path.join()` produces backslashes on Windows.
After fixing it, a second error appeared:
```
FAIL: test_directory_structure_matches_global (__main__.DirectoryStructureTest.test_directory_structure_matches_global)
AssertionError: Items in the first set but not the second:
'extra/a'
'extra/subdir/c'
'extra/b'
'extra/subdir/d'
Items in the second set but not the first:
'extra\\subdir\\c'
'extra\\a'
'extra\\b'
'extra\\subdir\\d' : Directory structure mismatch
```
This was because paths collected via `os.walk()` also produce
backslashes on Windows against expected paths returned by `Rlocation`
that always use forward slashes.
The change consists in leveraging `pathlib` for that purpose:
`Path().as_posix()`, `Path.rglob()` and `Path.relative_to()`.
This enables the 9 `filter_directory` tests in Windows CI.
aiuto
approved these changes
Feb 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
filter_directorytests were failing on Windows:This was because
Rlocation()expects POSIX-style paths (forward slashes), butos.path.join()produces backslashes on Windows.After fixing it, a second error appeared:
This was because paths collected via
os.walk()also produce backslashes on Windows against expected paths returned byRlocationthat always use forward slashes.The change consists in leveraging
pathlibfor that purpose:Path().as_posix(),Path.rglob()andPath.relative_to().This enables the 9
filter_directorytests in Windows CI.