Give this file to your coding agent. It explains the problem, checks your machine, and asks you how you want to handle it. It changes nothing until you choose.
dart test and flutter test compile each test file to a kernel (.dill) file in the system temp folder. Two things make that folder grow:
- Growth during a run (
dart test). Inpackage:test1.32 and earlier (test_core0.6.20 and earlier), the runner keeps every kernel file until the whole run ends. Each one can be 20–30 MiB. A package with 200 test files can hold 7 GiB or more while it runs. Several agents or worktrees running tests at once multiply this. Fixed intest1.33.0 (test_core0.6.21). Seedart-lang/test#2710 . - Leftovers after a killed run (
dart testandflutter test). Both delete their temp folder when a run finishes, and on Ctrl-C or SIGTERM. Neither cleans up after SIGHUP (the terminal or agent session closed) or SIGKILL (force kill, for example after a timeout). Later runs do not remove these folders. Seedart-lang/test#2711 andflutter/flutter#84094 .
| How the run stopped | dart test |
flutter test |
|---|---|---|
| Finished, Ctrl-C or SIGTERM | Cleaned up | Cleaned up |
| Session closed (SIGHUP) | dart_test.* left |
flutter_tools.* left |
| Force kill (SIGKILL) | dart_test.* left |
flutter_tools.* left |
Why you may not have the fix yet. In a pub workspace that includes a Flutter package, flutter_test pins test_api to an exact version, which caps package:test:
| Flutter | Newest test |
Has fix 1? |
|---|---|---|
| 3.50 and earlier | 1.32.x or older | No |
| 3.51 and later | 1.33.0+ | Yes |
Pure Dart packages outside a Flutter workspace can use test: ^1.33.0 now. Never override test_api to get the fix early.
Do not create, edit or delete anything in this step. Report:
- OS and where the system temp folder is (macOS:
getconf DARWIN_USER_TEMP_DIR; Linux:$TMPDIRor/tmp; Windows:%TEMP%), and how much free space that drive has. - Any
dart_test.*andflutter_tools.*folders there: count, total size, newest change time, and whether a running process still uses them. - For the current project, the resolved
test_coreversion (pubspec.lock) and Flutter version, and whether it has fix 1. - Which shells and agents the person uses, and whether any agent runs in a sandbox that limits where it can write.
- Other drives with more free space, if any.
Show the diagnosis, then offer only the options that fit this machine. Say what each changes and what it does not cover. Wait for the person to choose. They may choose several or none.
- A. Clean up now. Remove leftover folders that nothing is using and that have not changed recently. Show the list and get a yes first.
- B. Upgrade
package:test. Only if the Flutter pin allowstest1.33.0 or later. Fixes growth during a run, not leftovers. - C. Move the temp folder to a larger drive. Set
TMPDIRin a file every shell reads. Keep a fallback for when the drive is not mounted, becauseflutterfails ifTMPDIRpoints to a missing folder. Does not cover programs an app starts without a shell. Sandboxed agents may need the new folder added to their allowed write paths; find their real setting, do not guess. - D. Scheduled cleanup. A job (launchd, cron, systemd timer or Task Scheduler) that removes only
dart_test.*andflutter_tools.*folders that are stale and not in use. Default to a dry run. Show the script and schedule before installing. - E. Limit parallel runs. Run fewer test suites at once across agents or worktrees, for example with
--concurrencyor one test run per machine. - F. Do nothing. Report only.
Do only what the person chose. Back up any file before you edit it. After each change, run one short test and show that the temp files land where expected and are gone when the run finishes. Do not touch the analyzer cache, pub cache, build folders or source files unless the person asks.