@@ -71,6 +71,14 @@ pub fn run_metrics(config: Config, testfile: String, mm: &mut MetricMap) {
71
71
}
72
72
}
73
73
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
+
74
82
fn run_cfail_test ( config : & Config , props : & TestProps , testfile : & Path ) {
75
83
let proc_res = compile_test ( config, props, testfile) ;
76
84
@@ -81,16 +89,22 @@ fn run_cfail_test(config: &Config, props: &TestProps, testfile: &Path) {
81
89
82
90
check_correct_failure_status ( & proc_res) ;
83
91
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) ;
84
97
let expected_errors = errors:: load_errors ( & config. cfail_regex , testfile) ;
85
98
if !expected_errors. is_empty ( ) {
86
99
if !props. error_patterns . is_empty ( ) {
87
100
fatal ( "both error pattern and expected errors specified" ) ;
88
101
}
89
102
check_expected_errors ( expected_errors, testfile, & proc_res) ;
90
103
} else {
91
- check_error_patterns ( props, testfile, & proc_res) ;
104
+ check_error_patterns ( props, testfile, output_to_check . as_slice ( ) , & proc_res) ;
92
105
}
93
106
check_no_compiler_crash ( & proc_res) ;
107
+ check_forbid_output ( props, output_to_check. as_slice ( ) , & proc_res) ;
94
108
}
95
109
96
110
fn run_rfail_test ( config : & Config , props : & TestProps , testfile : & Path ) {
@@ -112,8 +126,9 @@ fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
112
126
fatal_proc_rec ( "run-fail test isn't valgrind-clean!" , & proc_res) ;
113
127
}
114
128
129
+ let output_to_check = get_output ( props, & proc_res) ;
115
130
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) ;
117
132
}
118
133
119
134
fn check_correct_failure_status ( proc_res : & ProcRes ) {
@@ -834,24 +849,15 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
834
849
835
850
fn check_error_patterns ( props : & TestProps ,
836
851
testfile : & Path ,
852
+ output_to_check : & str ,
837
853
proc_res : & ProcRes ) {
838
854
if props. error_patterns . is_empty ( ) {
839
855
fatal ( format ! ( "no error pattern specified in {}" ,
840
856
testfile. display( ) ) . as_slice ( ) ) ;
841
857
}
842
-
843
- if proc_res. status . success ( ) {
844
- fatal ( "process did not return an error status" ) ;
845
- }
846
-
847
858
let mut next_err_idx = 0 u;
848
859
let mut next_err_pat = & props. error_patterns [ next_err_idx] ;
849
860
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
- } ;
855
861
for line in output_to_check. as_slice ( ) . lines ( ) {
856
862
if line. contains ( next_err_pat. as_slice ( ) ) {
857
863
debug ! ( "found error pattern {}" , next_err_pat) ;
@@ -890,6 +896,16 @@ fn check_no_compiler_crash(proc_res: &ProcRes) {
890
896
}
891
897
}
892
898
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
+
893
909
fn check_expected_errors ( expected_errors : Vec < errors:: ExpectedError > ,
894
910
testfile : & Path ,
895
911
proc_res : & ProcRes ) {
0 commit comments