Skip to content

Commit 26e9103

Browse files
mchwangclaude
andcommitted
Comment and naming fixes (#189)
Review round 34: what the loaded Docker address means for each call, which stdout a failed call leaves unread, who adds the test-run label; the records directory variable is lower case, as it changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 88ba062 commit 26e9103

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎test/agent-network.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ beforeAll(async () => {
3636
/**
3737
* Objects a test makes without this run's runner label, by name or by the file its shim records the name in, so
3838
* afterAll removes them should the test time out before its own removal runs (#189). The record files live in
39-
* `RECORDS`, not in the shims, so a name a late client adds after the test's own removal is still read here.
39+
* `records`, not in the shims, so a name a late client adds after the test's own removal is still read here.
4040
*/
4141
const unlabelled: { kind: 'container' | 'network'; name?: string; file?: string }[] = [];
4242
// Made by the first test that records, so a run that selects none of this file's tests leaves no directory.
43-
let RECORDS = '';
44-
const recordFile = () => join(RECORDS ||= mkdtempSync(join(tmpdir(), 'codeboost-records-')), randomUUID());
43+
let records = '';
44+
const recordFile = () => join(records ||= mkdtempSync(join(tmpdir(), 'codeboost-records-')), randomUUID());
4545
// If setup failed there is no network, and a teardown error would hide the setup failure.
4646
afterAll(async () => {
4747
try {
@@ -59,7 +59,7 @@ afterAll(async () => {
5959
// timeout. The hook's 7 minutes leave a minute and a half over this sweep's worst case (eleven calls of 30 s), for
6060
// the cleanup before it.
6161
removeRunnerObjects(TEST_RUNNER_OWNER);
62-
if (RECORDS) rmSync(RECORDS, { recursive: true, force: true });
62+
if (records) rmSync(records, { recursive: true, force: true });
6363
}
6464
}, 7 * 60_000);
6565

‎test/docker-sweep.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ it('removes by name only an object of exactly that name, and reports failures ot
5656
// Answers as Docker 27.4 does for `inspect --format '{{json .Id}} {{json .Name}}'` (a volume: '{{json .Name}}') and
5757
// `rm`, in the parts removeByName reads: stdout of an inspect that succeeded, stderr and the exit status. A missing
5858
// object, an object found under another name (by an ID prefix), a refused removal, an inspect killed by a signal, and a
59-
// failure before the daemon (an unknown context; its meta.json path shortened). The stdout of a failed call, a bare
60-
// newline in 27.4, is not read.
59+
// failure before the daemon (an unknown context; its meta.json path shortened). The stdout of a failed call (a bare
60+
// newline for a missing object in 27.4, nothing for the others) is not read.
6161
writeFileSync(join(root, 'docker'), ['#!/bin/sh', `printf '%s\\n' "$*" >> '${calls}'`,
6262
'for arg; do name="$arg"; done',
6363
'if [ "$2" = inspect ]; then case "$1 $name" in',

‎test/fixtures/docker-sweep.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const REAL_DOCKER = spawnSync('sh', ['-c', 'command -v docker'], { encodi
1010
/**
1111
* The daemon `docker` talks to when this module loads. A test that times out may leave DOCKER_HOST or DOCKER_CONTEXT
1212
* changed (agent-supervisor points DOCKER_HOST at a missing socket until its handle settles), so every call here
13-
* restores them.
13+
* runs with the values they had when this module loaded.
1414
*/
1515
const LOADED_ENV = { DOCKER_HOST: process.env.DOCKER_HOST, DOCKER_CONTEXT: process.env.DOCKER_CONTEXT };
1616
const dockerEnv = () => {
@@ -25,8 +25,8 @@ export function requireRealDocker(): string {
2525
}
2626

2727
/**
28-
* The label a test's Docker shim adds to an object it makes without the runner label (#189), so the test can still
29-
* find and remove that object however the test ends. No codeboost code writes or reads it.
28+
* The label a test (most often through its Docker shim) adds to an object it makes without the runner label (#189),
29+
* so the test can still find and remove that object however the test ends. No codeboost code writes or reads it.
3030
*/
3131
export const TEST_RUN_LABEL = 'io.codeboost.test-run';
3232
/** Beside it, one value per test file run, so afterAll removes them all with one sweep. */

0 commit comments

Comments
 (0)