Skip to content

Commit c707896

Browse files
committed
Capture output from mpd.
1 parent 49dfc21 commit c707896

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/helpers/daemon.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ extern crate tempdir;
33
use self::tempdir::TempDir;
44
use super::mpd;
55
use std::fs::{File, create_dir};
6-
use std::io::Write;
6+
use std::io::{Write, Read};
77
use std::os::unix::net::UnixStream;
88
use std::path::{Path, PathBuf};
9-
use std::process::{Command, Child};
9+
use std::process::{Command, Child, Stdio};
1010

1111
struct MpdConfig {
1212
db_file: PathBuf,
@@ -68,6 +68,12 @@ impl Drop for Daemon {
6868
fn drop(&mut self) {
6969
self.process.kill().expect("Could not kill mpd daemon.");
7070
self.process.wait().expect("Could not wait for mpd daemon to shutdown.");
71+
if let Some(ref mut stderr) = self.process.stderr {
72+
let mut output = String::new();
73+
stderr.read_to_string(&mut output).expect("Could not collect output from mpd.");
74+
println!{"Output from mpd:"}
75+
println!{"{}", output};
76+
}
7177
}
7278
}
7379

@@ -85,6 +91,9 @@ impl Daemon {
8591
let process = Command::new("mpd")
8692
.arg("--no-daemon")
8793
.arg(&config.config_path)
94+
.stdin(Stdio::null())
95+
.stdout(Stdio::null())
96+
.stderr(Stdio::piped())
8897
.spawn()
8998
.expect("Could not create mpd daemon.");
9099

0 commit comments

Comments
 (0)