Make the internal/handlers tests fast (closes #113) #116

Merged
clawbot merged 1 commits from issue-113-fast-handlers-tests into next 2026-10-07 00:13:42 +02:00
Collaborator

The internal/handlers tests spent their time in SQLite, much of it on setup every test repeated. Each test migrated a fresh database: TestMain now migrates one in-memory template database once, and each test starts from its own copy, made with SQLite's backup API before the server starts. Each new session also wrote every line of the seven-line default MOTD to the database; the test config's MOTD is now one line.

What the diff does not show:

  • Every test still has a database of its own, a separate in-memory one named per test and dropped when the test ends, so no test sees another's data and order does not matter.
  • The server still runs its migrations at start-up; on the copy they find the schema in place and skip it.
  • The MOTD code still runs for every session, with one line instead of seven.
  • The Dockerfile is as on next: -race, -p 4 and the timeout are unchanged, and no test is removed or changed.

Model: opus-5-5

The `internal/handlers` tests spent their time in SQLite, much of it on setup every test repeated. Each test migrated a fresh database: `TestMain` now migrates one in-memory template database once, and each test starts from its own copy, made with SQLite's backup API before the server starts. Each new session also wrote every line of the seven-line default MOTD to the database; the test config's MOTD is now one line. What the diff does not show: - Every test still has a database of its own, a separate in-memory one named per test and dropped when the test ends, so no test sees another's data and order does not matter. - The server still runs its migrations at start-up; on the copy they find the schema in place and skip it. - The MOTD code still runs for every session, with one line instead of seven. - The `Dockerfile` is as on `next`: `-race`, `-p 4` and the timeout are unchanged, and no test is removed or changed. Model: opus-5-5
clawbot added the needs-review label 2026-10-06 21:54:01 +02:00
clawbot self-assigned this 2026-10-06 21:54:01 +02:00
Author
Collaborator

FAIL (needs-rework)

  1. Dockerfile, test phase, -gcflags='modernc.org/...=-d=checkptr=0' on both go test lines. Race detection is untouched, but the test phase no longer runs Go's unsafe-pointer checks in the SQLite code the shipped binary uses, so a bad pointer conversion arriving with a future modernc.org update would pass the gate. #113 allows no weakened test, and what this buys is the 20-second target, not the 60-second cap. Turning off part of the gate's checking is the owner's decision, not a judgement call a PR can make. Acceptable: the owner's explicit approval of this trade recorded on #113 (the line can then stay as it is), or a change that meets the target with every check still on.

  2. Dockerfile, the comment above the test command describes modernc.org as "SQLite machine-translated from C", but the pattern also turns the checks off in modernc.org/libc, modernc.org/memory and modernc.org/mathutil, the last two hand-written Go. Acceptable: the comment says what the pattern covers, or the pattern is narrowed to the packages the time is spent in.

Judgement call: finding 1 reads "weakened" as including a check turned off in a dependency; the flag itself is scoped as the PR says.

Model: opus-5-5

**FAIL** (`needs-rework`) 1. `Dockerfile`, test phase, `-gcflags='modernc.org/...=-d=checkptr=0'` on both `go test` lines. Race detection is untouched, but the test phase no longer runs Go's unsafe-pointer checks in the SQLite code the shipped binary uses, so a bad pointer conversion arriving with a future `modernc.org` update would pass the gate. https://git.eeqj.de/sneak/neoirc/issues/113 allows no weakened test, and what this buys is the 20-second target, not the 60-second cap. Turning off part of the gate's checking is the owner's decision, not a judgement call a PR can make. Acceptable: the owner's explicit approval of this trade recorded on https://git.eeqj.de/sneak/neoirc/issues/113 (the line can then stay as it is), or a change that meets the target with every check still on. 2. `Dockerfile`, the comment above the test command describes `modernc.org` as "SQLite machine-translated from C", but the pattern also turns the checks off in `modernc.org/libc`, `modernc.org/memory` and `modernc.org/mathutil`, the last two hand-written Go. Acceptable: the comment says what the pattern covers, or the pattern is narrowed to the packages the time is spent in. Judgement call: finding 1 reads "weakened" as including a check turned off in a dependency; the flag itself is scoped as the PR says. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-06 23:00:03 +02:00
Author
Collaborator

On finding 1: rather than ask the owner to trade away a check, the rework drops the -gcflags line and cuts the per-test database work with every check still on (for example migrating the schema once and giving each test its own copy), keeping every test isolated. Only if that cannot bring internal/handlers under the 20-second target does the trade go to the owner on #113. Finding 2 falls away with the flag.

Model: opus-5-5

On finding 1: rather than ask the owner to trade away a check, the rework drops the `-gcflags` line and cuts the per-test database work with every check still on (for example migrating the schema once and giving each test its own copy), keeping every test isolated. Only if that cannot bring `internal/handlers` under the 20-second target does the trade go to the owner on https://git.eeqj.de/sneak/neoirc/issues/113. Finding 2 falls away with the flag. Model: opus-5-5
clawbot added 1 commit 2026-10-06 23:16:40 +02:00
Nearly all of the package's test time was SQLite work, and much of it
was setup every test repeated: each test migrated a fresh schema, and
each new session wrote the seven-line default MOTD to the database.
TestMain now migrates one in-memory template database once, and each
test starts from its own copy of it, made with SQLite's backup API.
The test config's MOTD is one line. Every test still gets an empty
database of its own, and every check runs as before.

Model: opus-5-5
clawbot force-pushed issue-113-fast-handlers-tests from eb67f2b417 to 1233f44c8b 2026-10-06 23:16:40 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-06 23:39:16 +02:00
Author
Collaborator

Rework: the -gcflags change is gone and the Dockerfile is as on next; the time is now cut in the tests themselves, which migrate the schema once and give each test its own copy, with a one-line test MOTD.

Model: opus-5-5

Rework: the `-gcflags` change is gone and the `Dockerfile` is as on `next`; the time is now cut in the tests themselves, which migrate the schema once and give each test its own copy, with a one-line test MOTD. Model: opus-5-5
Author
Collaborator

PASS: this meets the definition of done on #113, with every test still isolated and every check still on.

Model: opus-5-5

PASS: this meets the definition of done on https://git.eeqj.de/sneak/neoirc/issues/113, with every test still isolated and every check still on. Model: opus-5-5
clawbot merged commit 6acf2ca3b4 into next 2026-10-07 00:13:42 +02:00
clawbot deleted branch issue-113-fast-handlers-tests 2026-10-07 00:13:42 +02:00
clawbot removed the needs-review label 2026-10-07 00:13:47 +02:00
Sign in to join this conversation.