Skip to content

Commit 7332f67

Browse files
committed
remove a lazy_static
1 parent c0943ce commit 7332f67

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

src/cargo/core/resolver/types.rs

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::cmp::Ordering;
22
use std::collections::{HashMap, HashSet};
3-
use std::env;
43
use std::ops::Range;
54
use std::rc::Rc;
65
use std::time::{Duration, Instant};
@@ -20,6 +19,8 @@ pub struct ResolverProgress {
2019
time_to_print: Duration,
2120
printed: bool,
2221
deps_time: Duration,
22+
#[cfg(debug_assertions)]
23+
slow_cpu_multiplier: u64,
2324
}
2425

2526
impl ResolverProgress {
@@ -30,6 +31,14 @@ impl ResolverProgress {
3031
time_to_print: Duration::from_millis(500),
3132
printed: false,
3233
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),
3342
}
3443
}
3544
pub fn shell_status(&mut self, config: Option<&Config>) -> CargoResult<()> {
@@ -53,31 +62,27 @@ impl ResolverProgress {
5362
config.shell().status("Resolving", "dependency graph...")?;
5463
}
5564
}
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.
7771
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()
8075
);
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+
}
8186
}
8287
Ok(())
8388
}

0 commit comments

Comments
 (0)