1313#![ feature( slicing_syntax, unboxed_closures) ]
1414#![ feature( box_syntax) ]
1515#![ feature( int_uint) ]
16+ #![ feature( test) ]
17+ #![ feature( rustc_private) ]
18+ #![ feature( std_misc) ]
19+ #![ feature( path) ]
20+ #![ feature( io) ]
21+ #![ feature( core) ]
22+ #![ feature( collections) ]
23+ #![ feature( os) ]
24+ #![ feature( unicode) ]
1625
1726#![ deny( warnings) ]
1827
@@ -21,7 +30,6 @@ extern crate getopts;
2130
2231#[ macro_use]
2332extern crate log;
24- extern crate regex;
2533
2634use std:: os;
2735use std:: io;
@@ -32,7 +40,6 @@ use getopts::{optopt, optflag, reqopt};
3240use common:: Config ;
3341use common:: { Pretty , DebugInfoGdb , DebugInfoLldb , Codegen } ;
3442use util:: logv;
35- use regex:: Regex ;
3643
3744pub mod procsrv;
3845pub mod util;
@@ -76,10 +83,6 @@ pub fn parse_config(args: Vec<String> ) -> Config {
7683 optopt( "" , "target-rustcflags" , "flags to pass to rustc for target" , "FLAGS" ) ,
7784 optflag( "" , "verbose" , "run tests verbosely, showing all output" ) ,
7885 optopt( "" , "logfile" , "file to log test execution to" , "FILE" ) ,
79- optopt( "" , "save-metrics" , "file to save metrics to" , "FILE" ) ,
80- optopt( "" , "ratchet-metrics" , "file to ratchet metrics against" , "FILE" ) ,
81- optopt( "" , "ratchet-noise-percent" ,
82- "percent change in metrics to consider noise" , "N" ) ,
8386 optflag( "" , "jit" , "run tests under the JIT" ) ,
8487 optopt( "" , "target" , "the target to build for" , "TARGET" ) ,
8588 optopt( "" , "host" , "the host to build for" , "HOST" ) ,
@@ -89,7 +92,6 @@ pub fn parse_config(args: Vec<String> ) -> Config {
8992 optopt( "" , "adb-path" , "path to the android debugger" , "PATH" ) ,
9093 optopt( "" , "adb-test-dir" , "path to tests for the android debugger" , "PATH" ) ,
9194 optopt( "" , "lldb-python-dir" , "directory containing LLDB's python module" , "PATH" ) ,
92- optopt( "" , "test-shard" , "run shard A, of B shards, worth of the testsuite" , "A.B" ) ,
9395 optflag( "h" , "help" , "show this message" ) ) ;
9496
9597 assert ! ( !args. is_empty( ) ) ;
@@ -120,14 +122,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
120122 }
121123
122124 let filter = if !matches. free . is_empty ( ) {
123- let s = matches. free [ 0 ] . as_slice ( ) ;
124- match regex:: Regex :: new ( s) {
125- Ok ( re) => Some ( re) ,
126- Err ( e) => {
127- println ! ( "failed to parse filter /{}/: {:?}" , s, e) ;
128- panic ! ( )
129- }
130- }
125+ Some ( matches. free [ 0 ] . clone ( ) )
131126 } else {
132127 None
133128 } ;
@@ -149,14 +144,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
149144 . as_slice ( ) ) . expect ( "invalid mode" ) ,
150145 run_ignored : matches. opt_present ( "ignored" ) ,
151146 filter : filter,
152- cfail_regex : Regex :: new ( errors:: EXPECTED_PATTERN ) . unwrap ( ) ,
153147 logfile : matches. opt_str ( "logfile" ) . map ( |s| Path :: new ( s) ) ,
154- save_metrics : matches. opt_str ( "save-metrics" ) . map ( |s| Path :: new ( s) ) ,
155- ratchet_metrics :
156- matches. opt_str ( "ratchet-metrics" ) . map ( |s| Path :: new ( s) ) ,
157- ratchet_noise_percent :
158- matches. opt_str ( "ratchet-noise-percent" )
159- . and_then ( |s| s. as_slice ( ) . parse :: < f64 > ( ) ) ,
160148 runtool : matches. opt_str ( "runtool" ) ,
161149 host_rustcflags : matches. opt_str ( "host-rustcflags" ) ,
162150 target_rustcflags : matches. opt_str ( "target-rustcflags" ) ,
@@ -175,7 +163,6 @@ pub fn parse_config(args: Vec<String> ) -> Config {
175163 opt_str2 ( matches. opt_str ( "adb-test-dir" ) ) . as_slice ( ) &&
176164 !opt_str2 ( matches. opt_str ( "adb-test-dir" ) ) . is_empty ( ) ,
177165 lldb_python_dir : matches. opt_str ( "lldb-python-dir" ) ,
178- test_shard : test:: opt_shard ( matches. opt_str ( "test-shard" ) ) ,
179166 verbose : matches. opt_present ( "verbose" ) ,
180167 }
181168}
@@ -209,10 +196,6 @@ pub fn log_config(config: &Config) {
209196 logv ( c, format ! ( "adb_test_dir: {:?}" , config. adb_test_dir) ) ;
210197 logv ( c, format ! ( "adb_device_status: {}" ,
211198 config. adb_device_status) ) ;
212- match config. test_shard {
213- None => logv ( c, "test_shard: (all)" . to_string ( ) ) ,
214- Some ( ( a, b) ) => logv ( c, format ! ( "test_shard: {}.{}" , a, b) )
215- }
216199 logv ( c, format ! ( "verbose: {}" , config. verbose) ) ;
217200 logv ( c, format ! ( "\n " ) ) ;
218201}
@@ -263,6 +246,9 @@ pub fn run_tests(config: &Config) {
263246 // parallel (especially when we have lots and lots of child processes).
264247 // For context, see #8904
265248 io:: test:: raise_fd_limit ( ) ;
249+ // Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
250+ // If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
251+ os:: setenv ( "__COMPAT_LAYER" , "RunAsInvoker" ) ;
266252 let res = test:: run_tests_console ( & opts, tests. into_iter ( ) . collect ( ) ) ;
267253 match res {
268254 Ok ( true ) => { }
@@ -283,15 +269,8 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
283269 logfile : config. logfile . clone ( ) ,
284270 run_tests : true ,
285271 run_benchmarks : true ,
286- ratchet_metrics : config. ratchet_metrics . clone ( ) ,
287- ratchet_noise_percent : config. ratchet_noise_percent . clone ( ) ,
288- save_metrics : config. save_metrics . clone ( ) ,
289- test_shard : config. test_shard . clone ( ) ,
290272 nocapture : false ,
291273 color : test:: AutoColor ,
292- show_boxplot : false ,
293- boxplot_width : 50 ,
294- show_all_stats : false ,
295274 }
296275}
297276
@@ -393,18 +372,24 @@ fn extract_gdb_version(full_version_line: Option<String>) -> Option<String> {
393372 if full_version_line. as_slice ( ) . trim ( ) . len ( ) > 0 => {
394373 let full_version_line = full_version_line. as_slice ( ) . trim ( ) ;
395374
396- let re = Regex :: new ( r"(^|[^0-9])([0-9]\.[0-9])([^0-9]|$)" ) . unwrap ( ) ;
397-
398- match re. captures ( full_version_line) {
399- Some ( captures) => {
400- Some ( captures. at ( 2 ) . unwrap_or ( "" ) . to_string ( ) )
375+ // used to be a regex "(^|[^0-9])([0-9]\.[0-9])([^0-9]|$)"
376+ for ( pos, c) in full_version_line. char_indices ( ) {
377+ if !c. is_digit ( 10 ) { continue }
378+ if pos + 2 >= full_version_line. len ( ) { continue }
379+ if full_version_line. char_at ( pos + 1 ) != '.' { continue }
380+ if !full_version_line. char_at ( pos + 2 ) . is_digit ( 10 ) { continue }
381+ if pos > 0 && full_version_line. char_at_reverse ( pos) . is_digit ( 10 ) {
382+ continue
401383 }
402- None => {
403- println ! ( "Could not extract GDB version from line '{}'" ,
404- full_version_line) ;
405- None
384+ if pos + 3 < full_version_line. len ( ) &&
385+ full_version_line. char_at ( pos + 3 ) . is_digit ( 10 ) {
386+ continue
406387 }
388+ return Some ( full_version_line[ pos..pos+3 ] . to_string ( ) ) ;
407389 }
390+ println ! ( "Could not extract GDB version from line '{}'" ,
391+ full_version_line) ;
392+ None
408393 } ,
409394 _ => None
410395 }
@@ -427,18 +412,26 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
427412 if full_version_line. as_slice ( ) . trim ( ) . len ( ) > 0 => {
428413 let full_version_line = full_version_line. as_slice ( ) . trim ( ) ;
429414
430- let re = Regex :: new ( r"[Ll][Ll][Dd][Bb]-([0-9]+)" ) . unwrap ( ) ;
431-
432- match re. captures ( full_version_line) {
433- Some ( captures) => {
434- Some ( captures. at ( 1 ) . unwrap_or ( "" ) . to_string ( ) )
435- }
436- None => {
437- println ! ( "Could not extract LLDB version from line '{}'" ,
438- full_version_line) ;
439- None
440- }
415+ for ( pos, l) in full_version_line. char_indices ( ) {
416+ if l != 'l' && l != 'L' { continue }
417+ if pos + 5 >= full_version_line. len ( ) { continue }
418+ let l = full_version_line. char_at ( pos + 1 ) ;
419+ if l != 'l' && l != 'L' { continue }
420+ let d = full_version_line. char_at ( pos + 2 ) ;
421+ if d != 'd' && d != 'D' { continue }
422+ let b = full_version_line. char_at ( pos + 3 ) ;
423+ if b != 'b' && b != 'B' { continue }
424+ let dash = full_version_line. char_at ( pos + 4 ) ;
425+ if dash != '-' { continue }
426+
427+ let vers = full_version_line[ pos + 5 ..] . chars ( ) . take_while ( |c| {
428+ c. is_digit ( 10 )
429+ } ) . collect :: < String > ( ) ;
430+ if vers. len ( ) > 0 { return Some ( vers) }
441431 }
432+ println ! ( "Could not extract LLDB version from line '{}'" ,
433+ full_version_line) ;
434+ None
442435 } ,
443436 _ => None
444437 }
0 commit comments