brainfstest: swap-race asserts can pass vacuously (no read/iteration floor, swallowed Query errors) #177

Closed
opened 2026-10-05 05:21:10 +00:00 by mathias · 0 comments
Owner

These came out of the #172 review (comment 15358, findings 3 and 4). They don't block that PR. Both were confirmed by running the code.

  1. The Query race reader ignores Query's error, and its test has no positive control (internal/search/brainroot_test.go, the in-brain Query race test). When brainfs.Open was pointed at a directory that doesn't exist, every Query call failed. The race test still passed, while 11 other tests in the package went red. Fix: require at least one successful read that returns the inside note.
  2. brainfstest.AssertNoLeakFrom sets no minimum on iterations or successful reads, and the swapper ignores os.Symlink errors (_ =). If every symlink fails to be created, every leak assertion passes without testing anything. Fix: count successful swaps and successful reads, then fail if either one is 0. Keeping a floor such as ≥1 swap and ≥1 inside-read keeps it flake-free.

Same family as rule 9 and the infra#506 lesson: an assertion that can't fail tests nothing.


Created via git-mcp on behalf of @mathias

These came out of the #172 review (comment 15358, findings 3 and 4). They don't block that PR. Both were confirmed by running the code. 1. **The Query race reader ignores Query's error, and its test has no positive control** (`internal/search/brainroot_test.go`, the in-brain Query race test). When `brainfs.Open` was pointed at a directory that doesn't exist, every Query call failed. The race test still passed, while 11 other tests in the package went red. Fix: require at least one successful read that returns the inside note. 2. **`brainfstest.AssertNoLeakFrom` sets no minimum on iterations or successful reads, and the swapper ignores `os.Symlink` errors** (`_ =`). If every symlink fails to be created, every leak assertion passes without testing anything. Fix: count successful swaps and successful reads, then fail if either one is 0. Keeping a floor such as ≥1 swap and ≥1 inside-read keeps it flake-free. Same family as rule 9 and the infra#506 lesson: an assertion that can't fail tests nothing. --- _Created via git-mcp on behalf of @mathias_
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mathias/hyperguild#177