As part of my learning project of porting Apple’s shell_cmds to rust, I would like to properly test things.
Here’s the thing. Some of the utilities are mostly just custom parsing of command-line arguments, which means I’m trying to test the binary itself.
In my project, I have library code like this:
src/command.rs. I can put unit tests of library code right in this file. That’s fine.
Then I’ve got binaries that look something like this:
/src/bin/command.rs – this binary is where the command-line parsing happens.
I can make integration tests in
tests/command.rs to test inter-library stuff, but I don’t see any way to get at the binary’s code.
So, I’m thinking the answer is to spawn the binary from the integration test file and interact with it that way. But how do I know which binary has just been produced (ie should I call
target/debug/command or…?)? I’m hoping I don’t have to spawn a shell and then call
cargo run --bin command…because that seems awful kludgy.