@@ -869,6 +869,66 @@ fn bisect(cfg: &Config, client: &Client) -> Result<(), Error> {
869
869
Ok ( ( ) )
870
870
}
871
871
872
+ struct NightlyFinderIter {
873
+ start_date : Date < Utc > ,
874
+ current_date : Date < Utc > ,
875
+ }
876
+
877
+ impl NightlyFinderIter {
878
+ fn new ( start_date : Date < Utc > ) -> Self {
879
+ Self {
880
+ start_date,
881
+ current_date : start_date,
882
+ }
883
+ }
884
+ }
885
+
886
+ impl Iterator for NightlyFinderIter {
887
+ type Item = Date < Utc > ;
888
+
889
+ fn next ( & mut self ) -> Option < Date < Utc > > {
890
+ let current_distance = self . start_date - self . current_date ;
891
+
892
+ let jump_length =
893
+ if current_distance. num_days ( ) < 7 {
894
+ // first week jump by two days
895
+ 2
896
+ } else if current_distance. num_days ( ) < 49 {
897
+ // from 2nd to 7th week jump weekly
898
+ 7
899
+ } else {
900
+ // from 7th week jump by two weeks
901
+ 14
902
+ } ;
903
+
904
+ self . current_date = self . current_date - chrono:: Duration :: days ( jump_length) ;
905
+ Some ( self . current_date )
906
+ }
907
+ }
908
+
909
+ #[ test]
910
+ fn test_nightly_finder_iterator ( ) {
911
+ let start_date = chrono:: Date :: from_utc (
912
+ chrono:: naive:: NaiveDate :: from_ymd ( 2019 , 01 , 01 ) ,
913
+ chrono:: Utc ,
914
+ ) ;
915
+
916
+ let mut iter = NightlyFinderIter :: new ( start_date) ;
917
+
918
+ assert_eq ! ( start_date - chrono:: Duration :: days( 2 ) , iter. next( ) . unwrap( ) ) ;
919
+ assert_eq ! ( start_date - chrono:: Duration :: days( 4 ) , iter. next( ) . unwrap( ) ) ;
920
+ assert_eq ! ( start_date - chrono:: Duration :: days( 6 ) , iter. next( ) . unwrap( ) ) ;
921
+ assert_eq ! ( start_date - chrono:: Duration :: days( 8 ) , iter. next( ) . unwrap( ) ) ;
922
+ assert_eq ! ( start_date - chrono:: Duration :: days( 15 ) , iter. next( ) . unwrap( ) ) ;
923
+ assert_eq ! ( start_date - chrono:: Duration :: days( 22 ) , iter. next( ) . unwrap( ) ) ;
924
+ assert_eq ! ( start_date - chrono:: Duration :: days( 29 ) , iter. next( ) . unwrap( ) ) ;
925
+ assert_eq ! ( start_date - chrono:: Duration :: days( 36 ) , iter. next( ) . unwrap( ) ) ;
926
+ assert_eq ! ( start_date - chrono:: Duration :: days( 43 ) , iter. next( ) . unwrap( ) ) ;
927
+ assert_eq ! ( start_date - chrono:: Duration :: days( 50 ) , iter. next( ) . unwrap( ) ) ;
928
+ assert_eq ! ( start_date - chrono:: Duration :: days( 64 ) , iter. next( ) . unwrap( ) ) ;
929
+ assert_eq ! ( start_date - chrono:: Duration :: days( 78 ) , iter. next( ) . unwrap( ) ) ;
930
+ }
931
+
872
932
fn bisect_nightlies ( cfg : & Config , client : & Client ) -> Result < BisectionResult , Error > {
873
933
if cfg. args . alt {
874
934
bail ! ( "cannot bisect nightlies with --alt: not supported" ) ;
@@ -883,7 +943,6 @@ fn bisect_nightlies(cfg: &Config, client: &Client) -> Result<BisectionResult, Er
883
943
( today, false )
884
944
} ;
885
945
886
- let mut jump_length = 1 ;
887
946
// before this date we didn't have -std packages
888
947
let end_at = chrono:: Date :: from_utc (
889
948
chrono:: naive:: NaiveDate :: from_ymd ( 2015 , 10 , 20 ) ,
@@ -905,6 +964,8 @@ fn bisect_nightlies(cfg: &Config, client: &Client) -> Result<BisectionResult, Er
905
964
}
906
965
} ;
907
966
967
+ let mut nightly_iter = NightlyFinderIter :: new ( nightly_date) ;
968
+
908
969
while nightly_date > end_at {
909
970
let mut t = Toolchain {
910
971
spec : ToolchainSpec :: Nightly { date : nightly_date } ,
@@ -930,10 +991,9 @@ fn bisect_nightlies(cfg: &Config, client: &Client) -> Result<BisectionResult, Er
930
991
} else {
931
992
last_failure = nightly_date;
932
993
}
933
- nightly_date = nightly_date - chrono:: Duration :: days ( jump_length) ;
934
- if jump_length < 30 {
935
- jump_length *= 2 ;
936
- }
994
+
995
+ nightly_date = nightly_iter. next ( ) . unwrap ( ) ;
996
+
937
997
if !cfg. args . preserve {
938
998
let _ = t. remove ( & dl_spec) ;
939
999
}
0 commit comments