Speed up the internal/cli lock and two-vault tests (closes #80) #83

Merged
clawbot merged 1 commits from issue-80-faster-cli-tests into next 2026-10-04 08:08:05 +02:00
Collaborator

Since #69 the internal/cli tests took much longer. A verbose run inside the docker build showed where: TestChangingCommandsWaitForLock, added with the lock, slept a fixed 100 ms for each of its 16 commands, and six path and move tests each created two vaults with passphrase unlockers, which are slow to create by design.

What changed:

  • requireWaitsForLock no longer sleeps. It reads the goroutine stack traces until one is stopped in vault.LockStateDir waiting for the in-memory filesystem's lock, checks the state directory is unchanged, then releases the lock. A command that takes no lock still finishes first and fails; one that changes something before locking always fails the unchanged check, instead of relying on 100 ms being long enough.
  • newTwoVaultFs creates its vaults once and returns a fresh copy on every call, the same copying the rejection cases already did. The test bodies are unchanged.

Each changed test fails with its guarded defect planted back.

What is left in TestChangingCommandsWaitForLock is creating passphrase unlockers: four of the commands create one, and two cases need one first. The size cases and -race are untouched (#52).

  • Judgement call: spotting the waiting command depends on the runtime's [sync.Mutex.Lock] wait reason in stack traces; if that text changes, the test fails with "never waited for the lock" rather than passing.
  • Rule suppressed: gochecknoglobals on the shared fixture's sync.Once and its copy source.

Model: opus-5-5

Since https://git.eeqj.de/sneak/secret/pulls/69 the `internal/cli` tests took much longer. A verbose run inside the docker build showed where: `TestChangingCommandsWaitForLock`, added with the lock, slept a fixed 100 ms for each of its 16 commands, and six path and move tests each created two vaults with passphrase unlockers, which are slow to create by design. What changed: - `requireWaitsForLock` no longer sleeps. It reads the goroutine stack traces until one is stopped in `vault.LockStateDir` waiting for the in-memory filesystem's lock, checks the state directory is unchanged, then releases the lock. A command that takes no lock still finishes first and fails; one that changes something before locking always fails the unchanged check, instead of relying on 100 ms being long enough. - `newTwoVaultFs` creates its vaults once and returns a fresh copy on every call, the same copying the rejection cases already did. The test bodies are unchanged. Each changed test fails with its guarded defect planted back. What is left in `TestChangingCommandsWaitForLock` is creating passphrase unlockers: four of the commands create one, and two cases need one first. The size cases and `-race` are untouched (https://git.eeqj.de/sneak/secret/issues/52). - Judgement call: spotting the waiting command depends on the runtime's `[sync.Mutex.Lock]` wait reason in stack traces; if that text changes, the test fails with "never waited for the lock" rather than passing. - Rule suppressed: `gochecknoglobals` on the shared fixture's `sync.Once` and its copy source. Model: opus-5-5
clawbot self-assigned this 2026-10-04 06:49:14 +02:00
clawbot added the needs-review label 2026-10-04 06:49:18 +02:00
Author
Collaborator

PASS: the lock test and the path and move tests are faster and still prove everything they proved before.

Disclosure: conflicts with current next only in TODO.md (both add a Completed Steps entry); reviewed with both entries kept.

Model: opus-5-5

PASS: the lock test and the path and move tests are faster and still prove everything they proved before. Disclosure: conflicts with current `next` only in `TODO.md` (both add a Completed Steps entry); reviewed with both entries kept. Model: opus-5-5
clawbot added 1 commit 2026-10-04 08:03:41 +02:00
The test that each changing command waits for the state directory lock
slept a fixed 100 ms per command. It now polls the goroutine stacks until
the command is parked in vault.LockStateDir, checks the state directory
is unchanged, and releases the lock; a command that takes no lock still
fails by finishing first.

newTwoVaultFs creates its two vaults, each with a passphrase unlocker,
once, and returns a fresh copy of them on every call, so the six path and
move tests no longer each pay for two passphrase key derivations.

Model: opus-5-5
clawbot force-pushed issue-80-faster-cli-tests from 9fc49f6052 to 02b42499e6 2026-10-04 08:03:41 +02:00 Compare
clawbot merged commit 5ec59862ff into next 2026-10-04 08:08:05 +02:00
clawbot deleted branch issue-80-faster-cli-tests 2026-10-04 08:08:05 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/secret#83