Repository navigation
Conversation
POSIX cat reads standard input for a "-" operand, but lit's builtin cat tried to open a file named "-" and failed, so RUN lines such as `echo foo | cat - %t` broke under the internal shell. Assisted-by: Claude Code (claude-opus-5-5)
|
Hello @thejesh23 👋 Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.
Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description. Frequently asked questionsHow do I add reviewers? This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically. You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using What if there are no comments? If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers. Are any special GitHub settings required to contribute to LLVM? We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details. If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse. Thank you, |
|
@llvm/pr-subscribers-testing-tools Author: Thejesh (thejesh23) Changeslit's builtin Fixes #240058 Assisted-by: Claude Code (claude-opus-5-5). I reviewed the change. I also ran the Full diff: https://github.com/llvm/llvm-project/pull/240060.diff 2 Files Affected:
diff --git a/llvm/utils/lit/lit/builtin_commands/cat.py b/llvm/utils/lit/lit/builtin_commands/cat.py
index 2882b79f572fd9..bf5430d037e038 100644
--- a/llvm/utils/lit/lit/builtin_commands/cat.py
+++ b/llvm/utils/lit/lit/builtin_commands/cat.py
@@ -71,7 +71,9 @@ def run(argv, stdin, stdout, stderr, cwd):
contents = None
is_text = False
- if platform.system() == "OS/390":
+ if filename == "-":
+ contents = stdin.read()
+ elif platform.system() == "OS/390":
try:
with open(path, "r") as fileToCat:
contents = fileToCat.read()
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
index c5b5d247c2f959..0f7a81fe168e89 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
@@ -74,3 +74,15 @@
## Test that cat will pipe stdin to stdout if no other files are specified.
# RUN: echo test | cat | FileCheck --check-prefix=CAT-STDIN %s
# CAT-STDIN: test
+
+## Test that cat reads stdin in place of a "-" operand.
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
+# RUN: echo "abcdefgh" > %t/temp1.write
+# RUN: echo "mnopqrst" > %t/temp2.write
+# RUN: echo "efghijkl" | cat %t/temp1.write - %t/temp2.write | \
+# RUN: FileCheck --check-prefix=DASH-CAT-OUTPUT --implicit-check-not={{.}} \
+# RUN: --match-full-lines --strict-whitespace %s
+# DASH-CAT-OUTPUT:abcdefgh
+# DASH-CAT-OUTPUT-NEXT:efghijkl
+# DASH-CAT-OUTPUT-NEXT:mnopqrst
|
lit's builtin
catnow reads stdin for a-operand, as POSIXcatdoes. This adds a case to theshtest-catinputs.Fixes #240058
Assisted-by: Claude Code (claude-opus-5-5). I reviewed the change. I also ran the
shtest-catinputs locally: they fail before the change and pass after it.