File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed 
src/tools/run-make-support/src Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use std::path::Path;
66use  std:: process:: { Command  as  StdCommand ,  ExitStatus ,  Output ,  Stdio } ; 
77
88use  crate :: drop_bomb:: DropBomb ; 
9- use  crate :: { assert_not_contains,  handle_failed_output} ; 
9+ use  crate :: { assert_contans ,   assert_not_contains,  handle_failed_output} ; 
1010
1111/// This is a custom command wrapper that simplifies working with commands and makes it easier to 
1212/// ensure that we check the exit status of executed processes. 
@@ -167,6 +167,12 @@ impl CompletedProcess {
167167        self 
168168    } 
169169
170+     #[ track_caller]  
171+     pub  fn  assert_stdout_contains < S :  AsRef < str > > ( self ,  needle :  S )  -> Self  { 
172+         assert_contains ( self . stdout_utf8 ( ) ,  needle. as_ref ( ) ) ; 
173+         self 
174+     } 
175+ 
170176    #[ track_caller]  
171177    pub  fn  assert_stdout_not_contains < S :  AsRef < str > > ( & self ,  needle :  S )  -> & Self  { 
172178        assert_not_contains ( & self . stdout_utf8 ( ) ,  needle. as_ref ( ) ) ; 
@@ -182,7 +188,7 @@ impl CompletedProcess {
182188
183189    #[ track_caller]  
184190    pub  fn  assert_stderr_contains < S :  AsRef < str > > ( & self ,  needle :  S )  -> & Self  { 
185-         assert ! ( self . stderr_utf8( ) . contains ( needle. as_ref( ) ) ) ; 
191+         assert_contains ( self . stderr_utf8 ( ) ,   needle. as_ref ( ) ) ; 
186192        self 
187193    } 
188194
Original file line number Diff line number Diff line change @@ -315,6 +315,18 @@ pub fn read_dir<F: Fn(&Path)>(dir: impl AsRef<Path>, callback: F) {
315315    } 
316316} 
317317
318+ /// Check that `haystack` contains `needle`. Panic otherwise. 
319+ #[ track_caller]  
320+ pub  fn  assert_contains ( haystack :  & str ,  needle :  & str )  { 
321+     if  !haystack. contains ( needle)  { 
322+         eprintln ! ( "=== HAYSTACK ===" ) ; 
323+         eprintln ! ( "{}" ,  haystack) ; 
324+         eprintln ! ( "=== NEEDLE ===" ) ; 
325+         eprintln ! ( "{}" ,  needle) ; 
326+         panic ! ( "needle was not found in haystack" ) ; 
327+     } 
328+ } 
329+ 
318330/// Check that `haystack` does not contain `needle`. Panic otherwise. 
319331#[ track_caller]  
320332pub  fn  assert_not_contains ( haystack :  & str ,  needle :  & str )  { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments