Skip to content
This repository has been archived by the owner on Dec 29, 2021. It is now read-only.

How to test piping one command into another #119

Open
samuela opened this issue Jan 25, 2020 · 3 comments
Open

How to test piping one command into another #119

samuela opened this issue Jan 25, 2020 · 3 comments

Comments

@samuela
Copy link

samuela commented Jan 25, 2020

I have a situation in which I'd like to test the output of things like myprog | head and echo "foobar" | myprog. Is there a way to accomplish this with assert_cli? A concise assert_cmd! option would be ideal.

@epage
Copy link
Collaborator

epage commented Jan 25, 2020

Are you just wanting to test your programs handling of stdin/stdout or is there something more specific you want to test related to pipes, like broken pipes?

@samuela
Copy link
Author

samuela commented Jan 25, 2020

Both ultimately would be nice but piping stdin/stdout is the most pressing. I ended up finding https://github.com/oconnor663/duct.rs and I'm giving that a shot atm

@vincentdephily
Copy link

If you just need to pipe, then it's easy to run ["/bin/sh", "-c", "your | piped | commands"], I do that in a few places (although for more complicated shell scripts that are out of scope for assert_cmd).

Proper pipe support in assert_cmd would be great, though it implies support for running and scheduling multiple commands, which is a can of worms we've opened elsewhere.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants