@@ -545,54 +545,54 @@ pub struct Execs {
545545impl Execs {
546546 /// Verify that stdout is equal to the given lines.
547547 /// See `lines_match` for supported patterns.
548- pub fn with_stdout < S : ToString > ( mut self , expected : S ) -> Execs {
548+ pub fn with_stdout < S : ToString > ( & mut self , expected : S ) -> & mut Self {
549549 self . expect_stdout = Some ( expected. to_string ( ) ) ;
550550 self
551551 }
552552
553553 /// Verify that stderr is equal to the given lines.
554554 /// See `lines_match` for supported patterns.
555- pub fn with_stderr < S : ToString > ( mut self , expected : S ) -> Execs {
555+ pub fn with_stderr < S : ToString > ( & mut self , expected : S ) -> & mut Self {
556556 self . expect_stderr = Some ( expected. to_string ( ) ) ;
557557 self
558558 }
559559
560560 /// Verify the exit code from the process.
561561 ///
562562 /// This is not necessary if the expected exit code is `0`.
563- pub fn with_status ( mut self , expected : i32 ) -> Execs {
563+ pub fn with_status ( & mut self , expected : i32 ) -> & mut Self {
564564 self . expect_exit_code = Some ( expected) ;
565565 self
566566 }
567567
568568 /// Verify that stdout contains the given contiguous lines somewhere in
569569 /// its output.
570570 /// See `lines_match` for supported patterns.
571- pub fn with_stdout_contains < S : ToString > ( mut self , expected : S ) -> Execs {
571+ pub fn with_stdout_contains < S : ToString > ( & mut self , expected : S ) -> & mut Self {
572572 self . expect_stdout_contains . push ( expected. to_string ( ) ) ;
573573 self
574574 }
575575
576576 /// Verify that stderr contains the given contiguous lines somewhere in
577577 /// its output.
578578 /// See `lines_match` for supported patterns.
579- pub fn with_stderr_contains < S : ToString > ( mut self , expected : S ) -> Execs {
579+ pub fn with_stderr_contains < S : ToString > ( & mut self , expected : S ) -> & mut Self {
580580 self . expect_stderr_contains . push ( expected. to_string ( ) ) ;
581581 self
582582 }
583583
584584 /// Verify that either stdout or stderr contains the given contiguous
585585 /// lines somewhere in its output.
586586 /// See `lines_match` for supported patterns.
587- pub fn with_either_contains < S : ToString > ( mut self , expected : S ) -> Execs {
587+ pub fn with_either_contains < S : ToString > ( & mut self , expected : S ) -> & mut Self {
588588 self . expect_either_contains . push ( expected. to_string ( ) ) ;
589589 self
590590 }
591591
592592 /// Verify that stdout contains the given contiguous lines somewhere in
593593 /// its output, and should be repeated `number` times.
594594 /// See `lines_match` for supported patterns.
595- pub fn with_stdout_contains_n < S : ToString > ( mut self , expected : S , number : usize ) -> Execs {
595+ pub fn with_stdout_contains_n < S : ToString > ( & mut self , expected : S , number : usize ) -> & mut Self {
596596 self . expect_stdout_contains_n
597597 . push ( ( expected. to_string ( ) , number) ) ;
598598 self
@@ -601,7 +601,7 @@ impl Execs {
601601 /// Verify that stdout does not contain the given contiguous lines.
602602 /// See `lines_match` for supported patterns.
603603 /// See note on `with_stderr_does_not_contain`.
604- pub fn with_stdout_does_not_contain < S : ToString > ( mut self , expected : S ) -> Execs {
604+ pub fn with_stdout_does_not_contain < S : ToString > ( & mut self , expected : S ) -> & mut Self {
605605 self . expect_stdout_not_contains . push ( expected. to_string ( ) ) ;
606606 self
607607 }
@@ -614,7 +614,7 @@ impl Execs {
614614 /// your test will pass without verifying the correct behavior. If
615615 /// possible, write the test first so that it fails, and then implement
616616 /// your fix/feature to make it pass.
617- pub fn with_stderr_does_not_contain < S : ToString > ( mut self , expected : S ) -> Execs {
617+ pub fn with_stderr_does_not_contain < S : ToString > ( & mut self , expected : S ) -> & mut Self {
618618 self . expect_stderr_not_contains . push ( expected. to_string ( ) ) ;
619619 self
620620 }
@@ -634,7 +634,7 @@ impl Execs {
634634 /// [RUNNING] `rustc --crate-name foo [..]
635635 /// This will randomly fail if the other crate name is `bar`, and the
636636 /// order changes.
637- pub fn with_stderr_unordered < S : ToString > ( mut self , expected : S ) -> Execs {
637+ pub fn with_stderr_unordered < S : ToString > ( & mut self , expected : S ) -> & mut Self {
638638 self . expect_stderr_unordered . push ( expected. to_string ( ) ) ;
639639 self
640640 }
@@ -655,7 +655,7 @@ impl Execs {
655655 /// The order of arrays is ignored.
656656 /// Strings support patterns described in `lines_match`.
657657 /// Use `{...}` to match any object.
658- pub fn with_json ( mut self , expected : & str ) -> Execs {
658+ pub fn with_json ( & mut self , expected : & str ) -> & mut Self {
659659 self . expect_json = Some (
660660 expected
661661 . split ( "\n \n " )
@@ -669,7 +669,7 @@ impl Execs {
669669 /// Useful for printf debugging of the tests.
670670 /// CAUTION: CI will fail if you leave this in your test!
671671 #[ allow( unused) ]
672- pub fn stream ( mut self ) -> Execs {
672+ pub fn stream ( & mut self ) -> & mut Self {
673673 self . stream_output = true ;
674674 self
675675 }
@@ -1193,18 +1193,36 @@ impl ham::Matcher<ProcessBuilder> for Execs {
11931193 }
11941194}
11951195
1196+ impl < ' t > ham:: Matcher < ProcessBuilder > for & ' t mut Execs {
1197+ fn matches ( & self , process : ProcessBuilder ) -> ham:: MatchResult {
1198+ self . match_process ( & process)
1199+ }
1200+ }
1201+
11961202impl < ' a > ham:: Matcher < & ' a mut ProcessBuilder > for Execs {
11971203 fn matches ( & self , process : & ' a mut ProcessBuilder ) -> ham:: MatchResult {
11981204 self . match_process ( process)
11991205 }
12001206}
12011207
1208+ impl < ' a , ' t > ham:: Matcher < & ' a mut ProcessBuilder > for & ' t mut Execs {
1209+ fn matches ( & self , process : & ' a mut ProcessBuilder ) -> ham:: MatchResult {
1210+ self . match_process ( process)
1211+ }
1212+ }
1213+
12021214impl ham:: Matcher < Output > for Execs {
12031215 fn matches ( & self , output : Output ) -> ham:: MatchResult {
12041216 self . match_output ( & output)
12051217 }
12061218}
12071219
1220+ impl < ' t > ham:: Matcher < Output > for & ' t mut Execs {
1221+ fn matches ( & self , output : Output ) -> ham:: MatchResult {
1222+ self . match_output ( & output)
1223+ }
1224+ }
1225+
12081226pub fn execs ( ) -> Execs {
12091227 Execs {
12101228 expect_stdout : None ,
0 commit comments