[llvm] 918dad5 - [test] Avoid unportable echo in Other/lit-quoting.txt
Rainer Orth via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 14 15:21:16 PDT 2021
Author: Rainer Orth
Date: 2021-08-15T00:20:47+02:00
New Revision: 918dad54bd226a8c2fda42bc63dbb1f324bf6c24
URL: https://github.com/llvm/llvm-project/commit/918dad54bd226a8c2fda42bc63dbb1f324bf6c24
DIFF: https://github.com/llvm/llvm-project/commit/918dad54bd226a8c2fda42bc63dbb1f324bf6c24.diff
LOG: [test] Avoid unportable echo in Other/lit-quoting.txt
`LLVM :: Other/lit-quoting.txt` currently `FAIL`s on Solaris:
llvm/test/Other/lit-quoting.txt:8:9: error: CHECK2: expected string not found in input
CHECK2: {{^a\[b\\c$}}
^
<stdin>:1:1: note: scanning from here
a[b
^
This happens because echo with backslashes or special characters is
unportable, as extensively documented in the Autoconf manual. In the case
at hand, `echo 'a[b\c'` yields `a[b\c` on Linux, but `a[b` (no newline) on
Solaris.
This patch fixes this by using the portable alternative suggested in the
Autoconf manual.
Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
Differential Revision: https://reviews.llvm.org/D108031
Added:
Modified:
llvm/test/Other/lit-quoting.txt
Removed:
################################################################################
diff --git a/llvm/test/Other/lit-quoting.txt b/llvm/test/Other/lit-quoting.txt
index 48a72e20e4603..76dc67956a290 100644
--- a/llvm/test/Other/lit-quoting.txt
+++ b/llvm/test/Other/lit-quoting.txt
@@ -1,14 +1,14 @@
-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: printf "%%s\n" "\"" | FileCheck %s --check-prefix=CHECK1
+RUN: printf "%%s\n" '"' | FileCheck %s --check-prefix=CHECK1
+RUN: printf "%%s\n" 'a[b\c' | FileCheck %s --check-prefix=CHECK2
+RUN: printf "%%s\n" "a[b\\c" | FileCheck %s --check-prefix=CHECK2
+RUN: printf "%%s\n" 'a\b\\c\\\\d' | FileCheck %s --check-prefix=CHECK3
+RUN: printf "%%s\n" "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
+RUNX: printf "%%s\n" 'a[b\c\\d' | FileCheck %s --check-prefix=CHECK4
+RUNX: printf "%%s\n" "a[b\\c\\\\d" | FileCheck %s --check-prefix=CHECK4
CHECK4: {{^a\[b\\c\\\\d$}}
More information about the llvm-commits
mailing list