@@ -58,6 +58,7 @@ impl OutputAssertExt for process::Output {
5858}
5959
6060impl OutputAssertExt for & mut process:: Command {
61+ #[ track_caller]
6162 fn assert ( self ) -> Assert {
6263 let output = match self . output ( ) {
6364 Ok ( output) => output,
@@ -158,7 +159,11 @@ impl Assert {
158159 /// ```
159160 #[ track_caller]
160161 pub fn success ( self ) -> Self {
161- self . try_success ( ) . unwrap_or_else ( AssertError :: panic)
162+ match self . try_success ( ) {
163+ Ok ( v) => v,
164+ // Called manually so `#[track_caller]` is effective.
165+ Err ( e) => e. panic ( ) ,
166+ }
162167 }
163168
164169 /// `try_` variant of [`Assert::success`].
@@ -187,7 +192,11 @@ impl Assert {
187192 /// ```
188193 #[ track_caller]
189194 pub fn failure ( self ) -> Self {
190- self . try_failure ( ) . unwrap_or_else ( AssertError :: panic)
195+ match self . try_failure ( ) {
196+ Ok ( v) => v,
197+ // Called manually so `#[track_caller]` is effective.
198+ Err ( e) => e. panic ( ) ,
199+ }
191200 }
192201
193202 /// Variant of [`Assert::failure`] that returns an [`AssertResult`].
@@ -201,7 +210,11 @@ impl Assert {
201210 /// Ensure the command aborted before returning a code.
202211 #[ track_caller]
203212 pub fn interrupted ( self ) -> Self {
204- self . try_interrupted ( ) . unwrap_or_else ( AssertError :: panic)
213+ match self . try_interrupted ( ) {
214+ Ok ( v) => v,
215+ // Called manually so `#[track_caller]` is effective.
216+ Err ( e) => e. panic ( ) ,
217+ }
205218 }
206219
207220 /// Variant of [`Assert::interrupted`] that returns an [`AssertResult`].
@@ -266,7 +279,11 @@ impl Assert {
266279 I : IntoCodePredicate < P > ,
267280 P : predicates_core:: Predicate < i32 > ,
268281 {
269- self . try_code ( pred) . unwrap_or_else ( AssertError :: panic)
282+ match self . try_code ( pred) {
283+ Ok ( v) => v,
284+ // Called manually so `#[track_caller]` is effective.
285+ Err ( e) => e. panic ( ) ,
286+ }
270287 }
271288
272289 /// Variant of [`Assert::code`] that returns an [`AssertResult`].
@@ -364,7 +381,11 @@ impl Assert {
364381 I : IntoOutputPredicate < P > ,
365382 P : predicates_core:: Predicate < [ u8 ] > ,
366383 {
367- self . try_stdout ( pred) . unwrap_or_else ( AssertError :: panic)
384+ match self . try_stdout ( pred) {
385+ Ok ( v) => v,
386+ // Called manually so `#[track_caller]` is effective.
387+ Err ( e) => e. panic ( ) ,
388+ }
368389 }
369390
370391 /// Variant of [`Assert::stdout`] that returns an [`AssertResult`].
@@ -460,7 +481,11 @@ impl Assert {
460481 I : IntoOutputPredicate < P > ,
461482 P : predicates_core:: Predicate < [ u8 ] > ,
462483 {
463- self . try_stderr ( pred) . unwrap_or_else ( AssertError :: panic)
484+ match self . try_stderr ( pred) {
485+ Ok ( v) => v,
486+ // Called manually so `#[track_caller]` is effective.
487+ Err ( e) => e. panic ( ) ,
488+ }
464489 }
465490
466491 /// Variant of [`Assert::stderr`] that returns an [`AssertResult`].
0 commit comments