Optionally dump stdout

This commit is contained in:
Graham Christensen 2017-12-04 19:03:42 -05:00
parent d2cfece806
commit 1fc075a5b7
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
3 changed files with 16 additions and 6 deletions

View file

@ -28,7 +28,7 @@ impl EvalChecker {
}
pub fn execute(&self, path: &Path) -> Result<File, File> {
self.nix.safely(&self.cmd, path, self.args.clone())
self.nix.safely(&self.cmd, path, self.args.clone(), false)
}
pub fn cli_cmd(&self) -> String {

View file

@ -40,18 +40,27 @@ impl Nix {
attrargs.push(attr);
}
return self.safely("nix-build", nixpkgs, attrargs);
return self.safely("nix-build", nixpkgs, attrargs, true);
}
pub fn safely(&self, cmd: &str, nixpkgs: &Path, args: Vec<String>) -> Result<File,File> {
pub fn safely(&self, cmd: &str, nixpkgs: &Path, args: Vec<String>, keep_stdout: bool) -> Result<File,File> {
let mut nixpath = OsString::new();
nixpath.push("nixpkgs=");
nixpath.push(nixpkgs.as_os_str());
let stdout = tempfile().expect("Fetching a stdout tempfile");
let stderr = stdout.try_clone().expect("Cloning stdout for stderr");
let stderr = tempfile().expect("Fetching a stderr tempfile");
let mut reader = stderr.try_clone().expect("Cloning stderr to the reader");
let stdout: Stdio;
if keep_stdout {
let stdout_fd = stderr.try_clone().expect("Cloning stderr for stdout");
stdout = Stdio::from(stdout_fd);
} else {
stdout = Stdio::null();
}
let status = Command::new(cmd)
.env_clear()
.current_dir(nixpkgs)

View file

@ -436,7 +436,8 @@ impl Stdenvs {
String::from("."),
String::from("-A"),
String::from("stdenv"),
]
],
false
);
println!("{:?}", result);