Eric Abrahamsen writes: > Eric Abrahamsen writes: > >> Eric Abrahamsen writes: >> >>> Ted Zlatanov writes: >> >> [...] >> >>>> The registry has ERT tests, which I thought covered this case. Can you >>>> look at `tests/gnustest-registry.el'? As a first step, can you try >>>> making tests to demonstrate the problems? >>> >>> Will do. >> >> Okay, turns out there were tests, but the bit that tests pruning was >> commented out :) >> >> This is the first in a (gradual) series of patches. It does very little >> except: >> >> 1. Adjust `registry-prune' to do what the docstring says: return the >> total number of entries pruned >> >> 2. Uncomment the pruning test and adjust it so it correctly catches the >> number of pruned entries. >> >> Test should fail. Over the next couple of days I'll add another test to >> check that entries are sorted correctly before pruning, and then take a >> stab at fixing the pruning itself. > > Okay I realized it didn't make too much sense to patch gnus just to make > it fail, so here's a complete patch, with passing tests, that preserves > precious entries when pruning. I haven't done the sorting yet, that will > be a separate patch. And of course seconds later I realized that the test didn't quite match the logic of the function, here's a new version. In essence, here's the logic of pruning, taken from the test: (let* ((size (registry-size db)) (limit (min (oref db :max-hard) (oref db :max-soft))) (keepers (registry-search db :member '((extra "more data")))) (desired-prune-count (- size (- limit (* size 0.1)))) (expected-prune-count (min (- size (length keepers)) desired-prune-count)) (actual-prune-count (registry-prune db))) (ert-info ((format "Expected to prune %d entries but pruned %d" expected-prune-count actual-prune-count) :prefix "Error: ") (should (= expected-prune-count actual-prune-count)))) I hope that's what was actually intended! Seems to work okay, though. Please test with byte-compiled files, otherwise it's brutally slow. Eric