llvm / llvm/llvm-project

Waiting for user input Bash / Linux commands running under lit may not wait for user input

Open
#192,459 1 comment 0 reactions 0 assignees View on GitHub
llvm-lit question
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

In my lit test `xxx.ll` there is (fragment):
```
RUN: rm -i xxx && ...
```
Per `man rm`:
```
-i prompt before every removal
```
To my surprise running `lit xxx.ll` does not prompt (before every removal). lit exit status is 0 (file is not removed).

I asked AI "why doesn't python called bash wait for user input". AI replied:
> The most common reason Python fails to wait for user input when calling a Bash script is because of Standard Input (stdin) redirection or pipe isolation. When you run a script through Python's subprocess module, the child process (Bash) may not be connected to your physical keyboard (the terminal TTY) by default.

Does lit run the RUN commands with standard input (stdin) redirection or pipe isolation?

Does lit run the child process (Bash), which is not connected to the physical keyboard (the terminal TTY) by default?

I searched lit [documentation](https://llvm.org/docs/CommandGuide/lit.html) by "stdin" and found nothing.

What else I tried:
```
read
read < $TMPDIR/xxx # $TMPDIR/xxx is FIFO (named pipe) created with mkfifo
```
Nothing above works: bash commands above running under lit don't wait for user input.

Is it a bug in lit?

Is in undocumented feature of lit?

P.S. I quickly looked on `TestRunner.py` and could not quickly fix the issue.

Contributor guide

Open the contributing guide

Research direction

Start with the TestRunner.py file mentioned in the report and trace how lit launches RUN commands and handles stdin. Reproduce the rm -i, read, and FIFO examples from xxx.ll, then check the linked lit documentation. Done means the stdin behavior is either corrected or explicitly documented and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, linux, python
Domain
testing-qa, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.