From 65d8235173f3d3897f36f37b8bcc1535b4ce76ee Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 10 Jan 2025 19:09:30 +0100 Subject: [PATCH] add test case --- .../turbo-tasks-testing/tests/collectibles.rs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/turbopack/crates/turbo-tasks-testing/tests/collectibles.rs b/turbopack/crates/turbo-tasks-testing/tests/collectibles.rs index dd95eb49cc463a..b9ea58654061fc 100644 --- a/turbopack/crates/turbo-tasks-testing/tests/collectibles.rs +++ b/turbopack/crates/turbo-tasks-testing/tests/collectibles.rs @@ -141,6 +141,20 @@ async fn taking_collectibles_parallel() { .unwrap() } +#[tokio::test] +async fn taking_collectibles_with_resolve() { + run(®ISTRATION, || async { + let result_op = my_transitive_emitting_function_with_resolve("resolve".into()); + result_op.connect().strongly_consistent().await?; + let list = result_op.take_collectibles::>(); + assert_eq!(list.len(), 2); + + anyhow::Ok(()) + }) + .await + .unwrap() +} + #[turbo_tasks::value(transparent)] struct Collectibles(AutoSet>>); @@ -225,6 +239,18 @@ async fn my_emitting_function(_key: RcStr) -> Result<()> { Ok(()) } +#[turbo_tasks::function] +async fn my_transitive_emitting_function_with_thing(key: RcStr, _thing: Vc) -> Result<()> { + let _ = my_emitting_function(key); + Ok(()) +} + +#[turbo_tasks::function(operation)] +async fn my_transitive_emitting_function_with_resolve(key: RcStr) -> Result<()> { + let _ = my_transitive_emitting_function_with_thing(key, get_thing(0)); + Ok(()) +} + #[turbo_tasks::value(shared)] struct Thing(u32); @@ -241,3 +267,8 @@ impl ValueToString for Thing { Vc::cell(self.0.to_string().into()) } } + +#[turbo_tasks::function] +fn get_thing(v: u32) -> Vc { + Thing::cell(Thing(v)) +}