Skip to content

Commit 823685a

Browse files
authored
Turbopack: fix race condition in unit test (#84085)
### What? Turbo Task functions are executed when they are called. Not awaiting them will still execute them, but makes it a race condition if the stats or the execution is faster.
1 parent 3a5227b commit 823685a

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

turbopack/crates/turbo-tasks-backend/tests/task_statistics.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,33 @@ async fn test_dyn_trait_methods() -> Result<()> {
178178
async fn test_no_execution() -> Result<()> {
179179
run_without_cache_check(&REGISTRATION, async move {
180180
enable_stats();
181-
// don't await this!
182-
let _ = wrap_vc(double_vc(double(123))).double().double_vc();
181+
wrap_vc(double_vc(double(123)))
182+
.double()
183+
.double_vc()
184+
.as_side_effect()
185+
.await?;
183186
assert_eq!(
184187
stats_json(),
185188
json!({
186-
"double": {
187-
"cache_miss": 1,
189+
"WrappedU64::Doublable::double": {
190+
"cache_hit": 0,
191+
"cache_miss": 1
192+
},
193+
"WrappedU64::Doublable::double_vc": {
194+
"cache_hit": 0,
195+
"cache_miss": 1
196+
},
197+
"double": {
198+
"cache_hit": 0,
199+
"cache_miss": 1
200+
},
201+
"double_vc": {
202+
"cache_hit": 0,
203+
"cache_miss": 1
204+
},
205+
"wrap_vc": {
188206
"cache_hit": 0,
207+
"cache_miss": 1
189208
},
190209
})
191210
);

0 commit comments

Comments
 (0)