[lit] Why does if statement containing <command> with exit status 0 (in Bash) fail?
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
This lit test `xxx.ll`:
```
; RUN: if echo xxx | grep -q xxx ; then \
; RUN: echo "Success"; \
; RUN: else \
; RUN: echo "Failure"; \
; RUN: fi
```
executed via `llvm-lit xxx.ll -a` produces:
```
+ echo Success
```
which is expected.
This lit test `yyy.ll`:
```
; RUN: if objdump -t yyy.so | grep -q yyy ; then \
; RUN: echo "Success"; \
; RUN: else \
; RUN: echo "Failure"; \
; RUN: fi
```
executed via `llvm-lit yyy.ll -a` produces:
```
+ echo Failure
```
which is unexpected.
In Bash exit status of both commands is 0:
```
$ echo xxx | grep -q xxx ; echo $?
0
$ objdump -t yyy.so | grep -q yyy ; echo $?
0
```
Why does `yyy.ll` produce `+ echo Failure` if in Bash exit status of `objdump -t yyy.so | grep -q yyy` is 0?
Is it a bug in lit?
```
llvm-lit --version
lit 21.1.0dev
```
Contributor guide
Research direction
Start by reproducing the two RUN pipelines with llvm-lit 21.1.0dev, comparing them with Bash and checking the lit test execution path for pipeline handling. Use xxx.ll and yyy.ll as fixtures; done means explaining the differing status and, if lit is at fault, adding a regression test for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash
- Domain
- testing-qa, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100