@@ -57,22 +57,22 @@ use cli_error::CliError;
57
57
/// To test that
58
58
///
59
59
/// ```sh
60
- /// ls -n1 src/
60
+ /// bash -c $BLACK_BOX
61
61
/// ```
62
62
///
63
63
/// returns
64
64
///
65
65
/// ```plain
66
- /// cli_error.rs
67
- /// diff.rs
68
- /// lib.rs
66
+ /// Launch sequence initiated.
69
67
/// ```
70
68
///
71
69
/// you would call it like this:
72
70
///
73
- /// ```rust,no_run
71
+ /// ```rust
74
72
/// # extern crate assert_cli;
75
- /// assert_cli::assert_cli_output("ls", &["-n1", "src/"], "cli_error.rs\ndiff.rs\nlib.rs");
73
+ /// # const BLACK_BOX: &'static str = r#"function test_helper() {\
74
+ /// # echo "Launch sequence initiated."; return 0; }; test_helper"#;
75
+ /// assert_cli::assert_cli_output("bash", &["-c", BLACK_BOX], "Launch sequence initiated.");
76
76
/// ```
77
77
pub fn assert_cli_output < S > ( cmd : & str , args : & [ S ] , expected_output : & str ) -> Result < ( ) , Box < Error > >
78
78
where S : AsRef < OsStr >
@@ -100,7 +100,28 @@ pub fn assert_cli_output<S>(cmd: &str, args: &[S], expected_output: &str) -> Res
100
100
. map_err ( From :: from)
101
101
}
102
102
103
- /// Assert a CLI call fails with the expected error code and output.
103
+ /// Assert a CLI call that fails the expected `stderr` output and error code.
104
+ ///
105
+ /// To test that
106
+ ///
107
+ /// ```sh
108
+ /// bash -c $BLACK_BOX
109
+ /// ```
110
+ ///
111
+ /// fails with an exit code of `42` after printing this to `stderr`
112
+ ///
113
+ /// ```plain
114
+ /// error no 42!
115
+ /// ```
116
+ ///
117
+ /// you would call it like this:
118
+ ///
119
+ /// ```rust
120
+ /// # extern crate assert_cli;
121
+ /// # const BLACK_BOX: &'static str = r#"function test_helper() {\
122
+ /// # >&2 echo "error no 42!"; return 42; }; test_helper"#;
123
+ /// assert_cli::assert_cli_output_error("bash", &["-c", BLACK_BOX], Some(42), "error no 42!");
124
+ /// ```
104
125
pub fn assert_cli_output_error < S > ( cmd : & str ,
105
126
args : & [ S ] ,
106
127
error_code : Option < i32 > ,
0 commit comments