-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[win][test] Make PathSanitizingFileCheck more aware of Windows. #24940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,9 +60,11 @@ constants.""") | |
|
||
if args.enable_windows_compatibility: | ||
if args.enable_yaml_compatibility: | ||
slashes_re = r'(/|\\\\|\\\\\\\\)' | ||
slashes_re = r'(/|\\\\\\\\|\\\\)' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At first I was trying to use the same regular expression for both cases, Having the 2 escaped slashes before the 4 escaped slashes was creating duplicated |
||
undo_slashes_re = re.compile(r'\\\\|\\') | ||
else: | ||
slashes_re = r'(/|\\\\)' | ||
undo_slashes_re = re.compile(r'\\') | ||
else: | ||
slashes_re = r'/' | ||
|
||
|
@@ -72,7 +74,18 @@ constants.""") | |
# We are replacing the Unix path separators in the paths passed as | ||
# arguments with a broader pattern to also allow forward slashes and | ||
# double escaped slashes in the result that we are checking. Sigh. | ||
stdin = re.sub(re.sub(r'/', slashes_re, pattern), replacement, stdin) | ||
pattern = re.sub(r'/', slashes_re, pattern) | ||
stdin = re.sub(pattern, replacement, stdin) | ||
|
||
if args.enable_windows_compatibility: | ||
# For making easier to write the tests, we also look in the | ||
# possible subpath attached to the replacement. | ||
extended_replacement = replacement + r'[^\s\'"]+' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to deal with the quoting now when we didn't previously? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are not doing something that we weren't doing before. Before, the only thing that we were doing was matching the path found in the result and transforming it into the tokens This new piece of code does something similar, but not the same: it looks for things that starts with In summary: first replacement replaces |
||
|
||
def replace_slashes(matchobj): | ||
return re.sub(undo_slashes_re, r'/', matchobj.group(0)) | ||
|
||
stdin = re.sub(extended_replacement, replace_slashes, stdin) | ||
|
||
p = subprocess.Popen( | ||
[args.file_check_path] + unknown_args, stdin=subprocess.PIPE) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the split here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is two different things: the path
SOURCE_DIR/test/Driver/Inputs/bridging-header.h
with a possible end quote, and some other path that finishes in-emit-pch
. It might not be a necessary change, but it makes it clear that there's two "atoms" to check for. The other way it looks like it is part of the same thing.