Commit 83b6ac1b authored by Jesse McKenna's avatar Jesse McKenna Committed by Commit Bot

Make autotest.py support forward slash on Windows

Currently, autotest.py doesn't support the forward slash '/' as a path
separator on Windows. For example:

Succeeds:
python3 tools/autotest.py -C out/bug base\at_exit_unittest
--gtest_filter=*Exit*

Fails:
python3 tools/autotest.py -C out/bug base/at_exit_unittest
--gtest_filter=*Exit*

This is because RecursiveMatchFilename() considers a file a match with
the requested filename if the requested filename is a substring of the
file's full path. On Windows, file paths as returned by os.scandir()
use '\\' as a path separator, so a path using '/' will never match
(e.g. 'base/at_exit_unittest' is not a substring of
'C:\\src\\chromium\\src\\base\\at_exit_unittest.cc').

With this change, either type of path separator works on Windows.

Change-Id: Ic21eff291d86e7ca994faeda807f6aeaff737562
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2181744
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#766500}
parent ec9de8eb
...@@ -125,6 +125,12 @@ def RecursiveMatchFilename(folder, filename): ...@@ -125,6 +125,12 @@ def RecursiveMatchFilename(folder, filename):
def FindMatchingTestFile(target): def FindMatchingTestFile(target):
if sys.platform.startswith('win32') and os.path.altsep in target:
# Use backslash as the path separator on Windows to match os.scandir().
if DEBUG:
print('Replacing ' + os.path.altsep + ' with ' + os.path.sep + ' in: '
+ target)
target = target.replace(os.path.altsep, os.path.sep)
if DEBUG: if DEBUG:
print('Finding files with full path containing: ' + target) print('Finding files with full path containing: ' + target)
results = RecursiveMatchFilename(SRC_DIR, target) results = RecursiveMatchFilename(SRC_DIR, target)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment