@@ -165,9 +165,13 @@ pub fn parse_config(args: Vec<String>) -> Config {
165
165
let cdb = analyze_cdb ( matches. opt_str ( "cdb" ) , & target) ;
166
166
let ( gdb, gdb_version, gdb_native_rust) =
167
167
analyze_gdb ( matches. opt_str ( "gdb" ) , & target, & android_cross_path) ;
168
- let ( lldb_version, lldb_native_rust) = extract_lldb_version ( matches. opt_str ( "lldb-version" ) ) ;
169
-
170
- let color = match matches. opt_str ( "color" ) . as_ref ( ) . map ( |x| & * * x) {
168
+ let ( lldb_version, lldb_native_rust) = matches
169
+ . opt_str ( "lldb-version" )
170
+ . as_deref ( )
171
+ . and_then ( extract_lldb_version)
172
+ . map ( |( v, b) | ( Some ( v) , b) )
173
+ . unwrap_or ( ( None , false ) ) ;
174
+ let color = match matches. opt_str ( "color" ) . as_deref ( ) {
171
175
Some ( "auto" ) | None => ColorConfig :: AutoColor ,
172
176
Some ( "always" ) => ColorConfig :: AlwaysColor ,
173
177
Some ( "never" ) => ColorConfig :: NeverColor ,
@@ -251,7 +255,7 @@ pub fn log_config(config: &Config) {
251
255
logv ( c, format ! ( "stage_id: {}" , config. stage_id) ) ;
252
256
logv ( c, format ! ( "mode: {}" , config. mode) ) ;
253
257
logv ( c, format ! ( "run_ignored: {}" , config. run_ignored) ) ;
254
- logv ( c, format ! ( "filter: {}" , opt_str( & config. filter. as_ref ( ) . map ( |re| re . to_owned ( ) ) ) ) ) ;
258
+ logv ( c, format ! ( "filter: {}" , opt_str( & config. filter) ) ) ;
255
259
logv ( c, format ! ( "filter_exact: {}" , config. filter_exact) ) ;
256
260
logv (
257
261
c,
@@ -400,17 +404,14 @@ fn configure_lldb(config: &Config) -> Option<Config> {
400
404
return None ;
401
405
}
402
406
403
- if let Some ( lldb_version) = config. lldb_version . as_ref ( ) {
404
- if lldb_version == "350" {
405
- println ! (
406
- "WARNING: The used version of LLDB ({}) has a \
407
- known issue that breaks debuginfo tests. See \
408
- issue #32520 for more information. Skipping all \
409
- LLDB-based tests!",
410
- lldb_version
411
- ) ;
412
- return None ;
413
- }
407
+ if let Some ( 350 ) = config. lldb_version {
408
+ println ! (
409
+ "WARNING: The used version of LLDB (350) has a \
410
+ known issue that breaks debuginfo tests. See \
411
+ issue #32520 for more information. Skipping all \
412
+ LLDB-based tests!",
413
+ ) ;
414
+ return None ;
414
415
}
415
416
416
417
// Some older versions of LLDB seem to have problems with multiple
@@ -722,9 +723,7 @@ fn make_test_closure(
722
723
let config = config. clone ( ) ;
723
724
let testpaths = testpaths. clone ( ) ;
724
725
let revision = revision. cloned ( ) ;
725
- test:: DynTestFn ( Box :: new ( move || {
726
- runtest:: run ( config, & testpaths, revision. as_ref ( ) . map ( |s| s. as_str ( ) ) )
727
- } ) )
726
+ test:: DynTestFn ( Box :: new ( move || runtest:: run ( config, & testpaths, revision. as_deref ( ) ) ) )
728
727
}
729
728
730
729
/// Returns `true` if the given target is an Android target for the
@@ -840,75 +839,40 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
840
839
// This particular form is documented in the GNU coding standards:
841
840
// https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion
842
841
843
- // don't start parsing in the middle of a number
844
- let mut prev_was_digit = false ;
845
- let mut in_parens = false ;
846
- for ( pos, c) in full_version_line. char_indices ( ) {
847
- if in_parens {
848
- if c == ')' {
849
- in_parens = false ;
850
- }
851
- continue ;
852
- } else if c == '(' {
853
- in_parens = true ;
854
- continue ;
855
- }
856
-
857
- if prev_was_digit || !c. is_digit ( 10 ) {
858
- prev_was_digit = c. is_digit ( 10 ) ;
859
- continue ;
842
+ let mut splits = full_version_line. rsplit ( ' ' ) ;
843
+ let version_string = splits. next ( ) . unwrap ( ) ;
844
+
845
+ let mut splits = version_string. split ( '.' ) ;
846
+ let major = splits. next ( ) . unwrap ( ) ;
847
+ let minor = splits. next ( ) . unwrap ( ) ;
848
+ let patch = splits. next ( ) ;
849
+
850
+ let major: u32 = major. parse ( ) . unwrap ( ) ;
851
+ let ( minor, patch) : ( u32 , u32 ) = match minor. find ( not_a_digit) {
852
+ None => {
853
+ let minor = minor. parse ( ) . unwrap ( ) ;
854
+ let patch: u32 = match patch {
855
+ Some ( patch) => match patch. find ( not_a_digit) {
856
+ None => patch. parse ( ) . unwrap ( ) ,
857
+ Some ( idx) if idx > 3 => 0 ,
858
+ Some ( idx) => patch[ ..idx] . parse ( ) . unwrap ( ) ,
859
+ } ,
860
+ None => 0 ,
861
+ } ;
862
+ ( minor, patch)
860
863
}
861
-
862
- prev_was_digit = true ;
863
-
864
- let line = & full_version_line[ pos..] ;
865
-
866
- let next_split = match line. find ( |c : char | !c. is_digit ( 10 ) ) {
867
- Some ( idx) => idx,
868
- None => continue , // no minor version
869
- } ;
870
-
871
- if line. as_bytes ( ) [ next_split] != b'.' {
872
- continue ; // no minor version
864
+ // There is no patch version after minor-date (e.g. "4-2012").
865
+ Some ( idx) => {
866
+ let minor = minor[ ..idx] . parse ( ) . unwrap ( ) ;
867
+ ( minor, 0 )
873
868
}
869
+ } ;
874
870
875
- let major = & line[ ..next_split] ;
876
- let line = & line[ next_split + 1 ..] ;
877
-
878
- let ( minor, patch) = match line. find ( |c : char | !c. is_digit ( 10 ) ) {
879
- Some ( idx) => {
880
- if line. as_bytes ( ) [ idx] == b'.' {
881
- let patch = & line[ idx + 1 ..] ;
882
-
883
- let patch_len =
884
- patch. find ( |c : char | !c. is_digit ( 10 ) ) . unwrap_or_else ( || patch. len ( ) ) ;
885
- let patch = & patch[ ..patch_len] ;
886
- let patch = if patch_len > 3 || patch_len == 0 { None } else { Some ( patch) } ;
887
-
888
- ( & line[ ..idx] , patch)
889
- } else {
890
- ( & line[ ..idx] , None )
891
- }
892
- }
893
- None => ( line, None ) ,
894
- } ;
895
-
896
- if minor. is_empty ( ) {
897
- continue ;
898
- }
899
-
900
- let major: u32 = major. parse ( ) . unwrap ( ) ;
901
- let minor: u32 = minor. parse ( ) . unwrap ( ) ;
902
- let patch: u32 = patch. unwrap_or ( "0" ) . parse ( ) . unwrap ( ) ;
903
-
904
- return Some ( ( ( major * 1000 ) + minor) * 1000 + patch) ;
905
- }
906
-
907
- None
871
+ Some ( ( ( major * 1000 ) + minor) * 1000 + patch)
908
872
}
909
873
910
874
/// Returns (LLDB version, LLDB is rust-enabled)
911
- fn extract_lldb_version ( full_version_line : Option < String > ) -> ( Option < String > , bool ) {
875
+ fn extract_lldb_version ( full_version_line : & str ) -> Option < ( u32 , bool ) > {
912
876
// Extract the major LLDB version from the given version string.
913
877
// LLDB version strings are different for Apple and non-Apple platforms.
914
878
// The Apple variant looks like this:
@@ -917,7 +881,7 @@ fn extract_lldb_version(full_version_line: Option<String>) -> (Option<String>, b
917
881
// lldb-300.2.51 (new versions)
918
882
//
919
883
// We are only interested in the major version number, so this function
920
- // will return `Some(" 179" )` and `Some(" 300" )` respectively.
884
+ // will return `Some(179)` and `Some(300)` respectively.
921
885
//
922
886
// Upstream versions look like:
923
887
// lldb version 6.0.1
@@ -929,53 +893,24 @@ fn extract_lldb_version(full_version_line: Option<String>) -> (Option<String>, b
929
893
// normally fine because the only non-Apple version we test is
930
894
// rust-enabled.
931
895
932
- if let Some ( ref full_version_line) = full_version_line {
933
- if !full_version_line. trim ( ) . is_empty ( ) {
934
- let full_version_line = full_version_line. trim ( ) ;
935
-
936
- for ( pos, l) in full_version_line. char_indices ( ) {
937
- if l != 'l' && l != 'L' {
938
- continue ;
939
- }
940
- if pos + 5 >= full_version_line. len ( ) {
941
- continue ;
942
- }
943
- let l = full_version_line[ pos + 1 ..] . chars ( ) . next ( ) . unwrap ( ) ;
944
- if l != 'l' && l != 'L' {
945
- continue ;
946
- }
947
- let d = full_version_line[ pos + 2 ..] . chars ( ) . next ( ) . unwrap ( ) ;
948
- if d != 'd' && d != 'D' {
949
- continue ;
950
- }
951
- let b = full_version_line[ pos + 3 ..] . chars ( ) . next ( ) . unwrap ( ) ;
952
- if b != 'b' && b != 'B' {
953
- continue ;
954
- }
955
- let dash = full_version_line[ pos + 4 ..] . chars ( ) . next ( ) . unwrap ( ) ;
956
- if dash != '-' {
957
- continue ;
958
- }
959
-
960
- let vers = full_version_line[ pos + 5 ..]
961
- . chars ( )
962
- . take_while ( |c| c. is_digit ( 10 ) )
963
- . collect :: < String > ( ) ;
964
- if !vers. is_empty ( ) {
965
- return ( Some ( vers) , full_version_line. contains ( "rust-enabled" ) ) ;
966
- }
967
- }
896
+ let full_version_line = full_version_line. trim ( ) ;
968
897
969
- if full_version_line. starts_with ( "lldb version " ) {
970
- let vers = full_version_line[ 13 ..]
971
- . chars ( )
972
- . take_while ( |c| c. is_digit ( 10 ) )
973
- . collect :: < String > ( ) ;
974
- if !vers. is_empty ( ) {
975
- return ( Some ( vers + "00" ) , full_version_line. contains ( "rust-enabled" ) ) ;
976
- }
977
- }
898
+ if let Some ( apple_ver) =
899
+ full_version_line. strip_prefix ( "LLDB-" ) . or_else ( || full_version_line. strip_prefix ( "lldb-" ) )
900
+ {
901
+ if let Some ( idx) = apple_ver. find ( not_a_digit) {
902
+ let version: u32 = apple_ver[ ..idx] . parse ( ) . unwrap ( ) ;
903
+ return Some ( ( version, full_version_line. contains ( "rust-enabled" ) ) ) ;
904
+ }
905
+ } else if let Some ( lldb_ver) = full_version_line. strip_prefix ( "lldb version " ) {
906
+ if let Some ( idx) = lldb_ver. find ( not_a_digit) {
907
+ let version: u32 = lldb_ver[ ..idx] . parse ( ) . unwrap ( ) ;
908
+ return Some ( ( version * 100 , full_version_line. contains ( "rust-enabled" ) ) ) ;
978
909
}
979
910
}
980
- ( None , false )
911
+ None
912
+ }
913
+
914
+ fn not_a_digit ( c : char ) -> bool {
915
+ !c. is_digit ( 10 )
981
916
}
0 commit comments