| impl fmt::Display for Foo { |
| fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| if env::var("YOU_ARE_TESTING_NOW").is_ok() { |
| let exe = env::current_exe().unwrap(); |
| let out = process::Command::new(exe) |
| .env("YOU_ARE_TESTING_NOW", "1") |
| .env("RUST_LOG", "debug") |
| .unwrap_or_else(|e| panic!("Unable to start child process: {}", e)); |
| if out.status.success() { |
| println!("test failed: {}", out.status); |
| println!("--- stdout\n{}", str::from_utf8(&out.stdout).unwrap()); |
| println!("--- stderr\n{}", str::from_utf8(&out.stderr).unwrap()); |