[][src]Struct bigbro::Status

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]

pub fn status(&self) -> ExitStatus[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

pub fn read_from_directories(&self) -> HashSet<PathBuf>[src]

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) );
}

pub fn read_from_files(&self) -> HashSet<PathBuf>[src]

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 {
  println!("The above list should have {:?}", p);
  assert!(status.read_from_files().contains(&p) );
}

pub fn written_to_files(&self) -> HashSet<PathBuf>[src]

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 );
}

pub fn mkdir_directories(&self) -> HashSet<PathBuf>[src]

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.

pub fn stdout(&mut self) -> Result<Option<Box<dyn Read>>>[src]

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]

Auto Trait Implementations

impl Sync for Status

impl Send for Status

impl Unpin for Status

impl RefUnwindSafe for Status

impl UnwindSafe for Status

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]