Skip to content

Read package:test version from .dart_tool/package_graph.json instead of running dart test --version#5983

Merged
DanTup merged 1 commit intomasterfrom
read-package-graph-for-test-version
Mar 12, 2026
Merged

Read package:test version from .dart_tool/package_graph.json instead of running dart test --version#5983
DanTup merged 1 commit intomasterfrom
read-package-graph-for-test-version

Conversation

@DanTup
Copy link
Member

@DanTup DanTup commented Mar 12, 2026

We currently spawn dart run test:test --version for each package in the workspace to get the test capabilities during test discovery (to know if we can add profiles like Coverage to a given suite). This can be expensive (in terms of CPU and RAM) if the project is large.

For example opening the Dart SDK root on my machine and then clicking the Test Explorer icon results in all RAM being consumed. We already filter out packages in the same Pub Workspace, but there are lots of non-Workspace packages in there.

With this change, we just read the version from the .dart_tool/package_graph.json file instead which is significantly faster and uses little resources.

This also resulted in quite a bit of async code becoming sync.

Fixes #5936

@DanTup DanTup added this to the v3.132.0 milestone Mar 12, 2026
@DanTup DanTup added is bug fix in testing Relates to test execution of Dart/Flutter tests for end users is performance labels Mar 12, 2026
@DanTup DanTup marked this pull request as ready for review March 12, 2026 12:53
@DanTup DanTup requested a review from Copilot March 12, 2026 12:53
@DanTup
Copy link
Member Author

DanTup commented Mar 12, 2026

@codex review

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors how the package:test version is obtained, switching from spawning a dart test --version process to synchronously reading the version from the .dart_tool/package_graph.json file. This is an excellent performance improvement that avoids costly process creation, especially in large workspaces. The change has been propagated correctly, leading to a nice simplification of the codebase by converting several asynchronous functions and call sites to synchronous ones. The new implementation includes appropriate error handling for file I/O and JSON parsing. Overall, the changes are well-implemented and improve both performance and code clarity.

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 75.75758% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.51%. Comparing base (d1d61d7) to head (503fed7).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/shared/test/version.ts 66.66% 6 Missing and 1 partial ⚠️
src/extension/test/vs_test_controller.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5983      +/-   ##
==========================================
- Coverage   67.52%   67.51%   -0.01%     
==========================================
  Files         169      169              
  Lines       12962    12948      -14     
  Branches     2565     2565              
==========================================
- Hits         8752     8742      -10     
+ Misses       3751     3748       -3     
+ Partials      459      458       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

…of running `dart test --version`

We currently spawn `dart run test:test --version` for each package in the workspace to get the test capabilities during test discovery (to know if we can add profiles like Coverage to a given suite). This can be expensive (in terms of CPU and RAM) if the project is large.

For example opening the Dart SDK root on my machine and then clicking the Test Explorer icon results in all RAM being consumed. We already filter out packages in the same Pub Workspace, but there are lots of non-Workspace packages in there.

With this change, we just read the version from the `.dart_tool/package_graph.json` file instead which is significantly faster and uses little resources.

This also resulted in quite a bit of async code becoming sync.

Fixes #5936
@DanTup DanTup force-pushed the read-package-graph-for-test-version branch from 7adbb63 to 503fed7 Compare March 12, 2026 15:55
@DanTup DanTup merged commit f26c02d into master Mar 12, 2026
26 checks passed
@DanTup DanTup deleted the read-package-graph-for-test-version branch March 12, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in testing Relates to test execution of Dart/Flutter tests for end users is bug fix is performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test discovery can spawn huge numbers of "dart run test:test --version" commands, consuming all RAM

2 participants