uttrflow / uttrflow/uttrflow-swift
Temporary Sandbox values are destroyed before dictionary tests write their files, leaving directories behind
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## Problem
Numerous dictionary tests pass `Sandbox().file` directly into `PersonalDictionaryStore`. `Sandbox` owns cleanup in its deinitializer, but the temporary value is destroyed while extracting the URL, before the actor later creates its files. The store owns only the URL and has no matching cleanup. Tests that write through this pattern leave UUID directories behind after completion.
## Evidence
Reviewed main at `8d93f5b8574f3c7b8c30086d9c817bf7f5d4827d`. Reproduced with unchanged repository source in an isolated Swift package on macOS. Checks assert the observed problem, not a completed fix or a full-app test pass.
Copied the unchanged dictionary `Fixtures.swift` into the isolated test package. A helper extracted `Sandbox().file`, created a store, added one word, and returned. After that helper completed, the dictionary file still existed (`SANDBOX_FILE_REMAINS true`). The reproduction then removed it explicitly. There are 28 `Sandbox().file` occurrences across the three files below; not every occurrence writes a file, so this is not a claim that all 28 leak on every run.
## Relevant code
- [Tests/UttrflowDictionaryTests/Fixtures.swift:28](https://github.com/uttrflow/uttrflow-swift/blob/8d93f5b8574f3c7b8c30086d9c817bf7f5d4827d/Tests/UttrflowDictionaryTests/Fixtures.swift#L28)
- [Tests/UttrflowDictionaryTests/PersonalDictionaryStoreTests.swift:37](https://github.com/uttrflow/uttrflow-swift/blob/8d93f5b8574f3c7b8c30086d9c817bf7f5d4827d/Tests/UttrflowDictionaryTests/PersonalDictionaryStoreTests.swift#L37)
- [Tests/UttrflowDictionaryTests/DictionaryLearningTests.swift:33](https://github.com/uttrflow/uttrflow-swift/blob/8d93f5b8574f3c7b8c30086d9c817bf7f5d4827d/Tests/UttrflowDictionaryTests/DictionaryLearningTests.swift#L33)
- [Tests/UttrflowDictionaryTests/ShippedWordsTests.swift:72](https://github.com/uttrflow/uttrflow-swift/blob/8d93f5b8574f3c7b8c30086d9c817bf7f5d4827d/Tests/UttrflowDictionaryTests/ShippedWordsTests.swift#L72)
## Acceptance criteria
- Keep the sandbox alive through the final awaited store operation and deterministically remove its directory when the test ends, including throwing paths. An explicit scoped async fixture helper or cleanup defer is sufficient.
- Convert the affected writing tests and verify their temporary roots are absent afterwards.
- Preserve independent per-test directories so parallel tests remain isolated.
## Existing work checked
Checked open and closed issue titles/bodies for fixture lifetime, temporary-directory cleanup, and `Sandbox().file`; no matching report found. #632 covers test CPU cost and #629 unbounded waits, not files left by fixture destruction.
Contributor guide
Research direction
Start with the Sandbox usage in Tests/UttrflowDictionaryTests/Fixtures.swift and the affected tests in PersonalDictionaryStoreTests.swift, DictionaryLearningTests.swift, and ShippedWordsTests.swift. Run the dictionary tests and inspect the existing Sandbox and PersonalDictionaryStore lifecycle. Keep each sandbox alive through the final awaited store operation, clean up on throwing and non-throwing paths, and verify temporary roots are absent while parallel tests retain separate directories.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100