Skip to content

Commit 33d2cd3

Browse files
Paolo TranquilliCopilot
andcommitted
Rust: Test that dropping loaded workspaces waits for a background load
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8d0772f66a6b42c7b59d25b5e8f4073d
1 parent bf84d0e commit 33d2cd3

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎rust/extractor/src/workspaces.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,21 @@ mod tests {
227227
drop(loaded);
228228
assert_eq!(stats.live.load(Ordering::SeqCst), 0);
229229
}
230+
231+
#[test]
232+
fn drop_waits_for_background_load() {
233+
let (stats, release) = stats();
234+
let [a, b] = &manifests(["a", "b"]);
235+
let mut loaded = LoadedWorkspaces::new(true, loader(&stats));
236+
assert!(loaded.get(a, Some(b), &mut Vec::new()).is_some());
237+
let releaser = std::thread::spawn(move || {
238+
std::thread::sleep(Duration::from_millis(100));
239+
release.send(()).unwrap();
240+
});
241+
drop(loaded);
242+
assert_eq!(*stats.loads.lock().unwrap(), ["a", "b (background)"]);
243+
assert_eq!(stats.peak.load(Ordering::SeqCst), 2);
244+
assert_eq!(stats.live.load(Ordering::SeqCst), 0);
245+
releaser.join().unwrap();
246+
}
230247
}

0 commit comments

Comments
 (0)