rust-cli / human-panic

Panic messages for humans.
https://docs.rs/human-panic
Apache License 2.0
1.66k stars 65 forks source link

Add simple integration test & infrastructure #24

Closed killercup closed 6 years ago

killercup commented 6 years ago

Turns this repository into a cargo workspaces and adds a sub-crate with the wonderful name 'simple-human-panic-test' that lives in the new tests/ directory. This should be of no consequence to the actual crate itself or its deployment to crates.io, but allows us to easily test how human-panic works when in an external crate. Especially, we can set up the sub-crate Cargo.toml files in a way that we can easily test that human-panic's output does not cause panics in humans.

For that, I've also added a simple integration test to the simple test crate. It uses assert_cli to run the crate's main binary and assert its output contains certain strings (as well as that it exits with a panic- typical exit code). By the way: One benefit of using cargo workspaces is that sub-crates share a lock file and a target/ directory. So, we can add lots of test crates without worrying of having to recompile dependencies all the time.

You can easily run the tests across all sub-crates with cargo test --all. In general, most cargo subcommands support --all, and I've added it in a few places in the CI config.

This is the first step towards #18 but I'd like to add more tests before closing this issue.