Repository navigation
Expand file tree
/
Copy pathcheck-xctest-selection.ts
More file actions
544 lines (509 loc) · 22.5 KB
/
Copy pathcheck-xctest-selection.ts
File metadata and controls
544 lines (509 loc) · 22.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
// `pnpm check:xctest-selection` — derive, from the Swift sources and CI definitions, which
// runner XCTest methods each CI lane actually reaches, and fail when a method reaches none
// (#1781 A7). Also ensures those unit-test methods are stripped from the Apple runner source
// copied into the npm package.
//
// Three workflows run the `AgentDeviceRunnerUITests` bundle over four lanes, and each reaches a
// different set:
//
// - host smoke-macos/action.yml, macOS host, every PR: the whole bundle as compiled for macOS, minus
// `-skip-testing:` — the pure runner-decision tests, whose guard is
// `#if AGENT_DEVICE_RUNNER_UNIT_TESTS` alone.
// - pr smoke-ios-run/action.yml, iOS Simulator: shared tests with platform-dependent Swift bodies, when selected.
// - nightly xctest-nightly.yml, iOS Simulator, scheduled: the whole bundle as compiled for
// iOS, minus `-skip-testing:` — includes the simulator-only tests, whose guard is
// `… && os(iOS)` (they launch the host app, route through SpringBoard, or assert an
// iOS-only branch).
// - nightly-ipad xctest-nightly.yml's iPad leg: the named `-only-testing:` selection only —
// the sole-screen route's off-phone half, which runs nowhere else.
//
// The classification therefore lives in the `#if` guards, so this check evaluates them per
// platform rather than treating a source-level `func test…` as running everywhere. What it
// holds:
//
// 1. Every `-skip-testing:` identifier compiles for its lane. An unknown skip re-admits
// `RunnerTests/testCommand`, the server entry point that waits 24 hours.
// 2. Every declared method is reachable by at least one lane. A test gated to a platform
// no lane runs (the tvOS-only pair this check found) is dark from the day it is written.
// 3. The entry point is reachable by no lane at all.
//
// The nightly and host lanes also assert their executed count equals the reach derived here
// (scripts/xctest-run-summary.ts), so a build variant without the unit-test compile flag, or a
// guard that quietly compiles a file out, reads as red instead of as a smaller green.
import fs from 'node:fs';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { runCmdSync } from '@agent-device/host-kit/command';
import { activeSource, type Platform } from './swift-conditional-compilation.ts';
import {
parseDeclaredTestsByPlatform,
readSwiftSources,
RUNNER_TESTS_DIR,
type DeclaredTest,
type SwiftSource,
} from './xctest-declarations.ts';
const repoRoot = path.resolve(import.meta.dirname, '..');
const packageAppleRunnerScript = path.join(repoRoot, 'scripts/package-apple-runner-source.mjs');
/** The macOS host lane, which runs the whole macOS-compiled bundle on every PR. */
export const HOST_XCTEST_SOURCE_FILE = '.github/actions/smoke-macos/action.yml';
export const PR_XCTEST_SOURCE_FILE = '.github/actions/smoke-ios-run/action.yml';
/** The nightly lane, whose `-skip-testing:` list decides what the full simulator suite leaves out. */
export const NIGHTLY_WORKFLOW_FILE = '.github/workflows/xctest-nightly.yml';
export type LaneId = 'host' | 'pr' | 'nightly' | 'nightly-ipad';
export type Lane = {
readonly id: LaneId;
readonly workflow: string;
readonly platform: Platform;
/**
* `whole`: everything compiled minus `-skip-testing:`; `platform-branch`: derived from guards;
* `named-only`: exactly the lane's own `-only-testing:` selection.
*/
readonly selection: 'whole' | 'platform-branch' | 'named-only';
/** The job-summary heading the lane's reporter prints. */
readonly title: string;
};
export const LANES: readonly Lane[] = [
{
id: 'host',
workflow: HOST_XCTEST_SOURCE_FILE,
platform: 'macOS',
selection: 'whole',
title: 'iOS runner host XCTest lane (macOS, no simulator)',
},
{
id: 'pr',
workflow: PR_XCTEST_SOURCE_FILE,
platform: 'iOS',
selection: 'platform-branch',
title: 'iOS runner platform branch checks',
},
{
id: 'nightly',
workflow: NIGHTLY_WORKFLOW_FILE,
platform: 'iOS',
selection: 'whole',
title: 'iOS runner full XCTest suite',
},
{
id: 'nightly-ipad',
workflow: NIGHTLY_WORKFLOW_FILE,
platform: 'iOS',
selection: 'named-only',
title: 'iPad runner sole-screen selection',
},
];
export function lane(id: string): Lane {
const found = LANES.find((entry) => entry.id === id);
if (!found) {
throw new Error(
`Unknown XCTest lane "${id}"; expected one of ${LANES.map((e) => e.id).join(', ')}.`,
);
}
return found;
}
/**
* Every workflow whose test identifiers this check owns. All are read, so a workflow that is
* renamed or deleted fails here rather than leaving a stale claim in the output.
*/
export const GUARDED_WORKFLOWS: readonly string[] = [
...new Set(LANES.map((entry) => entry.workflow)),
];
/**
* The one method that must be reachable by no lane: `testCommand` is the runner's server
* entry point (RunnerTests.swift), compiled unconditionally.
*/
export const ENTRY_POINT_METHOD = 'RunnerTests/testCommand';
// Two guards against reading prose as configuration, both learned the hard way: these
// workflows discuss their own flags in comments, and this check's first draft counted the
// comments. A line whose first non-space character is `#` is a comment in YAML and in the
// `run:` shell alike, so it can never be a flag xcodebuild sees; and the identifier must
// have the `Target/Class/method` shape, so a prose mention with no identifier after the
// colon matches nothing. A typo'd identifier is still identifier-shaped, so both guards
// narrow what counts as a flag without narrowing what counts as a defect.
const YAML_COMMENT = /^\s*#/;
// Global: a `run:` line may carry more than one flag (nothing stops `-only-testing:A -only-testing:B`
// on one line), and matching only the first would make the second invisible — silently permissive in
// the skip direction, where an unseen entry is a lane that stops skipping the 24-hour entry point.
const TEST_FLAG = /-(only|skip)-testing:([A-Za-z_][\w.+-]*(?:\/[A-Za-z_]\w*){1,2})/g;
export type TestFlag = 'only-testing' | 'skip-testing';
/** One `-only-testing:`/`-skip-testing:` identifier as written, and where it was written. */
export type FlaggedTest = {
readonly workflow: string;
readonly flag: TestFlag;
readonly identifier: string;
readonly line: number;
};
export type SelectionReport = {
readonly target: string;
/** Every `Target/Class/method` the Swift sources declare, sorted, regardless of guards. */
readonly declared: readonly string[];
/** The same set with the platforms each method compiles for. */
readonly declaredTests: readonly DeclaredTest[];
/** Every flagged identifier across the guarded workflows, in file order. */
readonly flagged: readonly FlaggedTest[];
/** Guarded workflows that do not exist — a claim this check can no longer make. */
readonly missingWorkflows: readonly string[];
/** Flagged identifiers naming no declared method — a failure. */
readonly unknown: readonly FlaggedTest[];
/** Flagged identifiers naming a method its lane's platform never compiles — a failure. */
readonly uncompiled: readonly FlaggedTest[];
/** What each lane reaches, once guards and flags are resolved. */
readonly reach: Readonly<Record<LaneId, ReadonlySet<string>>>;
/** Declared methods no lane reaches, entry point excluded — a failure. */
readonly dark: readonly string[];
/** Lanes that reach the entry point — a failure (a 24-hour hang). */
readonly entryPointReachedBy: readonly LaneId[];
readonly prWorkflowWiringFailures: readonly string[];
readonly sharedPlatformBranchIds: readonly string[];
readonly sharedPlatformBranchFailures: readonly string[];
};
export type WorkflowSource = { readonly workflow: string; readonly text: string | null };
/** Every `-only-testing:`/`-skip-testing:` identifier a workflow names, with its line. */
export function parseFlaggedTests(workflow: string, text: string): FlaggedTest[] {
return text.split('\n').flatMap((line, index) => {
if (YAML_COMMENT.test(line)) return [];
return [...line.matchAll(TEST_FLAG)].map((match) => ({
workflow,
flag: `${match[1]}-testing` as TestFlag,
identifier: match[2] as string,
line: index + 1,
}));
});
}
/** Attributed per workflow, not just per flag: each lane's number has to be its own. */
function identifiers(
flagged: readonly FlaggedTest[],
workflow: string,
flag: TestFlag,
): Set<string> {
return new Set(
flagged
.filter((entry) => entry.workflow === workflow && entry.flag === flag)
.map((entry) => entry.identifier),
);
}
/** The lane's platform's compiled identifiers, before its flags narrow them. */
function compiledIdentifiersForLane(declaredTests: readonly DeclaredTest[], entry: Lane): string[] {
return declaredTests
.filter((test) => test.platforms.includes(entry.platform))
.map((test) => test.identifier);
}
/** What one lane reaches: its platform's compiled set, narrowed by its flags. */
function laneReach(
entry: Lane,
declaredTests: readonly DeclaredTest[],
flagged: readonly FlaggedTest[],
sharedPlatformBranchIds: readonly string[],
): Set<string> {
if (entry.selection === 'platform-branch')
return new Set(iosPrTestIdentifiers(declaredTests, sharedPlatformBranchIds));
const compiled = compiledIdentifiersForLane(declaredTests, entry);
if (entry.selection === 'named-only') {
const named = identifiers(flagged, entry.workflow, 'only-testing');
return new Set(compiled.filter((id) => named.has(id)));
}
const skipped = identifiers(flagged, entry.workflow, 'skip-testing');
return new Set(compiled.filter((id) => !skipped.has(id)));
}
export function iosPrTestIdentifiers(
declaredTests: readonly DeclaredTest[],
sharedPlatformBranchIds: readonly string[],
): string[] {
const branchSensitive = new Set(sharedPlatformBranchIds);
return declaredTests
.filter(
(test) =>
test.platforms.includes('iOS') &&
test.platforms.includes('macOS') &&
branchSensitive.has(test.identifier),
)
.map((test) => test.identifier)
.filter((id) => !id.endsWith(`/${ENTRY_POINT_METHOD}`))
.sort();
}
type SharedMethodBody = { id: string; body: string; file: string };
type SharedMethodScan = { bodies: SharedMethodBody[]; failures: string[] };
function sharedMethodsByName(shared: readonly DeclaredTest[]): Map<string, string[]> {
const byMethod = new Map<string, string[]>();
for (const test of shared) {
const method = test.identifier.split('/').at(-1)!;
byMethod.set(method, [...(byMethod.get(method) ?? []), test.identifier]);
}
return byMethod;
}
function methodBody(lines: readonly string[], index: number, indent: number): string | undefined {
const start = lines[index]!;
const end = /\{[ \t]*}[ \t]*(?:\/\/.*)?$/.test(start)
? index
: lines.findIndex(
(candidate, candidateIndex) =>
candidateIndex > index &&
(candidate.match(/^[ \t]*/)?.[0].length ?? 0) === indent &&
/^[ \t]*}[ \t]*(?:\/\/.*)?$/.test(candidate),
);
return end < index ? undefined : lines.slice(index, end + 1).join('\n');
}
function inspectSharedMethods(
source: SwiftSource,
byMethod: ReadonlyMap<string, readonly string[]>,
): SharedMethodScan {
const lines = source.text.split('\n');
const bodies: SharedMethodBody[] = [];
const failures: string[] = [];
for (const [index, line] of lines.entries()) {
const declaration = /^([ \t]*)(?:[\w@]+[ \t]+)*func[ \t]+(test\w*)[ \t]*\(/.exec(line);
if (!declaration) continue;
const matching = byMethod.get(declaration[2]!);
if (!matching) continue;
if (matching.length !== 1) {
failures.push(
`${source.file}:${index + 1}: ambiguous shared XCTest method ${declaration[2]}.`,
);
continue;
}
const body = methodBody(lines, index, declaration[1]!.length);
if (body === undefined) {
failures.push(
`${source.file}:${index + 1}: cannot inspect shared XCTest method ${matching[0]}.`,
);
continue;
}
bodies.push({ id: matching[0]!, body, file: source.file });
}
return { bodies, failures };
}
function scanSharedPlatformBranches(
sources: readonly SwiftSource[],
declaredTests: readonly DeclaredTest[],
): { ids: string[]; failures: string[] } {
const shared = declaredTests.filter(
(test) => test.platforms.includes('iOS') && test.platforms.includes('macOS'),
);
const byMethod = sharedMethodsByName(shared);
const scans = sources.map((source) => inspectSharedMethods(source, byMethod));
const bodies = scans.flatMap((scan) => scan.bodies);
const failures = scans.flatMap((scan) => scan.failures);
for (const test of shared) {
if (bodies.filter((body) => body.id === test.identifier).length !== 1) {
failures.push(`${test.identifier}: expected one inspectable shared XCTest method body.`);
}
}
const ids = bodies
.filter(
({ body, file }) => activeSource(body, 'iOS', file) !== activeSource(body, 'macOS', file),
)
.map(({ id }) => id);
return { ids: [...new Set(ids)].sort(), failures };
}
function prWorkflowWiringFailures(text: string | null): string[] {
if (text === null) return [];
const active = text
.split('\n')
.filter((line) => !YAML_COMMENT.test(line))
.join('\n');
const failures: string[] = [];
if (!active.includes('scripts/check-xctest-selection.ts --ios-pr-tests')) {
failures.push('PR workflow does not invoke the generated iOS branch XCTest selector.');
}
if (!active.includes('-only-testing:$test_id') || !active.includes('"${IOS_PR_TEST_ARGS[@]}"')) {
failures.push('PR workflow does not pass each generated XCTest identifier to xcodebuild.');
}
if (parseFlaggedTests(PR_XCTEST_SOURCE_FILE, active).length > 0) {
failures.push('PR workflow still contains hand-maintained XCTest selection identifiers.');
}
return failures;
}
export function buildReport(
target: string,
sources: readonly SwiftSource[],
workflows: readonly WorkflowSource[],
): SelectionReport {
const declaredTests = parseDeclaredTestsByPlatform(target, sources);
const sharedBranches = scanSharedPlatformBranches(sources, declaredTests);
const declared = declaredTests.map((test) => test.identifier);
const known = new Map(declaredTests.map((test) => [test.identifier, test]));
const flagged = workflows.flatMap((entry) =>
entry.text === null ? [] : parseFlaggedTests(entry.workflow, entry.text),
);
const platformOf = new Map(LANES.map((entry) => [entry.workflow, entry.platform]));
// Identifiers for another target are left alone: this check owns one target's sources
// and cannot speak for anything else a workflow might select.
const owned = flagged.filter((entry) => entry.identifier.startsWith(`${target}/`));
const reachOf = (id: LaneId): ReadonlySet<string> => {
const lane = LANES.find((entry) => entry.id === id);
if (!lane) throw new Error(`No lane is declared for ${id}.`);
return laneReach(lane, declaredTests, flagged, sharedBranches.ids);
};
const reach: Record<LaneId, ReadonlySet<string>> = {
host: reachOf('host'),
pr: reachOf('pr'),
nightly: reachOf('nightly'),
'nightly-ipad': reachOf('nightly-ipad'),
};
const entryPoint = `${target}/${ENTRY_POINT_METHOD}`;
const reachedAnywhere = new Set(LANES.flatMap((entry) => [...reach[entry.id]]));
const prWorkflow = workflows.find((entry) => entry.workflow === PR_XCTEST_SOURCE_FILE);
return {
target,
declared,
declaredTests,
flagged,
missingWorkflows: workflows.filter((entry) => entry.text === null).map((e) => e.workflow),
unknown: owned.filter((entry) => !known.has(entry.identifier)),
uncompiled: owned.filter((entry) => {
const test = known.get(entry.identifier);
const platform = platformOf.get(entry.workflow);
return test !== undefined && platform !== undefined && !test.platforms.includes(platform);
}),
reach,
dark: declared.filter((id) => id !== entryPoint && !reachedAnywhere.has(id)),
entryPointReachedBy: LANES.filter((entry) => reach[entry.id].has(entryPoint)).map(
(entry) => entry.id,
),
prWorkflowWiringFailures: prWorkflowWiringFailures(prWorkflow?.text ?? null),
sharedPlatformBranchIds: sharedBranches.ids,
sharedPlatformBranchFailures: sharedBranches.failures,
};
}
export function loadReport(root: string = repoRoot): SelectionReport {
const directory = path.join(root, RUNNER_TESTS_DIR);
return buildReport(
path.basename(directory),
readSwiftSources(directory),
GUARDED_WORKFLOWS.map((workflow) => {
const file = path.join(root, workflow);
return { workflow, text: fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : null };
}),
);
}
/** The partition a reader needs: how many methods each lane reaches, and how many none does. */
export function counts(report: SelectionReport): {
declared: number;
host: number;
pr: number;
nightly: number;
nightlyIpad: number;
dark: number;
} {
return {
declared: report.declared.length,
host: report.reach.host.size,
pr: report.reach.pr.size,
nightly: report.reach.nightly.size,
nightlyIpad: report.reach['nightly-ipad'].size,
dark: report.dark.length,
};
}
/** The failures, or an empty list. Kept apart from formatting so the test can assert both. */
export function reportFailures(report: SelectionReport): string[] {
// A parser that stops matching would report "0 unknown" forever, which reads exactly
// like a healthy list. Both inputs are non-empty by construction, so an empty parse is
// the check going blind, not a real state of the tree.
if (report.missingWorkflows.length > 0) {
return [
`Missing guarded workflow(s): ${report.missingWorkflows.join(', ')}. This check names ` +
'them in its own output, so a renamed or deleted lane must be reflected in ' +
'LANES rather than leaving a claim nothing backs.',
];
}
if (report.declared.length === 0) {
return [
`Found no test methods in ${RUNNER_TESTS_DIR}. The declaration scan is broken, ` +
'so this check can no longer see a dropped test.',
];
}
if (report.flagged.length === 0) {
return [
'Found no `-only-testing:`/`-skip-testing:` entries in ' +
`${GUARDED_WORKFLOWS.join(', ')}. Either every lane stopped filtering (drop this ` +
'check), or the scan is broken and can no longer see a dropped test.',
];
}
const failures: string[] = [];
const flagLine = (entry: FlaggedTest) =>
` - ${entry.workflow}:${entry.line} (-${entry.flag}) ${entry.identifier}`;
if (report.unknown.length > 0) {
failures.push(
`${report.unknown.length} XCTest identifier(s) name a method no source declares:`,
...report.unknown.map(flagLine),
'xcodebuild matches nothing and still exits 0 for an unknown identifier, in both',
'directions: an unknown `-only-testing:` drops a test from the PR lane silently, and an',
'unknown `-skip-testing:` re-admits whatever a whole-bundle lane meant to leave out —',
`including ${report.target}/${ENTRY_POINT_METHOD}, the runner's 24-hour server entry point.`,
'Update the entry to the current name, or remove it.',
);
}
if (report.uncompiled.length > 0) {
failures.push(
`${report.uncompiled.length} XCTest identifier(s) name a method that lane's platform ` +
'never compiles:',
...report.uncompiled.map(flagLine),
"The method exists, but its `#if` guard compiles it out of that lane's build, so the",
'flag matches nothing there. Move the entry to a lane whose platform compiles it, or',
'widen the guard.',
);
}
failures.push(...report.prWorkflowWiringFailures);
failures.push(...report.sharedPlatformBranchFailures);
if (report.dark.length > 0) {
failures.push(
`${report.dark.length} declared XCTest method(s) are reachable by no lane:`,
...report.dark.map((identifier) => ` - ${identifier}`),
'The host lane runs everything the macOS build compiles, the nightly everything the iOS',
'build compiles, and the PR lane selects shared iOS branch methods; a method outside all three — usually',
'a guard naming a platform no lane runs — is dark from the day it is written. Widen the',
'guard or delete it.',
);
}
if (report.entryPointReachedBy.length > 0) {
failures.push(
`${report.target}/${ENTRY_POINT_METHOD} is reachable by lane(s): ` +
`${report.entryPointReachedBy.join(', ')}.`,
'It is not a test: it opens an NWListener and waits 24 hours for a client, so a lane that',
'runs it hangs until timeout-minutes. Whole-bundle lanes must keep their -skip-testing:',
'entry for it; the PR selector must exclude it.',
);
}
return failures;
}
export function formatSummary(report: SelectionReport): string {
const { declared, host, pr, nightly, nightlyIpad, dark } = counts(report);
return (
`xctest selection: ${declared} declared ${report.target} methods — host lane ` +
`(${HOST_XCTEST_SOURCE_FILE}, macOS, every PR) reaches ${host}, PR iOS branch lane (${PR_XCTEST_SOURCE_FILE}, ` +
`iOS Simulator, selected PRs and main) selects ${pr}, nightly (${NIGHTLY_WORKFLOW_FILE}, iOS Simulator) ` +
`reaches ${nightly}, its iPad leg selects ${nightlyIpad}; ${dark} reachable by no lane; ` +
`${ENTRY_POINT_METHOD} skipped everywhere.\n`
);
}
/** Reuse the package builder's source guard without writing dist or packing a tarball. */
export function runnerPackageSourceFailures(root: string = repoRoot): string[] {
const result = runCmdSync(
process.execPath,
[packageAppleRunnerScript, '--root', root, '--check', '--quiet'],
{ allowFailure: true },
);
if (result.exitCode === 0) return [];
const detail = (result.stderr || result.stdout).trim();
return [`Apple runner package source guard failed:\n${detail || 'unknown failure'}`];
}
function main(): number {
const report = loadReport();
if (process.argv.slice(2).includes('--ios-pr-tests')) {
const failures = reportFailures(report);
if (report.reach.pr.size === 0)
failures.push('The PR lane selected no shared iOS branch XCTest methods.');
if (failures.length > 0) {
process.stderr.write(`${failures.join('\n')}\n`);
return 1;
}
process.stdout.write(`${[...report.reach.pr].sort().join('\n')}\n`);
return 0;
}
const failures = [...reportFailures(report), ...runnerPackageSourceFailures()];
process.stdout.write(formatSummary(report));
if (failures.length === 0) return 0;
process.stderr.write(`${failures.join('\n')}\n`);
return 1;
}
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) process.exit(main());