@@ -667,6 +667,57 @@ impl Execs {
667
667
/// Verifies that stdout is equal to the given lines.
668
668
///
669
669
/// See [`compare::assert_e2e`] for assertion details.
670
+ ///
671
+ /// <div class="warning">
672
+ ///
673
+ /// Prefer passing in [`str!`] for `expected` to get snapshot updating.
674
+ ///
675
+ /// If `format!` is needed for content that changes from run to run that you don't care about,
676
+ /// consider whether you could have [`compare::assert_e2e`] redact the content.
677
+ /// If nothing else, a wildcard (`[..]`, `...`) may be useful.
678
+ ///
679
+ /// However, `""` may be preferred for intentionally empty output so people don't accidentally
680
+ /// bless a change.
681
+ ///
682
+ /// </div>
683
+ ///
684
+ /// # Examples
685
+ ///
686
+ /// ```no_run
687
+ /// use cargo_test_support::prelude::*;
688
+ /// use cargo_test_support::str;
689
+ /// use cargo_test_support::execs;
690
+ ///
691
+ /// execs().with_stdout_data(str![r#"
692
+ /// Hello world!
693
+ /// "#]);
694
+ /// ```
695
+ ///
696
+ /// Non-deterministic compiler output
697
+ /// ```no_run
698
+ /// use cargo_test_support::prelude::*;
699
+ /// use cargo_test_support::str;
700
+ /// use cargo_test_support::execs;
701
+ ///
702
+ /// execs().with_stdout_data(str![r#"
703
+ /// [COMPILING] foo
704
+ /// [COMPILING] bar
705
+ /// "#].unordered());
706
+ /// ```
707
+ ///
708
+ /// jsonlines
709
+ /// ```no_run
710
+ /// use cargo_test_support::prelude::*;
711
+ /// use cargo_test_support::str;
712
+ /// use cargo_test_support::execs;
713
+ ///
714
+ /// execs().with_stdout_data(str![r#"
715
+ /// [
716
+ /// {},
717
+ /// {}
718
+ /// ]
719
+ /// "#].is_json().against_jsonlines());
720
+ /// ```
670
721
pub fn with_stdout_data ( & mut self , expected : impl snapbox:: IntoData ) -> & mut Self {
671
722
self . expect_stdout_data = Some ( expected. into_data ( ) ) ;
672
723
self
@@ -675,6 +726,57 @@ impl Execs {
675
726
/// Verifies that stderr is equal to the given lines.
676
727
///
677
728
/// See [`compare::assert_e2e`] for assertion details.
729
+ ///
730
+ /// <div class="warning">
731
+ ///
732
+ /// Prefer passing in [`str!`] for `expected` to get snapshot updating.
733
+ ///
734
+ /// If `format!` is needed for content that changes from run to run that you don't care about,
735
+ /// consider whether you could have [`compare::assert_e2e`] redact the content.
736
+ /// If nothing else, a wildcard (`[..]`, `...`) may be useful.
737
+ ///
738
+ /// However, `""` may be preferred for intentionally empty output so people don't accidentally
739
+ /// bless a change.
740
+ ///
741
+ /// </div>
742
+ ///
743
+ /// # Examples
744
+ ///
745
+ /// ```no_run
746
+ /// use cargo_test_support::prelude::*;
747
+ /// use cargo_test_support::str;
748
+ /// use cargo_test_support::execs;
749
+ ///
750
+ /// execs().with_stderr_data(str![r#"
751
+ /// Hello world!
752
+ /// "#]);
753
+ /// ```
754
+ ///
755
+ /// Non-deterministic compiler output
756
+ /// ```no_run
757
+ /// use cargo_test_support::prelude::*;
758
+ /// use cargo_test_support::str;
759
+ /// use cargo_test_support::execs;
760
+ ///
761
+ /// execs().with_stderr_data(str![r#"
762
+ /// [COMPILING] foo
763
+ /// [COMPILING] bar
764
+ /// "#].unordered());
765
+ /// ```
766
+ ///
767
+ /// jsonlines
768
+ /// ```no_run
769
+ /// use cargo_test_support::prelude::*;
770
+ /// use cargo_test_support::str;
771
+ /// use cargo_test_support::execs;
772
+ ///
773
+ /// execs().with_stderr_data(str![r#"
774
+ /// [
775
+ /// {},
776
+ /// {}
777
+ /// ]
778
+ /// "#].is_json().against_jsonlines());
779
+ /// ```
678
780
pub fn with_stderr_data ( & mut self , expected : impl snapbox:: IntoData ) -> & mut Self {
679
781
self . expect_stderr_data = Some ( expected. into_data ( ) ) ;
680
782
self
@@ -706,7 +808,14 @@ impl Execs {
706
808
/// its output.
707
809
///
708
810
/// See [`compare`] for supported patterns.
709
- #[ deprecated( note = "replaced with `Execs::with_stdout_data(expected)`" ) ]
811
+ ///
812
+ /// <div class="warning">
813
+ ///
814
+ /// Prefer [`Execs::with_stdout_data`] where possible.
815
+ /// - `expected` cannot be snapshotted
816
+ /// - `expected` can end up being ambiguous, causing the assertion to succeed when it should fail
817
+ ///
818
+ /// </div>
710
819
pub fn with_stdout_contains < S : ToString > ( & mut self , expected : S ) -> & mut Self {
711
820
self . expect_stdout_contains . push ( expected. to_string ( ) ) ;
712
821
self
@@ -716,7 +825,14 @@ impl Execs {
716
825
/// its output.
717
826
///
718
827
/// See [`compare`] for supported patterns.
719
- #[ deprecated( note = "replaced with `Execs::with_stderr_data(expected)`" ) ]
828
+ ///
829
+ /// <div class="warning">
830
+ ///
831
+ /// Prefer [`Execs::with_stderr_data`] where possible.
832
+ /// - `expected` cannot be snapshotted
833
+ /// - `expected` can end up being ambiguous, causing the assertion to succeed when it should fail
834
+ ///
835
+ /// </div>
720
836
pub fn with_stderr_contains < S : ToString > ( & mut self , expected : S ) -> & mut Self {
721
837
self . expect_stderr_contains . push ( expected. to_string ( ) ) ;
722
838
self
@@ -727,7 +843,18 @@ impl Execs {
727
843
/// See [`compare`] for supported patterns.
728
844
///
729
845
/// See note on [`Self::with_stderr_does_not_contain`].
730
- #[ deprecated]
846
+ ///
847
+ /// <div class="warning">
848
+ ///
849
+ /// Prefer [`Execs::with_stdout_data`] where possible.
850
+ /// - `expected` cannot be snapshotted
851
+ /// - The absence of `expected` can either mean success or that the string being looked for
852
+ /// changed.
853
+ ///
854
+ /// To mitigate this, consider matching this up with
855
+ /// [`Execs::with_stdout_contains`].
856
+ ///
857
+ /// </div>
731
858
pub fn with_stdout_does_not_contain < S : ToString > ( & mut self , expected : S ) -> & mut Self {
732
859
self . expect_stdout_not_contains . push ( expected. to_string ( ) ) ;
733
860
self
@@ -737,12 +864,18 @@ impl Execs {
737
864
///
738
865
/// See [`compare`] for supported patterns.
739
866
///
740
- /// Care should be taken when using this method because there is a
741
- /// limitless number of possible things that *won't* appear. A typo means
742
- /// your test will pass without verifying the correct behavior. If
743
- /// possible, write the test first so that it fails, and then implement
744
- /// your fix/feature to make it pass.
745
- #[ deprecated]
867
+ /// <div class="warning">
868
+ ///
869
+ /// Prefer [`Execs::with_stdout_data`] where possible.
870
+ /// - `expected` cannot be snapshotted
871
+ /// - The absence of `expected` can either mean success or that the string being looked for
872
+ /// changed.
873
+ ///
874
+ /// To mitigate this, consider either matching this up with
875
+ /// [`Execs::with_stdout_contains`] or replace it
876
+ /// with [`Execs::with_stderr_line_without`].
877
+ ///
878
+ /// </div>
746
879
pub fn with_stderr_does_not_contain < S : ToString > ( & mut self , expected : S ) -> & mut Self {
747
880
self . expect_stderr_not_contains . push ( expected. to_string ( ) ) ;
748
881
self
@@ -751,7 +884,18 @@ impl Execs {
751
884
/// Verify that a particular line appears in stderr with and without the
752
885
/// given substrings. Exactly one line must match.
753
886
///
754
- /// The substrings are matched as `contains`. Example:
887
+ /// The substrings are matched as `contains`.
888
+ ///
889
+ /// <div class="warning">
890
+ ///
891
+ /// Prefer [`Execs::with_stdout_data`] where possible.
892
+ /// - `with` cannot be snapshotted
893
+ /// - The absence of `without`` can either mean success or that the string being looked for
894
+ /// changed.
895
+ ///
896
+ /// </div>
897
+ ///
898
+ /// # Example
755
899
///
756
900
/// ```no_run
757
901
/// use cargo_test_support::execs;
@@ -768,9 +912,6 @@ impl Execs {
768
912
/// This will check that a build line includes `-C opt-level=3` but does
769
913
/// not contain `-C debuginfo` or `-C incremental`.
770
914
///
771
- /// Be careful writing the `without` fragments, see note in
772
- /// `with_stderr_does_not_contain`.
773
- #[ deprecated]
774
915
pub fn with_stderr_line_without < S : ToString > (
775
916
& mut self ,
776
917
with : & [ S ] ,
0 commit comments