Skip to content

Commit 2c320e9

Browse files
committed
fix(test): make //tests:path_test work on Windows
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.
1 parent a9358d5 commit 2c320e9

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

.bazelci/tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ win_tests: &win_tests
4848
- "//tests/..."
4949
- "//toolchains/..."
5050
- "-//tests:package_naming_aggregate_test"
51-
- "-//tests:path_test"
5251
# Bazel might be broken w.r.t. Unicode processing for windows. Multiple issues:
5352
# https://github.com/bazelbuild/bazel/issues?q=is%3Aissue+is%3Aopen+%2Bunicode+%2Bwindows+
5453
- "-//tests/mappings:utf8_manifest_test"

tests/path_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import collections
1717
import imp
18-
import os
18+
import posixpath
1919
import unittest
2020

2121

@@ -37,7 +37,7 @@ def __init__(self, short_path, is_generated=False, is_external=False):
3737
else:
3838
self.owner = Owner('', '')
3939
self.short_path = short_path
40-
self.path = os.path.join(
40+
self.path = posixpath.join(
4141
self.root.path, self.owner.workspace_root, short_path)
4242

4343

0 commit comments

Comments
 (0)