()
| 253 | |
| 254 | #[test] |
| 255 | fn command_run_capture_stderr() { |
| 256 | // The basics |
| 257 | Command::new("true").run_capture_stderr().unwrap(); |
| 258 | assert!(Command::new("false").run_capture_stderr().is_err()); |
| 259 | |
| 260 | // Verify we capture stderr |
| 261 | let e = Command::new("/bin/sh") |
| 262 | .args(["-c", "echo expected-this-oops-message 1>&2; exit 1"]) |
| 263 | .run_capture_stderr() |
| 264 | .err() |
| 265 | .unwrap(); |
| 266 | similar_asserts::assert_eq!( |
| 267 | e.to_string(), |
| 268 | "Subprocess failed: ExitStatus(unix_wait_status(256))\nexpected-this-oops-message\n" |
| 269 | ); |
| 270 | |
| 271 | // Ignoring invalid UTF-8 |
| 272 | let e = Command::new("/bin/sh") |
| 273 | .args([ |
| 274 | "-c", |
| 275 | r"echo -e 'expected\xf5\x80\x80\x80\x80-foo\xc0bar\xc0\xc0' 1>&2; exit 1", |
| 276 | ]) |
| 277 | .run_capture_stderr() |
| 278 | .err() |
| 279 | .unwrap(); |
| 280 | similar_asserts::assert_eq!( |
| 281 | e.to_string(), |
| 282 | "Subprocess failed: ExitStatus(unix_wait_status(256))\nexpected�����-foo�bar��\n" |
| 283 | ); |
| 284 | } |
| 285 | |
| 286 | #[test] |
| 287 | fn exit_status_check_status() { |
nothing calls this directly
no test coverage detected