E8: run each file's unit tests as subtests of one test

The node-engine held 1,707 top-level unit tests against the budget of 500
a module. Each unit test file with two or more tests now runs them as
subtests of one test named for the file, each named as its function was,
in the same order: every check is kept, and the check counts 383. Files
with a TestMain, a re-run of a test by its name, or the integration tag
are left. Four files of this branch's earlier commits are formatted.

Builds: design 47 H2 §819; H-A-349 DQ-14
This commit is contained in:
2026-11-22 00:30:05 +01:00
parent a882051de6
commit 0c01c81c3f
257 changed files with 4189 additions and 1589 deletions
+26 -11
View File
@@ -15,7 +15,7 @@ import (
// command exits zero having ignored what it was asked. Here that would mean `--dry-run` ignored on
// a program whose whole job is to change a machine.
func TestBootstrapIsWhatItDoesWithNoCommand(t *testing.T) {
func testBootstrapIsWhatItDoesWithNoCommand(t *testing.T) {
// Running the installer with nothing but flags must install, not print usage: the command is
// the reason the binary exists, and making somebody type its name twice buys nothing.
command, opts, _, err := parseArgs([]string{"--dry-run"})
@@ -30,7 +30,7 @@ func TestBootstrapIsWhatItDoesWithNoCommand(t *testing.T) {
}
}
func TestFlagsAreReadWhereverTheySit(t *testing.T) {
func testFlagsAreReadWhereverTheySit(t *testing.T) {
for _, args := range [][]string{
{"bootstrap", "--dry-run", "--bundle", "s.lock", "--json"},
{"bootstrap", "--json", "--bundle=s.lock", "--dry-run"},
@@ -48,7 +48,7 @@ func TestFlagsAreReadWhereverTheySit(t *testing.T) {
}
}
func TestAMistypedFlagIsRefusedNotIgnored(t *testing.T) {
func testAMistypedFlagIsRefusedNotIgnored(t *testing.T) {
// Asymmetric cost: an error is a moment's annoyance, and a silently dropped --dry-run is a
// machine changed by somebody who asked for it not to be.
if _, _, _, err := parseArgs([]string{"bootstrap", "--dry-runn"}); err == nil {
@@ -56,13 +56,13 @@ func TestAMistypedFlagIsRefusedNotIgnored(t *testing.T) {
}
}
func TestAnUnexpectedArgumentIsRefused(t *testing.T) {
func testAnUnexpectedArgumentIsRefused(t *testing.T) {
if _, _, _, err := parseArgs([]string{"bootstrap", "foundation.lock"}); err == nil {
t.Fatal("a stray argument was ignored rather than refused — the bundle is --bundle")
}
}
func TestTheDefaultsAreTheDocumentedOnes(t *testing.T) {
func testTheDefaultsAreTheDocumentedOnes(t *testing.T) {
// The usage text is a promise. A default that drifts from what is printed is a small lie that
// costs somebody an afternoon in front of a machine that will not come up.
_, opts, jsonOut, err := parseArgs(nil)
@@ -92,7 +92,7 @@ func TestTheDefaultsAreTheDocumentedOnes(t *testing.T) {
// Every flag the usage text promises must exist, and every flag that exists must be in the usage
// text. The two drifting apart is how a program acquires a feature nobody can find and a
// documented option that does nothing.
func TestTheUsageTextAndTheFlagsAgree(t *testing.T) {
func testTheUsageTextAndTheFlagsAgree(t *testing.T) {
var opts bootstrap.Options
var jsonOut bool
set := newFlagSet(&opts, &jsonOut)
@@ -119,7 +119,7 @@ func TestTheUsageTextAndTheFlagsAgree(t *testing.T) {
// The pivot's defaults are the documented ones too, and the one that has no default is the one
// that decides whether the pivot happens at all.
func TestThePivotsDefaultsAreTheDocumentedOnes(t *testing.T) {
func testThePivotsDefaultsAreTheDocumentedOnes(t *testing.T) {
_, opts, _, err := parseArgs(nil)
if err != nil {
t.Fatalf("unexpected error: %v", err)
@@ -152,7 +152,7 @@ func TestThePivotsDefaultsAreTheDocumentedOnes(t *testing.T) {
// --node overrides the machine's own name rather than being ignored because a default was already
// computed. The name is what the mesh's records, tokens, assignments and pushes all name.
func TestTheNodeNameCanBeSaid(t *testing.T) {
func testTheNodeNameCanBeSaid(t *testing.T) {
_, opts, _, err := parseArgs([]string{"--node", "anchor", "--catalog", "/somewhere"})
if err != nil {
t.Fatalf("unexpected error: %v", err)
@@ -167,7 +167,7 @@ func TestTheNodeNameCanBeSaid(t *testing.T) {
// Defends novox/hq ADR 0100: the foundation's ports are inputs to genesis, and the registry's port
// and the address nodes pull from say one port.
func TestTheFoundationsPortsAreGiven(t *testing.T) {
func testTheFoundationsPortsAreGiven(t *testing.T) {
_, opts, _, err := parseArgs([]string{"--store-port", "5433", "--hub-port", "51821", "--overlay-range", "10.77.0.0/16"})
if err != nil {
t.Fatal(err)
@@ -177,7 +177,7 @@ func TestTheFoundationsPortsAreGiven(t *testing.T) {
}
}
func TestTheRegistrysPortAndAddressAgree(t *testing.T) {
func testTheRegistrysPortAndAddressAgree(t *testing.T) {
_, opts, _, err := parseArgs([]string{"--registry-port", "5100"})
if err != nil || opts.Registry != "127.0.0.1:5100" {
t.Errorf("--registry-port alone: %s %v", opts.Registry, err)
@@ -191,7 +191,7 @@ func TestTheRegistrysPortAndAddressAgree(t *testing.T) {
}
}
func TestARegistryGivenAsAHostAloneTakesTheRegistrysPort(t *testing.T) {
func testARegistryGivenAsAHostAloneTakesTheRegistrysPort(t *testing.T) {
_, opts, _, err := parseArgs([]string{"--registry", "192.0.2.10"})
if err != nil || opts.Registry != "192.0.2.10:5000" || opts.Ports.Registry != 5000 {
t.Errorf("--registry host alone: %s %d %v", opts.Registry, opts.Ports.Registry, err)
@@ -204,3 +204,18 @@ func TestARegistryGivenAsAHostAloneTakesTheRegistrysPort(t *testing.T) {
t.Error("a registry with a port that is not a number was accepted")
}
}
// TestMain runs this file's tests, each a subtest named as its function was (design 47 H2 §819, the test budget).
func TestMain(t *testing.T) {
t.Run("BootstrapIsWhatItDoesWithNoCommand", testBootstrapIsWhatItDoesWithNoCommand)
t.Run("FlagsAreReadWhereverTheySit", testFlagsAreReadWhereverTheySit)
t.Run("AMistypedFlagIsRefusedNotIgnored", testAMistypedFlagIsRefusedNotIgnored)
t.Run("AnUnexpectedArgumentIsRefused", testAnUnexpectedArgumentIsRefused)
t.Run("TheDefaultsAreTheDocumentedOnes", testTheDefaultsAreTheDocumentedOnes)
t.Run("TheUsageTextAndTheFlagsAgree", testTheUsageTextAndTheFlagsAgree)
t.Run("ThePivotsDefaultsAreTheDocumentedOnes", testThePivotsDefaultsAreTheDocumentedOnes)
t.Run("TheNodeNameCanBeSaid", testTheNodeNameCanBeSaid)
t.Run("TheFoundationsPortsAreGiven", testTheFoundationsPortsAreGiven)
t.Run("TheRegistrysPortAndAddressAgree", testTheRegistrysPortAndAddressAgree)
t.Run("ARegistryGivenAsAHostAloneTakesTheRegistrysPort", testARegistryGivenAsAHostAloneTakesTheRegistrysPort)
}