@@ -19,6 +19,7 @@ extern mod extra;
19
19
use std:: os;
20
20
21
21
use extra:: getopts;
22
+ use extra:: getopts:: groups:: { optopt, optflag, reqopt} ;
22
23
use extra:: test;
23
24
24
25
use common:: config;
@@ -27,6 +28,7 @@ use common::mode_run_fail;
27
28
use common:: mode_compile_fail;
28
29
use common:: mode_pretty;
29
30
use common:: mode_debug_info;
31
+ use common:: mode_codegen;
30
32
use common:: mode;
31
33
use util:: logv;
32
34
@@ -45,31 +47,54 @@ pub fn main() {
45
47
}
46
48
47
49
pub fn parse_config ( args : ~[ ~str ] ) -> config {
48
- let opts =
49
- ~[ getopts:: reqopt ( "compile-lib-path" ) ,
50
- getopts:: reqopt ( "run-lib-path" ) ,
51
- getopts:: reqopt ( "rustc-path" ) , getopts:: reqopt ( "src-base" ) ,
52
- getopts:: reqopt ( "build-base" ) , getopts:: reqopt ( "aux-base" ) ,
53
- getopts:: reqopt ( "stage-id" ) ,
54
- getopts:: reqopt ( "mode" ) , getopts:: optflag ( "ignored" ) ,
55
- getopts:: optopt ( "runtool" ) , getopts:: optopt ( "rustcflags" ) ,
56
- getopts:: optflag ( "verbose" ) ,
57
- getopts:: optopt ( "logfile" ) ,
58
- getopts:: optflag ( "jit" ) ,
59
- getopts:: optflag ( "newrt" ) ,
60
- getopts:: optopt ( "target" ) ,
61
- getopts:: optopt ( "adb-path" ) ,
62
- getopts:: optopt ( "adb-test-dir" )
50
+
51
+ let groups : ~[ getopts:: groups:: OptGroup ] =
52
+ ~[ reqopt ( "" , "compile-lib-path" , "path to host shared libraries" , "PATH" ) ,
53
+ reqopt ( "" , "run-lib-path" , "path to target shared libraries" , "PATH" ) ,
54
+ reqopt ( "" , "rustc-path" , "path to rustc to use for compiling" , "PATH" ) ,
55
+ optopt ( "" , "clang-path" , "path to executable for codegen tests" , "PATH" ) ,
56
+ optopt ( "" , "llvm-bin-path" , "path to directory holding llvm binaries" , "DIR" ) ,
57
+ reqopt ( "" , "src-base" , "directory to scan for test files" , "PATH" ) ,
58
+ reqopt ( "" , "build-base" , "directory to deposit test outputs" , "PATH" ) ,
59
+ reqopt ( "" , "aux-base" , "directory to find auxiliary test files" , "PATH" ) ,
60
+ reqopt ( "" , "stage-id" , "the target-stage identifier" , "stageN-TARGET" ) ,
61
+ reqopt ( "" , "mode" , "which sort of compile tests to run" ,
62
+ "(compile-fail|run-fail|run-pass|pretty|debug-info)" ) ,
63
+ optflag ( "" , "ignored" , "run tests marked as ignored / xfailed" ) ,
64
+ optopt ( "" , "runtool" , "supervisor program to run tests under \
65
+ (eg. emulator, valgrind)", "PROGRAM" ) ,
66
+ optopt ( "" , "rustcflags" , "flags to pass to rustc" , "FLAGS" ) ,
67
+ optflag ( "" , "verbose" , "run tests verbosely, showing all output" ) ,
68
+ optopt ( "" , "logfile" , "file to log test execution to" , "FILE" ) ,
69
+ optflag ( "" , "jit" , "run tests under the JIT" ) ,
70
+ optflag ( "" , "newrt" , "run tests on the new runtime / scheduler" ) ,
71
+ optopt ( "" , "target" , "the target to build for" , "TARGET" ) ,
72
+ optopt ( "" , "adb-path" , "path to the android debugger" , "PATH" ) ,
73
+ optopt ( "" , "adb-test-dir" , "path to tests for the android debugger" , "PATH" ) ,
74
+ optflag ( "h" , "help" , "show this message" ) ,
63
75
] ;
64
76
65
77
assert ! ( !args. is_empty( ) ) ;
78
+ let argv0 = copy args[ 0 ] ;
66
79
let args_ = args. tail ( ) ;
80
+ if args[ 1 ] == ~"-h" || args[ 1 ] == ~"--help" {
81
+ let message = fmt ! ( "Usage: %s [OPTIONS] [TESTNAME...]" , argv0) ;
82
+ println ( getopts:: groups:: usage ( message, groups) ) ;
83
+ fail ! ( )
84
+ }
85
+
67
86
let matches =
68
- & match getopts:: getopts ( args_, opts ) {
87
+ & match getopts:: groups :: getopts ( args_, groups ) {
69
88
Ok ( m) => m,
70
89
Err ( f) => fail ! ( getopts:: fail_str( f) )
71
90
} ;
72
91
92
+ if getopts:: opt_present ( matches, "h" ) || getopts:: opt_present ( matches, "help" ) {
93
+ let message = fmt ! ( "Usage: %s [OPTIONS] [TESTNAME...]" , argv0) ;
94
+ println ( getopts:: groups:: usage ( message, groups) ) ;
95
+ fail ! ( )
96
+ }
97
+
73
98
fn opt_path ( m : & getopts:: Matches , nm : & str ) -> Path {
74
99
Path ( getopts:: opt_str ( m, nm) )
75
100
}
@@ -78,6 +103,8 @@ pub fn parse_config(args: ~[~str]) -> config {
78
103
compile_lib_path : getopts:: opt_str ( matches, "compile-lib-path" ) ,
79
104
run_lib_path : getopts:: opt_str ( matches, "run-lib-path" ) ,
80
105
rustc_path : opt_path ( matches, "rustc-path" ) ,
106
+ clang_path : getopts:: opt_maybe_str ( matches, "clang-path" ) . map ( |s| Path ( * s) ) ,
107
+ llvm_bin_path : getopts:: opt_maybe_str ( matches, "llvm-bin-path" ) . map ( |s| Path ( * s) ) ,
81
108
src_base : opt_path ( matches, "src-base" ) ,
82
109
build_base : opt_path ( matches, "build-base" ) ,
83
110
aux_base : opt_path ( matches, "aux-base" ) ,
@@ -159,6 +186,7 @@ pub fn str_mode(s: ~str) -> mode {
159
186
~"run-pass" => mode_run_pass,
160
187
~"pretty" => mode_pretty,
161
188
~"debug-info" => mode_debug_info,
189
+ ~"codegen" => mode_codegen,
162
190
_ => fail ! ( "invalid mode" )
163
191
}
164
192
}
@@ -170,6 +198,7 @@ pub fn mode_str(mode: mode) -> ~str {
170
198
mode_run_pass => ~"run-pass",
171
199
mode_pretty => ~"pretty",
172
200
mode_debug_info => ~"debug-info",
201
+ mode_codegen => ~"codegen",
173
202
}
174
203
}
175
204
@@ -187,8 +216,9 @@ pub fn test_opts(config: &config) -> test::TestOpts {
187
216
logfile : copy config. logfile ,
188
217
run_tests : true ,
189
218
run_benchmarks : false ,
190
- save_results : None ,
191
- compare_results : None
219
+ ratchet_metrics : None ,
220
+ ratchet_noise_percent : None ,
221
+ save_metrics : None ,
192
222
}
193
223
}
194
224
0 commit comments