Skip to content

Stop store tests leaking mojito.tests.* plists into ~/Library/Preferences - #243

Open
wr wants to merge 2 commits into
mainfrom
wells/w-1030-unit-tests-leak-mojitotests-userdefaults-plists-into
Open

wr wants to merge 2 commits into
mainfrom
wells/w-1030-unit-tests-leak-mojitotests-userdefaults-plists-into

Conversation

@wr

@wr wr commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Summary

TriggerConfigStoreTests, AliasStoreTests and QuickAccessStoreTests opened a uniquely-named UserDefaults(suiteName: "mojito.tests.…") per test and never removed it, so every test run left a plist in ~/Library/Preferences. About 5,800 had piled up locally.

Removing a named suite isn't reliable either: cfprefsd rewrites an empty plist about a minute later, even after removePersistentDomain and deleting the file. The new ScratchDefaults test helper opens suites by absolute path inside a private temp directory. On deinit it clears each domain and deletes the directory. Each suite keeps one as a stored property, and Swift Testing creates a fresh suite instance per test, so cleanup runs after every test.

  • Tests/MojitoTests/ScratchDefaults.swift: the helper, plus a regression test.
  • The three store test suites now get their suites from ScratchDefaults.
  • CLAUDE.md: note under "Things that have bitten us" so new store tests use the helper.

Test plan

  • scripts/run-tests.sh: 321/321 pass
  • 70 s after a full run, ~/Library/Preferences has no mojito.tests.* plists and $TMPDIR has no mojito-tests-* folders

Refs W-1030

wr added 2 commits October 13, 2026 17:58
…nces

TriggerConfigStore, AliasStore and QuickAccessStore tests each opened a
uniquely-named UserDefaults suite per test and never removed it, so every
run added plists to ~/Library/Preferences (~5,800 had piled up locally).

Deleting a named suite isn't reliable: cfprefsd rewrites an empty plist
even after removePersistentDomain + removing the file. ScratchDefaults
instead opens suites by absolute path in a private temp directory and
tears them down on deinit; each suite holds one as a stored property so
cleanup runs per test.

Refs: W-1030
@linear-code

linear-code Bot commented Oct 13, 2026

Copy link
Copy Markdown

W-1030

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant