[llvm] [llvm-lit][test] Updated built-in cat command tests (PR #104473)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 10:29:15 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-testing-tools

Author: Connie (connieyzhu)

<details>
<summary>Changes</summary>

This patch makes changes to improve syntax in tests and to add more strict checks on cat output.

---
Full diff: https://github.com/llvm/llvm-project/pull/104473.diff


3 Files Affected:

- (modified) llvm/utils/lit/tests/Inputs/shtest-cat/cat-error-0.txt (+1-1) 
- (modified) llvm/utils/lit/tests/Inputs/shtest-cat/cat-error-1.txt (+1-1) 
- (modified) llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt (+62-68) 


``````````diff
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-error-0.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-error-0.txt
index 690bc1e9e928aa..7bb71ab024911a 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-error-0.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-error-0.txt
@@ -1,3 +1,3 @@
-# Check error on an unsupported option for cat .
+## Test error on an unsupported option for cat .
 #
 # RUN: cat -b temp1.txt
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-error-1.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-error-1.txt
index 5344707e966404..f87e86698d090f 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-error-1.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-error-1.txt
@@ -1,3 +1,3 @@
-# Check error on a unsupported cat (Unable to find input file).
+## Test error on a unsupported cat (Unable to find input file).
 #
 # RUN: cat temp1.txt
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
index 7375a7497e5bec..5772b64dfcf596 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
@@ -1,83 +1,77 @@
 ## Test cat command with a single file.
 #
-# RUN: rm -rf %T/testCat
-# RUN: mkdir -p %T/testCat
-# RUN: echo "abcdefgh" > %T/testCat/temp.write
-# RUN: cat %T/testCat/temp.write > %T/testCat/tempcat.write
-# RUN: %{python} %S/../check_path.py file %T/testCat/tempcat.write > %T/testCat/path.out
-# RUN: FileCheck --check-prefix=FILE-EXISTS < %T/testCat/path.out %s
-# RUN: FileCheck --check-prefix=CAT-OUTPUT < %T/testCat/tempcat.write %s
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
+# RUN: echo "abcdefgh" > %t/temp.write
+# RUN: cat %t/temp.write > %t/tempcat.write
+# RUN: %{python} %S/../check_path.py file %t/tempcat.write > %t/path.out
+# RUN: FileCheck --check-prefix=FILE-EXISTS < %t/path.out %s
+# RUN: FileCheck --check-prefix=CAT-OUTPUT --implicit-check-not={{.}} \
+# RUN: --match-full-lines --strict-whitespace < %t/tempcat.write %s
 # FILE-EXISTS: True
-# CAT-OUTPUT: abcdefgh
+# CAT-OUTPUT:abcdefgh
 #
 ## Test cat command with multiple files.
 #
-# RUN: rm -rf %T/testCat
-# RUN: mkdir -p %T/testCat
-# RUN: echo "abcdefgh" > %T/testCat/temp1.write
-# RUN: echo "efghijkl" > %T/testCat/temp2.write
-# RUN: echo "mnopqrst" > %T/testCat/temp3.write
-# RUN: cat %T/testCat/temp1.write %T/testCat/temp2.write %T/testCat/temp3.write > %T/testCat/tempmulticat.write
-# RUN: %{python} %S/../check_path.py file %T/testCat/tempmulticat.write > %T/testCat/path.out
-# RUN: FileCheck --check-prefix=MULTI-FILE-EXISTS < %T/testCat/path.out %s
-# RUN: FileCheck --check-prefix=MULTI-CAT-OUTPUT < %T/testCat/tempmulticat.write %s
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
+# RUN: echo "abcdefgh" > %t/temp1.write
+# RUN: echo "efghijkl" > %t/temp2.write
+# RUN: echo "mnopqrst" > %t/temp3.write
+# RUN: cat %t/temp1.write %t/temp2.write %t/temp3.write > %t/tempmulticat.write
+# RUN: %{python} %S/../check_path.py file %t/tempmulticat.write > %t/path.out
+# RUN: FileCheck --check-prefix=MULTI-FILE-EXISTS < %t/path.out %s
+# RUN: FileCheck --check-prefix=MULTI-CAT-OUTPUT --implicit-check-not={{.}} \
+# RUN: --match-full-lines --strict-whitespace < %t/tempmulticat.write %s
 # MULTI-FILE-EXISTS: True
-# MULTI-CAT-OUTPUT: abcdefgh
-# MULTI-CAT-OUTPUT-NEXT: efghijkl
-# MULTI-CAT-OUTPUT-NEXT: mnopqrst
+# MULTI-CAT-OUTPUT:abcdefgh
+# MULTI-CAT-OUTPUT-NEXT:efghijkl
+# MULTI-CAT-OUTPUT-NEXT:mnopqrst
 #
 ## Test cat command with multiple files and piped output to FileCheck.
 #
-# RUN: rm -rf %T/testCat
-# RUN: mkdir -p %T/testCat
-# RUN: echo "abcdefgh" > %T/testCat/temp1.write
-# RUN: echo "efghijkl" > %T/testCat/temp2.write
-# RUN: cat %T/testCat/temp1.write %T/testCat/temp2.write | FileCheck --check-prefix=PIPED-CAT-OUTPUT %s
-# PIPED-CAT-OUTPUT: abcdefgh
-# PIPED-CAT-OUTPUT-NEXT: efghijkl
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
+# RUN: echo "abcdefgh" > %t/temp1.write
+# RUN: echo "efghijkl" > %t/temp2.write
+# RUN: cat %t/temp1.write %t/temp2.write \
+# RUN: | FileCheck --check-prefix=PIPED-CAT-OUTPUT --implicit-check-not={{.}} \
+# RUN: --match-full-lines --strict-whitespace %s
+# PIPED-CAT-OUTPUT:abcdefgh
+# PIPED-CAT-OUTPUT-NEXT:efghijkl
 #
 ## Test cat command with multiple files and glob expressions.
 #
-# RUN: rm -rf %T/testCat
-# RUN: mkdir -p %T/testCat
-# RUN: echo "cvbnm" > %T/testCat/temp1.write
-# RUN: echo "qwerty" > %T/testCat/temp2.write
-# RUN: cat %T/testCat/*.write | FileCheck --check-prefix=GLOB-CAT-OUTPUT %s
-# GLOB-CAT-OUTPUT: cvbnm
-# GLOB-CAT-OUTPUT-NEXT: qwerty
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
+# RUN: echo "cvbnm" > %t/temp1.write
+# RUN: echo "qwerty" > %t/temp2.write
+# RUN: cat %t/*.write \
+# RUN: | FileCheck --check-prefix=GLOB-CAT-OUTPUT --implicit-check-not={{.}} \
+# RUN: --match-full-lines --strict-whitespace %s
+# GLOB-CAT-OUTPUT:cvbnm
+# GLOB-CAT-OUTPUT-NEXT:qwerty
 #
-## Test cat command with -v option
+## Test cat command with -v and --show-nonprinting option.
+## The -v/--show-nonprinting option format text input into ^ and M- notation
 #
-# RUN: cat -v %S/cat_nonprinting.bin | FileCheck --check-prefix=NP-CAT-OUTPUT %s
-# NP-CAT-OUTPUT: ^@^A^B^C^D^E^F^G	^H
-# NP-CAT-OUTPUT-NEXT: ^K^L^M^N^O^P^Q^R^S
-# NP-CAT-OUTPUT-NEXT: ^T^U^V^W^X^Y^Z^[^\^]^^^_ !"#$%&'
-# NP-CAT-OUTPUT-NEXT: ()*+,-./0123456789:;
-# NP-CAT-OUTPUT-NEXT: <=>?@ABCDEFGHIJKLMNO
-# NP-CAT-OUTPUT-NEXT: PQRSTUVWXYZ[\]^_`abc
-# NP-CAT-OUTPUT-NEXT: defghijklmnopqrstuvw
-# NP-CAT-OUTPUT-NEXT: xyz{|}~^?M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^K
-# NP-CAT-OUTPUT-NEXT: M-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^ZM-^[M-^\M-^]M-^^M-^_
-# NP-CAT-OUTPUT-NEXT: M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3
-# NP-CAT-OUTPUT-NEXT: M-4M-5M-6M-7M-8M-9M-:M-;M-<M-=M->M-?M- at M-AM-BM-CM-DM-EM-FM-G
-# NP-CAT-OUTPUT-NEXT: M-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[
-# NP-CAT-OUTPUT-NEXT: M-\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-o
-# NP-CAT-OUTPUT-NEXT: M-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?
-#
-## Test cat command with -show-nonprinting option
-#
-# RUN: cat --show-nonprinting %S/cat_nonprinting.bin | FileCheck --check-prefix=NPLONG-CAT-OUTPUT %s
-# NPLONG-CAT-OUTPUT: ^@^A^B^C^D^E^F^G	^H
-# NPLONG-CAT-OUTPUT-NEXT: ^K^L^M^N^O^P^Q^R^S
-# NPLONG-CAT-OUTPUT-NEXT: ^T^U^V^W^X^Y^Z^[^\^]^^^_ !"#$%&'
-# NPLONG-CAT-OUTPUT-NEXT: ()*+,-./0123456789:;
-# NPLONG-CAT-OUTPUT-NEXT: <=>?@ABCDEFGHIJKLMNO
-# NPLONG-CAT-OUTPUT-NEXT: PQRSTUVWXYZ[\]^_`abc
-# NPLONG-CAT-OUTPUT-NEXT: defghijklmnopqrstuvw
-# NPLONG-CAT-OUTPUT-NEXT: xyz{|}~^?M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^K
-# NPLONG-CAT-OUTPUT-NEXT: M-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^ZM-^[M-^\M-^]M-^^M-^_
-# NPLONG-CAT-OUTPUT-NEXT: M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3
-# NPLONG-CAT-OUTPUT-NEXT: M-4M-5M-6M-7M-8M-9M-:M-;M-<M-=M->M-?M- at M-AM-BM-CM-DM-EM-FM-G
-# NPLONG-CAT-OUTPUT-NEXT: M-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[
-# NPLONG-CAT-OUTPUT-NEXT: M-\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-o
-# NPLONG-CAT-OUTPUT-NEXT: M-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?
+# RUN: cat -v %S/cat_nonprinting.bin \
+# RUN: | FileCheck --check-prefix=NP-CAT-OUTPUT --implicit-check-not={{.}} \
+# RUN: --match-full-lines --strict-whitespace %s
+# RUN: cat --show-nonprinting %S/cat_nonprinting.bin \
+# RUN: | FileCheck --check-prefix=NP-CAT-OUTPUT --implicit-check-not={{.}} \
+# RUN: --match-full-lines --strict-whitespace %s
+# NP-CAT-OUTPUT:^@^A^B^C^D^E^F^G	^H
+# NP-CAT-OUTPUT-NEXT:^K^L^M^N^O^P^Q^R^S
+# NP-CAT-OUTPUT-NEXT:^T^U^V^W^X^Y^Z^[^\^]^^^_ !"#$%&'
+# NP-CAT-OUTPUT-NEXT:()*+,-./0123456789:;
+# NP-CAT-OUTPUT-NEXT:<=>?@ABCDEFGHIJKLMNO
+# NP-CAT-OUTPUT-NEXT:PQRSTUVWXYZ[\]^_`abc
+# NP-CAT-OUTPUT-NEXT:defghijklmnopqrstuvw
+# NP-CAT-OUTPUT-NEXT:xyz{|}~^?M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^K
+# NP-CAT-OUTPUT-NEXT:M-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^ZM-^[M-^\M-^]M-^^M-^_
+# NP-CAT-OUTPUT-NEXT:M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3
+# NP-CAT-OUTPUT-NEXT:M-4M-5M-6M-7M-8M-9M-:M-;M-<M-=M->M-?M- at M-AM-BM-CM-DM-EM-FM-G
+# NP-CAT-OUTPUT-NEXT:M-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[
+# NP-CAT-OUTPUT-NEXT:M-\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-o
+# NP-CAT-OUTPUT-NEXT:M-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?

``````````

</details>


https://github.com/llvm/llvm-project/pull/104473


More information about the llvm-commits mailing list