[PATCH] D108031: [test] Avoid unportable echo in Other/lit-quoting.txt

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 13 06:06:54 PDT 2021


ro created this revision.
ro added a reviewer: mstorsjo.
Herald added subscribers: ormris, pengfei, fedor.sergeev, jyknight.
ro requested review of this revision.
Herald added a project: LLVM.

`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`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108031

Files:
  llvm/test/Other/lit-quoting.txt


Index: llvm/test/Other/lit-quoting.txt
===================================================================
--- llvm/test/Other/lit-quoting.txt
+++ 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$}}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108031.366260.patch
Type: text/x-patch
Size: 1397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210813/1d73ed56/attachment.bin>


More information about the llvm-commits mailing list