Struct bigbro::Status [] [src]

pub struct Status { /* fields omitted */ }

The result of running a command using bigbro.

It contains the ExitStatus as well as the information about files and directories accessed by the command.

Methods

impl Status
[src]

This returns the std::process::ExitStatus of the process. Was termination successful? Signal termination not considered a success, and success is defined as a zero exit status.

Examples

use bigbro::Command;

let status = Command::new("false")
                     .status()
                     .expect("failed to execute false");

assert!(! status.status().success() ); // should fail because "false" always fails

This retuns the set of directories that the process read from. For details of what is meant by a process having "read from a directory", see semantics.

Examples

use bigbro::Command;

let dir = std::env::temp_dir();
let status = Command::new("ls")
                     .arg(&dir)
                     .status()
                     .expect("failed to execute ls");

assert!(status.status().success() );
if bigbro::TRACKS_CHANGES {
  assert!(status.read_from_directories().contains(&dir) );
}

This retuns the set of files that the process read. For details of what is meant by a process having "read from a directory", see semantics.

Examples

use bigbro::Command;

let mut p = env::current_dir().unwrap();
p.push("Cargo.toml");
let e = std::ffi::OsString::from(&p);
let status = Command::new("cat")
                     .arg(&e)
                     .status()
                     .expect("failed to execute cat");

assert!(status.status().success() );
for f in status.read_from_files() {
   println!("read file {:#?}", f);
}
if bigbro::TRACKS_CHANGES {
  assert!(status.read_from_files().contains(&p) );
}

This retuns the set of files that the process wrote to. For details of what is meant by a process having "read from a directory", see semantics.

Examples

use bigbro::Command;

let mut p = std::env::temp_dir();
p.push("hello");
let status = Command::new("touch")
                     .arg(&p)
                     .status()
                     .expect("failed to execute sh");

assert!(status.status().success() );
for f in status.written_to_files() {
   println!("wrote file {:#?}", f);
}
if bigbro::TRACKS_CHANGES {
  assert!(status.written_to_files().contains(&p) );
  assert!(status.written_to_files().len() == 1 );
}

This retuns the set of directories that the process created. For details of what is meant by a process having "read from a directory", see semantics.

This retuns the stdout, if it has been saved using save_stdouterr.

Examples

use bigbro::Command;

let mut status = Command::new("ls")
                         .save_stdouterr()
                         .status()
                         .expect("failed to execute ls");

assert!(status.status().success() );
let f = status.stdout().unwrap();
assert!(f.is_some());
let mut contents = String::new();
f.unwrap().read_to_string(&mut contents);
println!("ls gives: {}", contents);
assert!(contents.contains("Cargo.toml"));
assert!(contents.contains("src"));

Trait Implementations

impl Debug for Status
[src]

Formats the value using the given formatter.