17
17
extern mod extra;
18
18
19
19
use std:: os;
20
+ use std:: f64;
20
21
21
22
use extra:: getopts;
22
23
use extra:: getopts:: groups:: { optopt, optflag, reqopt} ;
@@ -66,6 +67,10 @@ pub fn parse_config(args: ~[~str]) -> config {
66
67
optopt ( "" , "rustcflags" , "flags to pass to rustc" , "FLAGS" ) ,
67
68
optflag ( "" , "verbose" , "run tests verbosely, showing all output" ) ,
68
69
optopt ( "" , "logfile" , "file to log test execution to" , "FILE" ) ,
70
+ optopt ( "" , "save-metrics" , "file to save metrics to" , "FILE" ) ,
71
+ optopt ( "" , "ratchet-metrics" , "file to ratchet metrics against" , "FILE" ) ,
72
+ optopt ( "" , "ratchet-noise-percent" ,
73
+ "percent change in metrics to consider noise" , "N" ) ,
69
74
optflag ( "" , "jit" , "run tests under the JIT" ) ,
70
75
optflag ( "" , "newrt" , "run tests on the new runtime / scheduler" ) ,
71
76
optopt ( "" , "target" , "the target to build for" , "TARGET" ) ,
@@ -116,6 +121,13 @@ pub fn parse_config(args: ~[~str]) -> config {
116
121
Some ( copy matches. free [ 0 ] )
117
122
} else { None } ,
118
123
logfile : getopts:: opt_maybe_str ( matches, "logfile" ) . map ( |s| Path ( * s) ) ,
124
+ save_metrics : getopts:: opt_maybe_str ( matches, "save-metrics" ) . map ( |s| Path ( * s) ) ,
125
+ ratchet_metrics :
126
+ getopts:: opt_maybe_str ( matches, "ratchet-metrics" ) . map ( |s| Path ( * s) ) ,
127
+ ratchet_noise_percent :
128
+ getopts:: opt_maybe_str ( matches,
129
+ "ratchet-noise-percent" ) . map ( |s|
130
+ f64:: from_str ( * s) . get ( ) ) ,
119
131
runtool : getopts:: opt_maybe_str ( matches, "runtool" ) ,
120
132
rustcflags : getopts:: opt_maybe_str ( matches, "rustcflags" ) ,
121
133
jit : getopts:: opt_present ( matches, "jit" ) ,
@@ -215,10 +227,10 @@ pub fn test_opts(config: &config) -> test::TestOpts {
215
227
run_ignored : config. run_ignored ,
216
228
logfile : copy config. logfile ,
217
229
run_tests : true ,
218
- run_benchmarks : false ,
219
- ratchet_metrics : None ,
220
- ratchet_noise_percent : None ,
221
- save_metrics : None ,
230
+ run_benchmarks : true ,
231
+ ratchet_metrics : copy config . ratchet_metrics ,
232
+ ratchet_noise_percent : copy config . ratchet_noise_percent ,
233
+ save_metrics : copy config . save_metrics ,
222
234
}
223
235
}
224
236
@@ -231,7 +243,13 @@ pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
231
243
let file = copy * file;
232
244
debug ! ( "inspecting file %s" , file. to_str( ) ) ;
233
245
if is_test ( config, file) {
234
- tests. push ( make_test ( config, file) )
246
+ let t = do make_test ( config, file) {
247
+ match config. mode {
248
+ mode_codegen => make_metrics_test_closure ( config, file) ,
249
+ _ => make_test_closure ( config, file)
250
+ }
251
+ } ;
252
+ tests. push ( t)
235
253
}
236
254
}
237
255
tests
@@ -260,14 +278,15 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
260
278
return valid;
261
279
}
262
280
263
- pub fn make_test ( config : & config , testfile : & Path ) -> test:: TestDescAndFn {
281
+ pub fn make_test ( config : & config , testfile : & Path ,
282
+ f : & fn ( ) ->test:: TestFn ) -> test:: TestDescAndFn {
264
283
test:: TestDescAndFn {
265
284
desc : test:: TestDesc {
266
285
name : make_test_name ( config, testfile) ,
267
286
ignore : header:: is_test_ignored ( config, testfile) ,
268
287
should_fail : false
269
288
} ,
270
- testfn : make_test_closure ( config , testfile ) ,
289
+ testfn : f ( ) ,
271
290
}
272
291
}
273
292
@@ -291,3 +310,10 @@ pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn {
291
310
let testfile = Cell :: new ( testfile. to_str ( ) ) ;
292
311
test:: DynTestFn ( || { runtest:: run ( config. take ( ) , testfile. take ( ) ) } )
293
312
}
313
+
314
+ pub fn make_metrics_test_closure ( config : & config , testfile : & Path ) -> test:: TestFn {
315
+ use std:: cell:: Cell ;
316
+ let config = Cell :: new ( copy * config) ;
317
+ let testfile = Cell :: new ( testfile. to_str ( ) ) ;
318
+ test:: DynMetricFn ( |mm| { runtest:: run_metrics ( config. take ( ) , testfile. take ( ) , mm) } )
319
+ }
0 commit comments