@@ -71,6 +71,14 @@ pub fn run_metrics(config: Config, testfile: String, mm: &mut MetricMap) {
7171 }
7272}
7373
74+ fn get_output ( props : & TestProps , proc_res : & ProcRes ) -> String {
75+ if props. check_stdout {
76+ format ! ( "{}{}" , proc_res. stdout, proc_res. stderr)
77+ } else {
78+ proc_res. stderr . clone ( )
79+ }
80+ }
81+
7482fn run_cfail_test ( config : & Config , props : & TestProps , testfile : & Path ) {
7583 let proc_res = compile_test ( config, props, testfile) ;
7684
@@ -81,16 +89,22 @@ fn run_cfail_test(config: &Config, props: &TestProps, testfile: &Path) {
8189
8290 check_correct_failure_status ( & proc_res) ;
8391
92+ if proc_res. status . success ( ) {
93+ fatal ( "process did not return an error status" ) ;
94+ }
95+
96+ let output_to_check = get_output ( props, & proc_res) ;
8497 let expected_errors = errors:: load_errors ( & config. cfail_regex , testfile) ;
8598 if !expected_errors. is_empty ( ) {
8699 if !props. error_patterns . is_empty ( ) {
87100 fatal ( "both error pattern and expected errors specified" ) ;
88101 }
89102 check_expected_errors ( expected_errors, testfile, & proc_res) ;
90103 } else {
91- check_error_patterns ( props, testfile, & proc_res) ;
104+ check_error_patterns ( props, testfile, output_to_check . as_slice ( ) , & proc_res) ;
92105 }
93106 check_no_compiler_crash ( & proc_res) ;
107+ check_forbid_output ( props, output_to_check. as_slice ( ) , & proc_res) ;
94108}
95109
96110fn run_rfail_test ( config : & Config , props : & TestProps , testfile : & Path ) {
@@ -112,8 +126,9 @@ fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
112126 fatal_proc_rec ( "run-fail test isn't valgrind-clean!" , & proc_res) ;
113127 }
114128
129+ let output_to_check = get_output ( props, & proc_res) ;
115130 check_correct_failure_status ( & proc_res) ;
116- check_error_patterns ( props, testfile, & proc_res) ;
131+ check_error_patterns ( props, testfile, output_to_check . as_slice ( ) , & proc_res) ;
117132}
118133
119134fn check_correct_failure_status ( proc_res : & ProcRes ) {
@@ -834,24 +849,15 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
834849
835850fn check_error_patterns ( props : & TestProps ,
836851 testfile : & Path ,
852+ output_to_check : & str ,
837853 proc_res : & ProcRes ) {
838854 if props. error_patterns . is_empty ( ) {
839855 fatal ( format ! ( "no error pattern specified in {}" ,
840856 testfile. display( ) ) . as_slice ( ) ) ;
841857 }
842-
843- if proc_res. status . success ( ) {
844- fatal ( "process did not return an error status" ) ;
845- }
846-
847858 let mut next_err_idx = 0 u;
848859 let mut next_err_pat = & props. error_patterns [ next_err_idx] ;
849860 let mut done = false ;
850- let output_to_check = if props. check_stdout {
851- format ! ( "{}{}" , proc_res. stdout, proc_res. stderr)
852- } else {
853- proc_res. stderr . clone ( )
854- } ;
855861 for line in output_to_check. as_slice ( ) . lines ( ) {
856862 if line. contains ( next_err_pat. as_slice ( ) ) {
857863 debug ! ( "found error pattern {}" , next_err_pat) ;
@@ -890,6 +896,16 @@ fn check_no_compiler_crash(proc_res: &ProcRes) {
890896 }
891897}
892898
899+ fn check_forbid_output ( props : & TestProps ,
900+ output_to_check : & str ,
901+ proc_res : & ProcRes ) {
902+ for pat in props. forbid_output . iter ( ) {
903+ if output_to_check. contains ( pat. as_slice ( ) ) {
904+ fatal_proc_rec ( "forbidden pattern found in compiler output" , proc_res) ;
905+ }
906+ }
907+ }
908+
893909fn check_expected_errors ( expected_errors : Vec < errors:: ExpectedError > ,
894910 testfile : & Path ,
895911 proc_res : & ProcRes ) {
0 commit comments