@@ -43,7 +43,8 @@ pub fn run(input: &str,
43
43
libs : SearchPaths ,
44
44
externs : core:: Externs ,
45
45
mut test_args : Vec < String > ,
46
- crate_name : Option < String > )
46
+ crate_name : Option < String > ,
47
+ deny_warnings : bool )
47
48
-> int {
48
49
let input_path = Path :: new ( input) ;
49
50
let input = config:: Input :: File ( input_path. clone ( ) ) ;
@@ -101,6 +102,7 @@ pub fn run(input: &str,
101
102
libs,
102
103
externs,
103
104
false ) ;
105
+ collector. deny_warnings = deny_warnings;
104
106
collector. fold_crate ( krate) ;
105
107
106
108
test_args. insert ( 0 , "rustdoctest" . to_string ( ) ) ;
@@ -112,10 +114,10 @@ pub fn run(input: &str,
112
114
113
115
fn runtest ( test : & str , cratename : & str , libs : SearchPaths ,
114
116
externs : core:: Externs ,
115
- should_fail : bool , no_run : bool , as_test_harness : bool ) {
117
+ should_fail : bool , no_run : bool , as_test_harness : bool , deny_warnings : bool ) {
116
118
// the test harness wants its own `main` & top level functions, so
117
119
// never wrap the test in `fn main() { ... }`
118
- let test = maketest ( test, Some ( cratename) , true , as_test_harness) ;
120
+ let test = maketest ( test, Some ( cratename) , true , as_test_harness, deny_warnings ) ;
119
121
let input = config:: Input :: Str ( test. to_string ( ) ) ;
120
122
121
123
let sessopts = config:: Options {
@@ -214,13 +216,17 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
214
216
}
215
217
}
216
218
217
- pub fn maketest ( s : & str , cratename : Option < & str > , lints : bool , dont_insert_main : bool ) -> String {
219
+ pub fn maketest ( s : & str , cratename : Option < & str > ,
220
+ lints : bool , dont_insert_main : bool , deny_warnings : bool ) -> String {
218
221
let mut prog = String :: new ( ) ;
219
222
if lints {
220
223
prog. push_str ( r"
221
224
#![allow(unused_variables, unused_assignments, unused_mut, unused_attributes, dead_code)]
222
225
" ) ;
223
226
}
227
+ if deny_warnings {
228
+ prog. push_str ( "#![deny(warnings)]\n " ) ;
229
+ }
224
230
225
231
// Don't inject `extern crate std` because it's already injected by the
226
232
// compiler.
@@ -255,6 +261,7 @@ pub struct Collector {
255
261
use_headers : bool ,
256
262
current_header : Option < String > ,
257
263
cratename : String ,
264
+ deny_warnings : bool ,
258
265
}
259
266
260
267
impl Collector {
@@ -269,6 +276,7 @@ impl Collector {
269
276
use_headers : use_headers,
270
277
current_header : None ,
271
278
cratename : cratename,
279
+ deny_warnings : false ,
272
280
}
273
281
}
274
282
@@ -284,6 +292,7 @@ impl Collector {
284
292
let libs = self . libs . clone ( ) ;
285
293
let externs = self . externs . clone ( ) ;
286
294
let cratename = self . cratename . to_string ( ) ;
295
+ let deny_warnings = self . deny_warnings ;
287
296
debug ! ( "Creating test {}: {}" , name, test) ;
288
297
self . tests . push ( testing:: TestDescAndFn {
289
298
desc : testing:: TestDesc {
@@ -298,7 +307,8 @@ impl Collector {
298
307
externs,
299
308
should_fail,
300
309
no_run,
301
- as_test_harness) ;
310
+ as_test_harness,
311
+ deny_warnings) ;
302
312
} ) )
303
313
} ) ;
304
314
}
0 commit comments