From 30893f54fae309593474ed3acf9582c57c6ed3af Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:44:53 +0100 Subject: [PATCH] Cleanup --- .../crates/turbopack-tests/tests/snapshot.rs | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/turbopack/crates/turbopack-tests/tests/snapshot.rs b/turbopack/crates/turbopack-tests/tests/snapshot.rs index b5c408147a4d7..f47fc6dd24ef3 100644 --- a/turbopack/crates/turbopack-tests/tests/snapshot.rs +++ b/turbopack/crates/turbopack-tests/tests/snapshot.rs @@ -46,7 +46,7 @@ use turbopack_core::{ environment::{BrowserEnvironment, Environment, ExecutionEnvironment, NodeJsEnvironment}, file_source::FileSource, free_var_references, - issue::{Issue, IssueDescriptionExt}, + issue::{Issue, IssueDescriptionExt, PlainIssue}, module::Module, output::{OutputAsset, OutputAssets}, reference_type::{EntryReferenceSubType, ReferenceType}, @@ -158,8 +158,15 @@ async fn run(resource: PathBuf) -> Result<()> { let tt = TurboTasks::new(MemoryBackend::default()); let task = tt.spawn_once_task(async move { let out = run_test(resource.to_str().unwrap().into()); + let _ = out.resolve_strongly_consistent().await?; + let captured_issues = out.peek_issues_with_path().await?; - let emit = snapshot_issues(out); + let plain_issues = captured_issues + .iter_with_shortest_path() + .map(|(issue_vc, path)| issue_vc.into_plain(path)) + .collect(); + + let emit = snapshot_issues(plain_issues, out); emit.strongly_consistent() .await .context("Unable to handle issues")?; @@ -175,17 +182,16 @@ async fn run(resource: PathBuf) -> Result<()> { // a wrapper to make the snapshot_issues function a turbo task #[turbo_tasks::function] -async fn snapshot_issues(test_output: Vc) -> Result<()> { - let _ = test_output.resolve_strongly_consistent().await?; - let captured_issues = test_output.peek_issues_with_path().await?; - - let plain_issues = captured_issues - .iter_with_shortest_path() - .map(|(issue_vc, path)| async move { issue_vc.into_plain(path).await }) - .try_join() - .await?; - - snapshot::snapshot_issues(plain_issues, test_output.join("issues".into()), &REPO_ROOT).await +async fn snapshot_issues( + plain_issues: Vec>, + test_output: Vc, +) -> Result<()> { + snapshot::snapshot_issues( + plain_issues.iter().try_join().await?, + test_output.join("issues".into()), + &REPO_ROOT, + ) + .await } #[turbo_tasks::function]