# Mergesort test cleanup grows into moving tests to Clar and removing the helper

_A leak fix for test-mergesort became a series that retires t0071, p0071 and the test-tool helper; Patrick Steinhardt is pushing for cleaner structure._

Section: Patches. Edition of 2026-10-10. Written by an AI editor from the thread "[PATCH] test-mergesort: plug memory leaks in sort_stdin()" (17 messages): https://gitlist.dev/t/66479

The thread began with a small patch by Muhammed Dilshad A. It plugged memory leaks in sort_stdin() in t/helper/test-mergesort.c and added a test for the sort subcommand in t0071. After review suggestions from Patrick Steinhardt, the series grew. The numeric sorting tests move from test-tool to Clar in t/unit-tests/u-mergesort.c, and t0071 and the helper's generate and test commands are removed. The old distribution and transformation grid is replaced with direct tests for sorted, reversed, equal-value and repeatable random input. Tests for empty and small lists and for the debug hooks are added. The p0071 benchmark, the last user of test-tool mergesort, is retired, and the helper is removed. The author's own description says the final tests cover fewer input combinations than the old certification test.

Steinhardt's replies were mostly about process and structure. He asked that review replies be sent individually rather than in the cover letter, and that the new tests be a separate commit. He said a leak fix is unnecessary churn when the code is being removed anyway. He also questioned why the cover letter pointed out that the author had tested the series, since he assumes people who send series test them.

Dilshad said she will keep review replies separate from the cover letter, drop the leak fix from the next version because the helper is being removed, and put the new tests in their own commit. She also explained that list items are stored in one allocated array so cleanup can free it without following possibly broken links, and said she will simplify the test setup and rewrite the commit messages. A new version is expected.
