[llvm] [llvm-lit][test] Updated built-in cat command tests (PR #104473)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 11:29:30 PDT 2024
https://github.com/connieyzhu updated https://github.com/llvm/llvm-project/pull/104473
>From 2ba19599874143b019a02ba61ca0b481d07d16b9 Mon Sep 17 00:00:00 2001
From: Connie Zhu <connieyzhu at google.com>
Date: Thu, 15 Aug 2024 17:25:22 +0000
Subject: [PATCH 1/2] [llvm-lit][test] Updated built-in cat command tests
This patch makes changes to improve syntax in tests and to add more
strict checks on cat output.
---
.../tests/Inputs/shtest-cat/cat-error-0.txt | 2 +-
.../tests/Inputs/shtest-cat/cat-error-1.txt | 2 +-
.../utils/lit/tests/Inputs/shtest-cat/cat.txt | 130 +++++++++---------
3 files changed, 64 insertions(+), 70 deletions(-)
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-^?
>From 47b05c25fe9ade46575ad25b0b5e6caa8074463a Mon Sep 17 00:00:00 2001
From: Connie Zhu <connieyzhu at google.com>
Date: Thu, 15 Aug 2024 18:23:12 +0000
Subject: [PATCH 2/2] [llvm-lit][test] Made small syntax changes
---
.../tests/Inputs/shtest-cat/cat-error-0.txt | 2 +-
.../utils/lit/tests/Inputs/shtest-cat/cat.txt | 22 +++++++++----------
2 files changed, 12 insertions(+), 12 deletions(-)
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 7bb71ab024911a..5333b4d1561473 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 @@
-## Test 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.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
index 5772b64dfcf596..4af7c2436d0308 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
@@ -7,7 +7,7 @@
# 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
+# RUN: --match-full-lines --strict-whitespace < %t/tempcat.write %s
# FILE-EXISTS: True
# CAT-OUTPUT:abcdefgh
#
@@ -22,7 +22,7 @@
# 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
+# RUN: --match-full-lines --strict-whitespace < %t/tempmulticat.write %s
# MULTI-FILE-EXISTS: True
# MULTI-CAT-OUTPUT:abcdefgh
# MULTI-CAT-OUTPUT-NEXT:efghijkl
@@ -35,8 +35,8 @@
# 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
+# 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
#
@@ -47,20 +47,20 @@
# 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
+# 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 and --show-nonprinting option.
-## The -v/--show-nonprinting option format text input into ^ and M- notation
+## The -v/--show-nonprinting options format text input into ^ and M- notation
#
# 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: | 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
+# 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^[^\^]^^^_ !"#$%&'
More information about the llvm-commits
mailing list