1
1
use std:: cmp:: Ordering ;
2
2
use std:: collections:: { HashMap , HashSet } ;
3
- use std:: env;
4
3
use std:: ops:: Range ;
5
4
use std:: rc:: Rc ;
6
5
use std:: time:: { Duration , Instant } ;
@@ -20,6 +19,8 @@ pub struct ResolverProgress {
20
19
time_to_print : Duration ,
21
20
printed : bool ,
22
21
deps_time : Duration ,
22
+ #[ cfg( debug_assertions) ]
23
+ slow_cpu_multiplier : u64 ,
23
24
}
24
25
25
26
impl ResolverProgress {
@@ -30,6 +31,14 @@ impl ResolverProgress {
30
31
time_to_print : Duration :: from_millis ( 500 ) ,
31
32
printed : false ,
32
33
deps_time : Duration :: new ( 0 , 0 ) ,
34
+ // Some CI setups are much slower then the equipment used by Cargo itself.
35
+ // Architectures that do not have a modern processor, hardware emulation, ect.
36
+ // In the test code we have `slow_cpu_multiplier`, but that is not accessible here.
37
+ #[ cfg( debug_assertions) ]
38
+ slow_cpu_multiplier : std:: env:: var ( "CARGO_TEST_SLOW_CPU_MULTIPLIER" )
39
+ . ok ( )
40
+ . and_then ( |m| m. parse ( ) . ok ( ) )
41
+ . unwrap_or ( 1 ) ,
33
42
}
34
43
}
35
44
pub fn shell_status ( & mut self , config : Option < & Config > ) -> CargoResult < ( ) > {
@@ -53,31 +62,27 @@ impl ResolverProgress {
53
62
config. shell ( ) . status ( "Resolving" , "dependency graph..." ) ?;
54
63
}
55
64
}
56
- // The largest test in our suite takes less then 5000 ticks
57
- // with all the algorithm improvements.
58
- // If any of them are removed then it takes more than I am willing to measure.
59
- // So lets fail the test fast if we have ben running for two long.
60
- debug_assert ! (
61
- self . ticks < 50_000 ,
62
- "got to 50_000 ticks in {:?}" ,
63
- self . start. elapsed( )
64
- ) ;
65
- // The largest test in our suite takes less then 30 sec
66
- // with all the improvements to how fast a tick can go.
67
- // If any of them are removed then it takes more than I am willing to measure.
68
- // So lets fail the test fast if we have ben running for two long.
69
- if cfg ! ( debug_assertions) && ( self . ticks % 1000 == 0 ) {
70
- // Some CI setups are much slower then the equipment used by Cargo itself.
71
- // Architectures that do not have a modern processor, hardware emulation, ect.
72
- // In the test code we have `slow_cpu_multiplier`, but that is not accessible here.
73
- lazy_static:: lazy_static! {
74
- static ref SLOW_CPU_MULTIPLIER : u64 =
75
- env:: var( "CARGO_TEST_SLOW_CPU_MULTIPLIER" ) . ok( ) . and_then( |m| m. parse( ) . ok( ) ) . unwrap_or( 1 ) ;
76
- }
65
+ #[ cfg( debug_assertions) ]
66
+ {
67
+ // The largest test in our suite takes less then 5000 ticks
68
+ // with all the algorithm improvements.
69
+ // If any of them are removed then it takes more than I am willing to measure.
70
+ // So lets fail the test fast if we have ben running for two long.
77
71
assert ! (
78
- self . start. elapsed( ) - self . deps_time
79
- < Duration :: from_secs( * SLOW_CPU_MULTIPLIER * 90 )
72
+ self . ticks < 50_000 ,
73
+ "got to 50_000 ticks in {:?}" ,
74
+ self . start. elapsed( )
80
75
) ;
76
+ // The largest test in our suite takes less then 30 sec
77
+ // with all the improvements to how fast a tick can go.
78
+ // If any of them are removed then it takes more than I am willing to measure.
79
+ // So lets fail the test fast if we have ben running for two long.
80
+ if self . ticks % 1000 == 0 {
81
+ assert ! (
82
+ self . start. elapsed( ) - self . deps_time
83
+ < Duration :: from_secs( self . slow_cpu_multiplier * 90 )
84
+ ) ;
85
+ }
81
86
}
82
87
Ok ( ( ) )
83
88
}
0 commit comments