diff options
| author | dev <dev@example> | 2026-11-14 01:05:08 +0000 |
|---|---|---|
| committer | dev <dev@example> | 2026-11-14 01:05:08 +0000 |
| commit | 312ddd4936f09ae27a180ca495cacf2c06faf33e (patch) | |
| tree | 2fa46ab568ad55f7e8fb844c3447b1d296b2e340 /test/test.h | |
| parent | e737f3d560de2b8172e6dd83901bc1359283303c (diff) | |
| download | access-control-312ddd4936f09ae27a180ca495cacf2c06faf33e.tar.gz access-control-312ddd4936f09ae27a180ca495cacf2c06faf33e.zip | |
Comments: cut to what the code cannot say
The comments had grown into essays. A file header explaining why the file
exists, then a paragraph above each function restating what the next eight
lines do, then a paragraph above that one explaining why that matters. The
reader gets no further than the first paragraph, and the second is the one that
goes stale: it describes code that has since changed, and nothing fails when it
does.
Cut by about half. What is left is the three things a comment can do that code
cannot: say why the constraint exists (no regex because a hook must not depend
on what might be missing at 3am), say what is not obvious from the shape (a
bare ref name is a branch, never a tag; the seventh field of /etc/passwd is the
shell), and say where it hurts (the NULL in an execvp array, the mode and owner
that have to survive an atomic rewrite, the child that must not keep the hook's
stdin).
Block comments became // lines, which is also what the other C trees here use,
and the file headers went to two or three lines. Section banners stayed: they
are navigation, not prose.
Behaviour is unchanged and the suites prove it: 171 direct checks, 162
behavioural, clean under -Werror and under ASan/UBSan.
Diffstat (limited to 'test/test.h')
| -rw-r--r-- | test/test.h | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/test/test.h b/test/test.h index c4f63d0..e60e5af 100644 --- a/test/test.h +++ b/test/test.h @@ -1,10 +1,5 @@ -/* test.h - the little harness the test programs share. - * - * No test framework, because a test suite with a dependency is a test suite - * that does not run at 3am. Each program in test/ is its own: it links the - * library, runs its own cases and reports its own count, so one failing file - * says which area broke rather than taking the whole run down with it. - */ +// No test framework: a suite with a dependency is a suite that does not run at +// 3am. Each program in test/ links the library and reports its own count. #ifndef TEST_H #define TEST_H @@ -61,8 +56,8 @@ static inline void note(const char *fmt, ...) fputc('\n', stdout); } -/* Where the fixtures are written. UNIT_TMPDIR is there for a build that runs - * the tests somewhere the source tree is not writable. */ +// Where the fixtures are written. UNIT_TMPDIR is there for a build that runs * +// the tests somewhere the source tree is not writable. static inline void test_init(const char *argv0) { const char *dir = getenv("UNIT_TMPDIR"); @@ -79,11 +74,11 @@ static inline int test_report(const char *what) return failures != 0; } -/* ------------------------------------------------------------- fixtures */ +// ------------------------------------------------------------- fixtures -/* A policy from a string. The file is unlinked straight after loading: the - * decisions are made in memory, and a test that left policies behind would - * leave them to be trusted. */ +// A policy from a string. The file is unlinked straight after loading: the +// decisions are made in memory, and a test that left policies behind would leave +// them to be trusted. static inline int load_text(policy_t *p, const char *text) { static int seq; |
