@@ -72,7 +72,7 @@ use cli_error::CliError;
72
72
/// # echo "Launch sequence initiated."; return 0; }; test_helper"#;
73
73
/// assert_cli::assert_cli("bash", &["-c", BLACK_BOX]);
74
74
/// ```
75
- pub fn assert_cli < S > ( cmd : & str , args : & [ S ] ) -> Result < ( ) , Box < Error > >
75
+ pub fn assert_cli < S > ( cmd : & str , args : & [ S ] ) -> Result < Output , Box < Error > >
76
76
where S : AsRef < OsStr >
77
77
{
78
78
let call: Result < Output , Box < Error > > = Command :: new ( cmd)
@@ -85,7 +85,7 @@ pub fn assert_cli<S>(cmd: &str, args: &[S]) -> Result<(), Box<Error>>
85
85
return Err ( From :: from ( CliError :: WrongExitCode ( output) ) ) ;
86
86
}
87
87
88
- Ok ( ( ) )
88
+ Ok ( output )
89
89
} )
90
90
. map_err ( From :: from)
91
91
}
@@ -113,7 +113,7 @@ pub fn assert_cli<S>(cmd: &str, args: &[S]) -> Result<(), Box<Error>>
113
113
/// # echo "Launch sequence initiated."; return 0; }; test_helper"#;
114
114
/// assert_cli::assert_cli_output("bash", &["-c", BLACK_BOX], "Launch sequence initiated.");
115
115
/// ```
116
- pub fn assert_cli_output < S > ( cmd : & str , args : & [ S ] , expected_output : & str ) -> Result < ( ) , Box < Error > >
116
+ pub fn assert_cli_output < S > ( cmd : & str , args : & [ S ] , expected_output : & str ) -> Result < Output , Box < Error > >
117
117
where S : AsRef < OsStr >
118
118
{
119
119
let call: Result < Output , Box < Error > > = Command :: new ( cmd)
@@ -126,15 +126,17 @@ pub fn assert_cli_output<S>(cmd: &str, args: &[S], expected_output: &str) -> Res
126
126
return Err ( From :: from ( CliError :: WrongExitCode ( output) ) ) ;
127
127
}
128
128
129
- let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
130
- let ( distance, changes) = difference:: diff ( expected_output. trim ( ) ,
131
- & stdout. trim ( ) ,
132
- "\n " ) ;
133
- if distance > 0 {
134
- return Err ( From :: from ( CliError :: OutputMissmatch ( changes) ) ) ;
129
+ {
130
+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
131
+ let ( distance, changes) = difference:: diff ( expected_output. trim ( ) ,
132
+ & stdout. trim ( ) ,
133
+ "\n " ) ;
134
+ if distance > 0 {
135
+ return Err ( From :: from ( CliError :: OutputMissmatch ( changes) ) ) ;
136
+ }
135
137
}
136
138
137
- Ok ( ( ) )
139
+ Ok ( output )
138
140
} )
139
141
. map_err ( From :: from)
140
142
}
@@ -160,7 +162,7 @@ pub fn assert_cli_output<S>(cmd: &str, args: &[S], expected_output: &str) -> Res
160
162
pub fn assert_cli_error < S > ( cmd : & str ,
161
163
args : & [ S ] ,
162
164
error_code : Option < i32 > )
163
- -> Result < ( ) , Box < Error > >
165
+ -> Result < Output , Box < Error > >
164
166
where S : AsRef < OsStr >
165
167
{
166
168
let call: Result < Output , Box < Error > > = Command :: new ( cmd)
@@ -179,7 +181,7 @@ pub fn assert_cli_error<S>(cmd: &str,
179
181
_ => { }
180
182
}
181
183
182
- Ok ( ( ) )
184
+ Ok ( output )
183
185
} )
184
186
. map_err ( From :: from)
185
187
}
@@ -210,7 +212,7 @@ pub fn assert_cli_output_error<S>(cmd: &str,
210
212
args : & [ S ] ,
211
213
error_code : Option < i32 > ,
212
214
expected_output : & str )
213
- -> Result < ( ) , Box < Error > >
215
+ -> Result < Output , Box < Error > >
214
216
where S : AsRef < OsStr >
215
217
{
216
218
let call: Result < Output , Box < Error > > = Command :: new ( cmd)
@@ -229,15 +231,17 @@ pub fn assert_cli_output_error<S>(cmd: &str,
229
231
_ => { }
230
232
}
231
233
232
- let stdout = String :: from_utf8_lossy ( & output. stderr ) ;
233
- let ( distance, changes) = difference:: diff ( expected_output. trim ( ) ,
234
- & stdout. trim ( ) ,
235
- "\n " ) ;
236
- if distance > 0 {
237
- return Err ( From :: from ( CliError :: OutputMissmatch ( changes) ) ) ;
234
+ {
235
+ let stdout = String :: from_utf8_lossy ( & output. stderr ) ;
236
+ let ( distance, changes) = difference:: diff ( expected_output. trim ( ) ,
237
+ & stdout. trim ( ) ,
238
+ "\n " ) ;
239
+ if distance > 0 {
240
+ return Err ( From :: from ( CliError :: OutputMissmatch ( changes) ) ) ;
241
+ }
238
242
}
239
243
240
- Ok ( ( ) )
244
+ Ok ( output )
241
245
} )
242
246
. map_err ( From :: from)
243
247
}
0 commit comments