[PATCH] D99938: [lit] Always quote arguments containing '[' on windows
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 14 02:57:31 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG37935405efbe: [lit] Always quote arguments containing '[' on windows (authored by mstorsjo).
Changed prior to commit:
https://reviews.llvm.org/D99938?vs=335464&id=337384#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99938/new/
https://reviews.llvm.org/D99938
Files:
llvm/test/Other/lit-quoting.txt
llvm/utils/lit/lit/TestRunner.py
Index: llvm/utils/lit/lit/TestRunner.py
===================================================================
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -191,7 +191,13 @@
We use the same algorithm from MSDN as CPython
(http://msdn.microsoft.com/en-us/library/17w5ykft.aspx), but we treat more
- characters as needing quoting, such as double quotes themselves.
+ characters as needing quoting, such as double quotes themselves, and square
+ brackets.
+
+ For MSys based tools, this is very brittle though, because quoting an
+ argument makes the MSys based tool unescape backslashes where it shouldn't
+ (e.g. "a\b\\c\\\\d" becomes "a\b\c\\d" where it should stay as it was,
+ according to regular win32 command line parsing rules).
"""
result = []
needquote = False
@@ -203,7 +209,7 @@
result.append(' ')
# This logic differs from upstream list2cmdline.
- needquote = (" " in arg) or ("\t" in arg) or ("\"" in arg) or not arg
+ needquote = (" " in arg) or ("\t" in arg) or ("\"" in arg) or ("[" in arg) or not arg
if needquote:
result.append('"')
Index: llvm/test/Other/lit-quoting.txt
===================================================================
--- llvm/test/Other/lit-quoting.txt
+++ llvm/test/Other/lit-quoting.txt
@@ -1,2 +1,20 @@
-RUN: echo "\"" | FileCheck %s
-CHECK: {{^"$}}
+RUN: echo "\"" | FileCheck %s --check-prefix=CHECK1
+RUN: echo '"' | FileCheck %s --check-prefix=CHECK1
+RUN: echo 'a[b\c' | FileCheck %s --check-prefix=CHECK2
+RUN: echo "a[b\\c" | FileCheck %s --check-prefix=CHECK2
+RUN: echo 'a\b\\c\\\\d' | FileCheck %s --check-prefix=CHECK3
+RUN: echo "a\\b\\\\c\\\\\\\\d" | FileCheck %s --check-prefix=CHECK3
+RUN: not not echo "\"" | FileCheck %s --check-prefix=CHECK1
+RUN: not not echo '"' | FileCheck %s --check-prefix=CHECK1
+RUN: not not echo 'a[b\c' | FileCheck %s --check-prefix=CHECK2
+RUN: not not echo "a[b\\c" | FileCheck %s --check-prefix=CHECK2
+RUN: not not echo 'a\b\\c\\\\d' | FileCheck %s --check-prefix=CHECK3
+RUN: not not echo "a\\b\\\\c\\\\\\\\d" | FileCheck %s --check-prefix=CHECK3
+CHECK1: {{^"$}}
+CHECK2: {{^a\[b\\c$}}
+CHECK3: {{^a\\b\\\\c\\\\\\\\d$}}
+
+On Windows, with MSYS based tools, the following commands fail though:
+RUNX: echo 'a[b\c\\d' | FileCheck %s --check-prefix=CHECK4
+RUNX: echo "a[b\\c\\\\d" | FileCheck %s --check-prefix=CHECK4
+CHECK4: {{^a\[b\\c\\\\d$}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99938.337384.patch
Type: text/x-patch
Size: 2477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210414/3facc835/attachment.bin>
More information about the llvm-commits
mailing list