@@ -108,12 +108,30 @@ impl Assert {
108
108
self
109
109
}
110
110
111
+ /// Asserts that the command exited without the given `unexpected` stdout pattern.
112
+ pub fn without_stdout ( & self , unexpected : & str ) -> & Self {
113
+ if self . output . stdout . contains ( unexpected) {
114
+ print_indented ( "expected.stdout.does_not_contain" , unexpected) ;
115
+ panic ! ( ) ;
116
+ }
117
+ self
118
+ }
119
+
111
120
/// Asserts that the command exited with the given `expected` stderr pattern.
112
121
pub fn with_stderr ( & self , expected : impl IntoData ) -> & Self {
113
122
let stderr = self . redactions . redact ( & self . output . stderr ) ;
114
123
assert_data_eq ! ( & stderr, expected) ;
115
124
self
116
125
}
126
+
127
+ /// Asserts that the command exited without the given `unexpected` stderr pattern.
128
+ pub fn without_stderr ( & self , unexpected : & str ) -> & Self {
129
+ if self . output . stderr . contains ( unexpected) {
130
+ print_indented ( "expected.stderr.does_not_contain" , unexpected) ;
131
+ panic ! ( ) ;
132
+ }
133
+ self
134
+ }
117
135
}
118
136
119
137
impl Config {
@@ -212,11 +230,14 @@ impl Config {
212
230
}
213
231
214
232
/// Expect an ok status
233
+ #[ deprecated( note = "use `.expect().await.is_ok()` instead" ) ]
234
+ #[ allow( deprecated) ]
215
235
pub async fn expect_ok ( & mut self , args : & [ & str ] ) {
216
236
self . expect_ok_env ( args, & [ ] ) . await
217
237
}
218
238
219
239
/// Expect an ok status with extra environment variables
240
+ #[ deprecated( note = "use `.expect_with_env().await.is_ok()` instead" ) ]
220
241
pub async fn expect_ok_env ( & self , args : & [ & str ] , env : & [ ( & str , & str ) ] ) {
221
242
let out = self . run ( args[ 0 ] , & args[ 1 ..] , env) . await ;
222
243
if !out. ok {
@@ -227,11 +248,14 @@ impl Config {
227
248
}
228
249
229
250
/// Expect an err status and a string in stderr
251
+ #[ deprecated( note = "use `.expect().await.is_err()` instead" ) ]
252
+ #[ allow( deprecated) ]
230
253
pub async fn expect_err ( & self , args : & [ & str ] , expected : & str ) {
231
254
self . expect_err_env ( args, & [ ] , expected) . await
232
255
}
233
256
234
257
/// Expect an err status and a string in stderr, with extra environment variables
258
+ #[ deprecated( note = "use `.expect_with_env().await.is_err()` instead" ) ]
235
259
pub async fn expect_err_env ( & self , args : & [ & str ] , env : & [ ( & str , & str ) ] , expected : & str ) {
236
260
let out = self . run ( args[ 0 ] , & args[ 1 ..] , env) . await ;
237
261
if out. ok || !out. stderr . contains ( expected) {
@@ -243,6 +267,7 @@ impl Config {
243
267
}
244
268
245
269
/// Expect an ok status and a string in stdout
270
+ #[ deprecated( note = "use `.expect().await.is_ok().with_stdout()` instead" ) ]
246
271
pub async fn expect_stdout_ok ( & self , args : & [ & str ] , expected : & str ) {
247
272
let out = self . run ( args[ 0 ] , & args[ 1 ..] , & [ ] ) . await ;
248
273
if !out. ok || !out. stdout . contains ( expected) {
@@ -253,6 +278,7 @@ impl Config {
253
278
}
254
279
}
255
280
281
+ #[ deprecated( note = "use `.expect().await.is_ok().without_stdout()` instead" ) ]
256
282
pub async fn expect_not_stdout_ok ( & self , args : & [ & str ] , expected : & str ) {
257
283
let out = self . run ( args[ 0 ] , & args[ 1 ..] , & [ ] ) . await ;
258
284
if !out. ok || out. stdout . contains ( expected) {
@@ -263,6 +289,7 @@ impl Config {
263
289
}
264
290
}
265
291
292
+ #[ deprecated( note = "use `.expect().await.is_ok().without_stderr()` instead" ) ]
266
293
pub async fn expect_not_stderr_ok ( & self , args : & [ & str ] , expected : & str ) {
267
294
let out = self . run ( args[ 0 ] , & args[ 1 ..] , & [ ] ) . await ;
268
295
if !out. ok || out. stderr . contains ( expected) {
@@ -273,6 +300,7 @@ impl Config {
273
300
}
274
301
}
275
302
303
+ #[ deprecated( note = "use `.expect().await.is_err().without_stderr()` instead" ) ]
276
304
pub async fn expect_not_stderr_err ( & self , args : & [ & str ] , expected : & str ) {
277
305
let out = self . run ( args[ 0 ] , & args[ 1 ..] , & [ ] ) . await ;
278
306
if out. ok || out. stderr . contains ( expected) {
@@ -284,6 +312,7 @@ impl Config {
284
312
}
285
313
286
314
/// Expect an ok status and a string in stderr
315
+ #[ deprecated( note = "use `.expect().await.is_ok().with_stderr()` instead" ) ]
287
316
pub async fn expect_stderr_ok ( & self , args : & [ & str ] , expected : & str ) {
288
317
let out = self . run ( args[ 0 ] , & args[ 1 ..] , & [ ] ) . await ;
289
318
if !out. ok || !out. stderr . contains ( expected) {
@@ -295,12 +324,17 @@ impl Config {
295
324
}
296
325
297
326
/// Expect an exact strings on stdout/stderr with an ok status code
327
+ #[ deprecated( note = "use `.expect().await.is_ok().with_stderr()` instead" ) ]
328
+ #[ allow( deprecated) ]
298
329
pub async fn expect_ok_ex ( & mut self , args : & [ & str ] , stdout : & str , stderr : & str ) {
299
330
self . expect_ok_ex_env ( args, & [ ] , stdout, stderr) . await ;
300
331
}
301
332
302
333
/// Expect an exact strings on stdout/stderr with an ok status code,
303
334
/// with extra environment variables
335
+ #[ deprecated(
336
+ note = "use `.expect_with_env().await.is_ok().with_stdout().with_stderr()` instead"
337
+ ) ]
304
338
pub async fn expect_ok_ex_env (
305
339
& mut self ,
306
340
args : & [ & str ] ,
@@ -321,6 +355,7 @@ impl Config {
321
355
}
322
356
323
357
/// Expect an exact strings on stdout/stderr with an error status code
358
+ #[ deprecated( note = "use `.expect().await.is_err().with_stdout().with_stderr()` instead" ) ]
324
359
pub async fn expect_err_ex ( & self , args : & [ & str ] , stdout : & str , stderr : & str ) {
325
360
let out = self . run ( args[ 0 ] , & args[ 1 ..] , & [ ] ) . await ;
326
361
if out. ok || out. stdout != stdout || out. stderr != stderr {
0 commit comments