Replace single-letter -# self-tests with a named -#test=NAME registry - #427
Merged
Conversation
The hidden engine self-tests had accreted into a grab-bag of arbitrary
single-letter/-digit -# arms (-#0, -#A, -#W, ...) buried in the htscoremain.c
option switch, with no mnemonics and stale --help text. Collapse them into one
registry: -#test lists every test with a usage hint and one-line description,
and -#test=NAME [args] runs one.
The handlers and the two helpers they used (basic_selftests,
string_safety_selftests) move to a new htsselftest.c keyed by a
{name, args, desc, fn} table; htscoremain.c keeps only a small dispatch that
runs ahead of the no-URL usage gate, so a bare -#test (or an arg-less test like
copyopt/dns/cookies) no longer needs a dummy URL token to be reached. The
genuine debug knobs (-#L, -#C, -#R, -#h, ...) stay as letters in the switch;
only the unit self-tests, whose sole callers are tests/01_engine-*.test, are
renamed, so this is internal-only with no compatibility surface. Behavior is
preserved: each test prints the same result line and exit code, which the
existing assertions pin. Three now-unused includes (htscache_selftest.h,
htsdns_selftest.h, htsencoding.h) drop out of htscoremain.c.
Tests: the engine tests move to -#test=NAME; 01_engine-hashtable now asserts its
success line (not just exit code) so a misrouted registry row can't pass, and a
new 01_engine-selftest-dispatch covers the bare-list and unknown-name paths.
The --help/man "guru options" list now points at -#test instead of enumerating
a stale subset. The lone vestigial alias --debug-testfilters still resolves to
the removed -#0 (it was already non-functional: param1 supplies one argument,
-#0 required two); it is left untouched because editing that array forces
clang-format to reflow the whole untouched table.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The hidden engine self-tests had grown into a pile of arbitrary single-letter and single-digit
-#arms (-#0,-#A,-#W, ...) buried in the htscoremain.c option switch, with no mnemonics and a stale--helplisting. This replaces them with one registry:-#testlists every self-test with its arguments and a one-line description, and-#test=NAME [args]runs one. The handlers (and the two helpers they used) move to a new htsselftest.c keyed by a{name, args, desc, fn}table; htscoremain.c keeps only a small dispatch, placed ahead of the no-URL usage gate so a bare-#testor an arg-less test no longer needs a dummy URL token. Only the unit self-tests are renamed, and their sole callers are tests/01_engine-*.test, so there is no external compatibility surface; the genuine debug knobs (-#L,-#C,-#R, ...) keep their letters.Behavior is preserved: each test prints the same result line and exit code, which the existing assertions pin. The test suite moves to
-#test=NAME, the hashtable test now asserts its success line (not just exit code) so a misrouted registry row cannot slip through, and a new dispatch test covers the list and unknown-name paths. One loose end: the vestigial--debug-testfiltersalias still resolves to the removed-#0. It was already non-functional (it passes one argument where-#0wanted two), and I left it rather than edit the alias array, which would make clang-format reflow the whole untouched table.