FileCheck-style testing for rust integration tests.
Say you have a binary (named calculator) that reads expressions from stdin, and outputs result to stdout.
Then in tests/integration.rs write:
#[test]
fn run_output_check_tests() {
outputcheck::run([
"tests/outputcheck/simple.txt",
]);
}and in tests/outputcheck/simple.txt:
# RUN: cargo run --binary=calculator -- --input=%s --output=/dev/stdout
1 + 2
# CHECK: Result: 3
9 * 3
# CHECK: Result: 27
10 / 0
# CHECK: <Division by zero error>