@ultimat3/cli 31.47.1 → 31.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +30 -23
- package/README.md +96 -4
- package/package.json +29 -29
- package/src/api-registration.ts +28 -14
- package/src/app-load.ts +6 -1
- package/src/app-root.ts +7 -1
- package/src/clean-services.ts +142 -0
- package/src/cmd-auth.ts +3 -0
- package/src/cmd-clean-spec.ts +10 -3
- package/src/cmd-clean.ts +23 -9
- package/src/cmd-db-backfill.ts +6 -0
- package/src/cmd-db-branch.ts +10 -4
- package/src/cmd-db-recount.ts +5 -12
- package/src/cmd-db-rollback.ts +77 -0
- package/src/cmd-db-spec.ts +18 -2
- package/src/cmd-db-status.ts +5 -10
- package/src/cmd-db.ts +105 -33
- package/src/cmd-deploy-verify.ts +14 -6
- package/src/cmd-docs-topic.ts +94 -0
- package/src/cmd-docs.ts +15 -1
- package/src/cmd-doctor.ts +109 -41
- package/src/cmd-drill.ts +100 -19
- package/src/cmd-env.ts +30 -8
- package/src/cmd-errors-app.ts +63 -0
- package/src/cmd-errors.ts +50 -14
- package/src/cmd-generate.ts +17 -4
- package/src/cmd-heavy-spec.ts +36 -0
- package/src/cmd-heavy.ts +244 -0
- package/src/cmd-jobs.ts +27 -1
- package/src/cmd-merge-driver-spec.ts +12 -0
- package/src/cmd-merge-driver.ts +95 -0
- package/src/cmd-new.ts +23 -3
- package/src/cmd-policy-spec.ts +9 -1
- package/src/cmd-policy.ts +72 -17
- package/src/cmd-stop.ts +18 -4
- package/src/cmd-tasks-run.ts +87 -0
- package/src/cmd-tasks-spec.ts +10 -3
- package/src/cmd-tasks.ts +8 -5
- package/src/cmd-test.ts +15 -4
- package/src/cmd-upgrade-spec.ts +8 -1
- package/src/cmd-upgrade.ts +32 -5
- package/src/cmd-verify.ts +9 -41
- package/src/codemods/agents-doc-row.ts +73 -0
- package/src/codemods/define-error-leaf.ts +37 -12
- package/src/codemods/docs-many-agents.ts +26 -0
- package/src/codemods/docs-worker-commands.ts +26 -0
- package/src/codemods/index.ts +6 -0
- package/src/codemods/merge-drivers.ts +66 -0
- package/src/command.ts +3 -0
- package/src/db-applied-edits.ts +117 -0
- package/src/db-dev-wire.ts +18 -0
- package/src/db-diagnostics.ts +5 -10
- package/src/db-generate.ts +82 -7
- package/src/db-migrate-pass.ts +51 -0
- package/src/db-migrate-through-dev.ts +209 -0
- package/src/db-rollback-consent.ts +128 -0
- package/src/db-rollback-pass.ts +76 -0
- package/src/db-seed-generate.ts +5 -1
- package/src/db-seed.ts +7 -1
- package/src/deploy-verify-findings.ts +3 -0
- package/src/deploy-verify-grade.ts +3 -0
- package/src/deploy-verify-processes.ts +32 -0
- package/src/dev-boot.ts +3 -0
- package/src/dev-db-migrate.ts +155 -0
- package/src/dev-db-rollback.ts +33 -0
- package/src/dev-db-settled.ts +22 -0
- package/src/dev-lock-errors.ts +78 -0
- package/src/dev-lock-holder-dir.ts +64 -0
- package/src/dev-lock-live.ts +44 -0
- package/src/dev-lock.ts +59 -84
- package/src/dev-policy.ts +11 -8
- package/src/dev-rebuild-schema.ts +116 -13
- package/src/dev-rebuild.ts +13 -4
- package/src/dev-route-table.ts +7 -0
- package/src/dispatch.ts +21 -1
- package/src/doctor-advisory-floors.ts +30 -8
- package/src/doctor-api-listing.ts +114 -0
- package/src/doctor-guarded.ts +41 -0
- package/src/doctor-port.ts +90 -17
- package/src/doctor-probe.ts +36 -5
- package/src/doctor-processes-probe.ts +127 -0
- package/src/doctor-processes.ts +136 -0
- package/src/doctor-warnings.ts +17 -0
- package/src/error-codes-agents.ts +35 -0
- package/src/error-codes-processes.ts +30 -0
- package/src/error-codes-tooling.ts +11 -3
- package/src/error-codes.ts +12 -13
- package/src/errors-suite.ts +27 -0
- package/src/errors.ts +18 -22
- package/src/exec.ts +11 -3
- package/src/exercise-registration.ts +4 -3
- package/src/framework-env.ts +7 -3
- package/src/generate-files.ts +1 -0
- package/src/generate-grant-findings.ts +7 -5
- package/src/generate-grants.ts +9 -8
- package/src/generate-kinds.ts +30 -6
- package/src/generate-roles-file.ts +30 -0
- package/src/generate-slice-policy.ts +3 -3
- package/src/guards.ts +2 -2
- package/src/heavy-cores.ts +51 -0
- package/src/heavy-env.ts +21 -0
- package/src/heavy-errors.ts +54 -0
- package/src/heavy-flock.ts +73 -0
- package/src/heavy-holders.ts +78 -0
- package/src/heavy-ledger.ts +400 -0
- package/src/heavy-memory.ts +67 -0
- package/src/heavy-pressure.ts +104 -0
- package/src/heavy-weights.ts +47 -0
- package/src/heavy.ts +308 -0
- package/src/i18n-registration.ts +22 -2
- package/src/island-harness.ts +2 -2
- package/src/job-budget.ts +4 -2
- package/src/job-registration.ts +64 -8
- package/src/jobs-queue-known.ts +43 -0
- package/src/local-cli.ts +6 -5
- package/src/mcp-errors-agents.ts +20 -0
- package/src/mcp-errors-doctor.ts +27 -0
- package/src/mcp-errors-processes.ts +23 -0
- package/src/mcp-errors.ts +18 -29
- package/src/mcp-host.ts +2 -2
- package/src/merge-driver-catalog.ts +58 -0
- package/src/merge-driver-config.ts +43 -0
- package/src/merge-driver-lines.ts +140 -0
- package/src/merge-state.ts +105 -0
- package/src/messages-db.ts +22 -1
- package/src/messages-processes.ts +13 -0
- package/src/messages-upgrade.ts +6 -0
- package/src/messages.ts +62 -1
- package/src/output-findings.ts +48 -21
- package/src/parse.ts +37 -6
- package/src/policy-facts.ts +38 -21
- package/src/policy-row.ts +99 -0
- package/src/port-pair-free.ts +28 -0
- package/src/registry-lines.ts +110 -0
- package/src/registry.ts +4 -0
- package/src/retain-sweep.ts +1 -1
- package/src/role-replicator.ts +9 -4
- package/src/role-select.ts +86 -0
- package/src/role-start.ts +13 -55
- package/src/role-sync.ts +10 -5
- package/src/runtime-cache-frame.ts +46 -0
- package/src/runtime-cache-ttl.ts +23 -0
- package/src/runtime-cache.ts +56 -18
- package/src/runtime-database-ssl.ts +84 -0
- package/src/runtime-idempotency-scope.ts +16 -2
- package/src/runtime-jobs-share.ts +52 -0
- package/src/runtime-jobs.ts +43 -12
- package/src/runtime-overrides.ts +4 -2
- package/src/runtime-queue.ts +18 -3
- package/src/runtime-services.ts +8 -1
- package/src/schema-drift.ts +19 -2
- package/src/schema-dump-drift.ts +4 -1
- package/src/serve-boot-probe.ts +30 -2
- package/src/serve-boot.ts +11 -1
- package/src/serve-env.ts +39 -3
- package/src/serve.ts +61 -10
- package/src/stop-run-start.ts +12 -0
- package/src/supervise-boot.ts +61 -0
- package/src/supervise-cgroup.ts +84 -0
- package/src/supervise-child.ts +206 -0
- package/src/supervise-count.ts +244 -0
- package/src/supervise-errors.ts +83 -0
- package/src/supervise-facts.ts +40 -0
- package/src/supervise-messages.ts +84 -0
- package/src/supervise-policy.ts +46 -0
- package/src/supervise-pool.ts +10 -0
- package/src/supervise-probe.ts +158 -0
- package/src/supervise-run.ts +54 -0
- package/src/supervise.ts +383 -0
- package/src/templates/generate-purge.ts +6 -6
- package/src/templates/guard-animated-layout-property.ts +2 -2
- package/src/templates/guard-bare-error.ts +1 -1
- package/src/templates/guard-error-declared.ts +2 -2
- package/src/templates/guard-focus-visible.ts +1 -1
- package/src/templates/guard-image-dimensions.ts +2 -2
- package/src/templates/guard-island-mount-clears.ts +1 -1
- package/src/templates/guard-native-confirm.ts +1 -1
- package/src/templates/guard-raw-breakpoint.ts +2 -2
- package/src/templates/guard-raw-colour.ts +2 -2
- package/src/templates/guard-raw-fetch.ts +1 -1
- package/src/templates/guard-raw-interval.ts +1 -1
- package/src/templates/guard-raw-length.ts +3 -3
- package/src/templates/guard-raw-motion.ts +1 -1
- package/src/templates/guard-raw-shadow.ts +1 -1
- package/src/templates/guard-raw-z-index.ts +1 -1
- package/src/templates/guard-released-forms.ts +59 -13
- package/src/templates/guard-repo-await-in-loop.ts +1 -1
- package/src/templates/guard-repo-raw-sql.ts +4 -4
- package/src/templates/guard-repo-unbounded.ts +1 -1
- package/src/templates/guard-runtime-pin.ts +1 -1
- package/src/templates/guard-semantic-interactive.ts +2 -2
- package/src/templates/guard-unbounded-fanout.ts +1 -1
- package/src/templates/guard-undeclared-custom-property.ts +3 -3
- package/src/templates/guard-undefined-style-class.ts +3 -3
- package/src/templates/guard-unzoned-date.ts +3 -3
- package/src/templates/query-slice.ts +82 -0
- package/src/templates/query.ts +76 -30
- package/src/templates/resource-page.ts +3 -2
- package/src/templates/scaffold-bin.ts +2 -0
- package/src/templates/scaffold-claude-agents.ts +9 -6
- package/src/templates/scaffold-claude-commands.ts +7 -1
- package/src/templates/scaffold-claude.ts +4 -4
- package/src/templates/scaffold-container-compose.ts +47 -7
- package/src/templates/scaffold-docs.ts +11 -6
- package/src/templates/scaffold-gitattributes.ts +18 -1
- package/src/templates/scaffold-helm-templates.ts +9 -0
- package/src/templates/scaffold-repo.ts +4 -1
- package/src/templates/scaffold-test-services.ts +33 -11
- package/src/templates/shapes/offline.ts +0 -7
- package/src/templates/shapes/realtime.ts +2 -6
- package/src/templates/sign-in-action-tests.ts +6 -4
- package/src/templates/sign-in-challenge.ts +62 -0
- package/src/templates/sign-in-oidc-mfa.ts +31 -0
- package/src/templates/sign-in-oidc.ts +11 -3
- package/src/templates/sign-in-password.ts +18 -56
- package/src/test-batches.ts +9 -3
- package/src/test-shards.ts +117 -37
- package/src/test-slots.ts +35 -161
- package/src/test-verdict.ts +79 -0
- package/src/test-workers.ts +15 -0
- package/src/upgrade-gate-codemods.ts +5 -3
- package/src/upgrade-gate.ts +19 -1
- package/src/upgrade-merge-drivers.ts +25 -0
- package/src/upgrade-report.ts +18 -4
- package/src/upgrade-scope.ts +62 -0
- package/src/verify-checks.ts +6 -11
- package/src/verify-coverage-run.ts +9 -5
- package/src/verify-deadline.ts +18 -2
- package/src/verify-heavy-steps.ts +26 -0
- package/src/verify-live.ts +38 -14
- package/src/verify-only.ts +67 -0
- package/src/verify-progress.ts +7 -3
- package/src/verify-run.ts +20 -2
- package/src/verify-services-stack.ts +165 -0
- package/src/verify-services.ts +84 -2
- package/src/verify-test-run.ts +9 -9
- package/src/verify-tests.ts +35 -22
- package/src/verify-typecheck.ts +25 -2
- package/wiki/Actions.md +2 -1
- package/wiki/Admin-Dashboard.md +2 -2
- package/wiki/Agents.md +5 -5
- package/wiki/Auth.md +15 -5
- package/wiki/Bare-VM.md +1 -1
- package/wiki/Building-Your-Own-Base.md +15 -2
- package/wiki/CI-Parallel-Gate.md +4 -4
- package/wiki/CLI-Reference.md +127 -48
- package/wiki/Caching-And-Invalidation.md +2 -2
- package/wiki/Client-Navigation.md +1 -1
- package/wiki/Configuration.md +32 -13
- package/wiki/Deployment.md +44 -4
- package/wiki/Entities-And-Migrations.md +5 -1
- package/wiki/FAQ.md +1 -1
- package/wiki/Getting-Started.md +2 -2
- package/wiki/Home.md +2 -1
- package/wiki/I18n.md +5 -3
- package/wiki/Installation.md +12 -11
- package/wiki/Interface-Rules.md +1 -1
- package/wiki/Jobs-And-Workflows.md +24 -4
- package/wiki/Known-Gaps.md +2 -2
- package/wiki/MCP-And-AI.md +8 -5
- package/wiki/Mail.md +1 -1
- package/wiki/Many-Agents.md +127 -0
- package/wiki/Migrations-And-Backfills.md +18 -0
- package/wiki/Notify.md +1 -1
- package/wiki/Observability.md +13 -0
- package/wiki/Queries-And-Live-Queries.md +2 -2
- package/wiki/Realtime.md +10 -1
- package/wiki/Routes-And-Render-Modes.md +1 -1
- package/wiki/Scheduled-Tasks.md +4 -1
- package/wiki/Testing.md +12 -9
- package/wiki/Timezones-And-Dates.md +5 -1
- package/wiki/Troubleshooting.md +1 -0
- package/wiki/Tutorial-01-First-App.md +5 -5
- package/wiki/Tutorial-02-First-Feature.md +1 -1
- package/wiki/Tutorial-03-Auth-And-Admin.md +7 -6
- package/wiki/Upgrading.md +37 -0
package/src/test-shards.ts
CHANGED
|
@@ -46,20 +46,23 @@ import { join } from 'node:path';
|
|
|
46
46
|
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
47
47
|
import { ISOLATED_ENV } from '@ultimat3/testing';
|
|
48
48
|
import type { AffectedSelection } from './affected';
|
|
49
|
-
import type { Runner } from './exec';
|
|
49
|
+
import type { ExecResult, Runner } from './exec';
|
|
50
50
|
import { msg } from './messages';
|
|
51
51
|
import type { CommandResult, Finding, JsonValue, StepResult } from './output';
|
|
52
52
|
import { quoteArg } from './shell-quote';
|
|
53
53
|
import { testEnvOverrides } from './test-dotenv';
|
|
54
|
+
import type { MachineLease } from './test-slots';
|
|
54
55
|
|
|
55
56
|
/** Bun's per-file durations, cached under the run's root and refreshed by every parallel run. */
|
|
56
57
|
export const TEST_TIMINGS_FILE = '.x/test-timings.json';
|
|
57
58
|
|
|
58
59
|
import { runBatches, testBatches } from './test-batches';
|
|
60
|
+
import { countsOf } from './test-counts';
|
|
59
61
|
import { tidyBeforeTestRun } from './test-housekeeping';
|
|
60
62
|
import { testPasses } from './test-passes';
|
|
61
63
|
import type { TestFile } from './test-select';
|
|
62
64
|
import { loadTimings, SLOWEST_KEPT, slowestOf } from './test-timings';
|
|
65
|
+
import { allSkippedFinding, failingFiles } from './test-verdict';
|
|
63
66
|
import { BATCH_FILES_PER_WORKER, SHARED_BATCH_FILES_PER_WORKER } from './test-workers';
|
|
64
67
|
import type { TestType } from './verify-tests';
|
|
65
68
|
|
|
@@ -150,27 +153,30 @@ export interface ReproduceOptions {
|
|
|
150
153
|
* and the command still runs, over a different file set, which reproduces nothing.
|
|
151
154
|
*/
|
|
152
155
|
export function reproduceFor(options: ReproduceOptions): string {
|
|
156
|
+
return `x ${quoteArg(reproduceWords(options))}`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** `reproduceFor`'s words after `x`, unquoted: each is quoted on its own (`quoteArg`) where pasted. */
|
|
160
|
+
export function reproduceWords(options: ReproduceOptions): readonly string[] {
|
|
153
161
|
return [
|
|
154
|
-
'
|
|
155
|
-
...(options.type === undefined ? [] : [
|
|
156
|
-
...(options.filter === undefined ? [] : ['--filter',
|
|
162
|
+
'test',
|
|
163
|
+
...(options.type === undefined ? [] : [options.type]),
|
|
164
|
+
...(options.filter === undefined ? [] : ['--filter', options.filter]),
|
|
157
165
|
...(options.sample === undefined ? [] : ['--sample', String(options.sample)]),
|
|
158
166
|
// `--base` is emitted always rather than only when non-default: the default is `main`, and a
|
|
159
167
|
// rerun days later against a moved `main` is a different diff wearing the same flag.
|
|
160
|
-
...(options.affected === undefined
|
|
161
|
-
? []
|
|
162
|
-
: ['--affected', '--base', quoteArg(options.affected.base)]),
|
|
168
|
+
...(options.affected === undefined ? [] : ['--affected', '--base', options.affected.base]),
|
|
163
169
|
...(options.affected?.dirty === true ? ['--dirty'] : []),
|
|
164
170
|
'--workers',
|
|
165
171
|
String(options.workers),
|
|
166
172
|
...(options.isolate === true ? ['--isolate'] : []),
|
|
167
173
|
...(options.seed === undefined ? [] : ['--seed', String(options.seed)]),
|
|
168
174
|
// Last, and after a `--` of its own, because that is where the caller typed it and where the
|
|
169
|
-
// parser will find it again.
|
|
175
|
+
// parser will find it again.
|
|
170
176
|
...(options.passthrough === undefined || options.passthrough.length === 0
|
|
171
177
|
? []
|
|
172
|
-
: ['--', ...options.passthrough
|
|
173
|
-
]
|
|
178
|
+
: ['--', ...options.passthrough]),
|
|
179
|
+
];
|
|
174
180
|
}
|
|
175
181
|
|
|
176
182
|
export interface RunShardsOptions {
|
|
@@ -201,7 +207,7 @@ export interface RunShardsOptions {
|
|
|
201
207
|
/** `--seed`: handed to the children by the caller's runner, printed back in the reproduce. */
|
|
202
208
|
readonly seed?: number;
|
|
203
209
|
/** The machine-pool lease (`test-slots.ts`), for a default-width run. */
|
|
204
|
-
readonly lease?:
|
|
210
|
+
readonly lease?: MachineLease;
|
|
205
211
|
}
|
|
206
212
|
|
|
207
213
|
const isolatedRun = (options: RunShardsOptions): boolean => {
|
|
@@ -232,16 +238,56 @@ const planOf = (
|
|
|
232
238
|
: { passthrough: options.passthrough }),
|
|
233
239
|
});
|
|
234
240
|
|
|
241
|
+
/** The failing files shown in a cause; the rest are counted. */
|
|
242
|
+
const SHOWN_FAILING = 5;
|
|
243
|
+
|
|
244
|
+
/** `plan` narrowed to one file, alone: the rerun of a failure that is not the whole suite again. */
|
|
245
|
+
const narrowedTo = (plan: ReproduceOptions, file: string): ReproduceOptions => ({
|
|
246
|
+
workers: 1,
|
|
247
|
+
filter: file,
|
|
248
|
+
...(plan.type === undefined ? {} : { type: plan.type }),
|
|
249
|
+
...(plan.isolate === true ? { isolate: true } : {}),
|
|
250
|
+
...(plan.seed === undefined ? {} : { seed: plan.seed }),
|
|
251
|
+
...(plan.passthrough === undefined ? {} : { passthrough: plan.passthrough }),
|
|
252
|
+
});
|
|
253
|
+
|
|
235
254
|
/**
|
|
236
|
-
* `X_TEST_FAILED
|
|
237
|
-
*
|
|
255
|
+
* `X_TEST_FAILED`. With the failing files read out of bun's output, the cause names them and the
|
|
256
|
+
* fix reruns the first one alone — rerunning the selection that just failed is the line the
|
|
257
|
+
* reader already ran. Only when bun named no file is the fix the whole reproduction.
|
|
258
|
+
* `X_TEST_SHARD_FAILED` was the `--worker` rerun's and went with it: registered, unthrown.
|
|
238
259
|
*/
|
|
239
|
-
export const failureOf = (
|
|
240
|
-
code:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
260
|
+
export const failureOf = (
|
|
261
|
+
code: number,
|
|
262
|
+
files: number,
|
|
263
|
+
plan: ReproduceOptions,
|
|
264
|
+
failing: readonly string[] = [],
|
|
265
|
+
): Finding => {
|
|
266
|
+
const first = failing[0];
|
|
267
|
+
const more = failing.length > SHOWN_FAILING ? ` (+${failing.length - SHOWN_FAILING} more)` : '';
|
|
268
|
+
const named =
|
|
269
|
+
first === undefined ? '' : `; failing: ${failing.slice(0, SHOWN_FAILING).join(', ')}${more}`;
|
|
270
|
+
return {
|
|
271
|
+
code: 'X_TEST_FAILED',
|
|
272
|
+
cause: `${plan.type ?? 'test'} run exited ${code} across ${plan.workers} worker(s) (${files} file(s))${named}`,
|
|
273
|
+
fix: reproduceFor(first === undefined ? plan : narrowedTo(plan, first)),
|
|
274
|
+
docs: ERROR_DOCS_URL,
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
/** The environment the children saw: this process's, with the overrides applied (undefined unsets). */
|
|
279
|
+
const childEnv = (
|
|
280
|
+
env: Readonly<Record<string, string | undefined>>,
|
|
281
|
+
overrides: Readonly<Record<string, string | undefined>>,
|
|
282
|
+
): Readonly<Record<string, string | undefined>> => {
|
|
283
|
+
// A Map, never a keyed object: an env key is any string, `__proto__` included.
|
|
284
|
+
const out = new Map(Object.entries(env));
|
|
285
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
286
|
+
if (value === undefined) out.delete(key);
|
|
287
|
+
else out.set(key, value);
|
|
288
|
+
}
|
|
289
|
+
return Object.fromEntries(out);
|
|
290
|
+
};
|
|
245
291
|
|
|
246
292
|
/**
|
|
247
293
|
* ONE `bun test` PER BATCH, a pass being as many batches as `test-batches.ts` cuts it into, and
|
|
@@ -279,8 +325,10 @@ export async function runShards(options: RunShardsOptions): Promise<CommandResul
|
|
|
279
325
|
const steps: StepResult[] = [];
|
|
280
326
|
const spent: JsonValue[] = [];
|
|
281
327
|
let batchCount = 0;
|
|
328
|
+
let peak = 1;
|
|
282
329
|
let ok = true;
|
|
283
330
|
let exitCode = 0;
|
|
331
|
+
const results: ExecResult[] = [];
|
|
284
332
|
for (const pass of passes) {
|
|
285
333
|
const files = pass.files.map((file) => file.path);
|
|
286
334
|
// `-- --watch` is never split: it never exits, so a second batch would never start. Every
|
|
@@ -297,8 +345,7 @@ export async function runShards(options: RunShardsOptions): Promise<CommandResul
|
|
|
297
345
|
batches,
|
|
298
346
|
stopOnFailure: bailing,
|
|
299
347
|
workers: pass.workers,
|
|
300
|
-
|
|
301
|
-
...(pass.workers > 1 && options.lease !== undefined ? { lease: options.lease } : {}),
|
|
348
|
+
...(options.lease === undefined ? {} : { lease: options.lease }),
|
|
302
349
|
argsFor: (batch, width) =>
|
|
303
350
|
testArgs({
|
|
304
351
|
files: batch,
|
|
@@ -314,7 +361,13 @@ export async function runShards(options: RunShardsOptions): Promise<CommandResul
|
|
|
314
361
|
});
|
|
315
362
|
batchCount += batches.length;
|
|
316
363
|
const plan = planOf(options, pass);
|
|
317
|
-
|
|
364
|
+
// What ran, not what was asked: the machine lease may hold every batch below the plan.
|
|
365
|
+
const reached = Math.max(1, ...result.widths);
|
|
366
|
+
peak = Math.max(peak, reached);
|
|
367
|
+
const narrowed = reached < pass.workers;
|
|
368
|
+
const label = narrowed
|
|
369
|
+
? msg('cli.test.narrowed', { peak: reached, planned: pass.workers })
|
|
370
|
+
: `${pass.workers} worker(s)`;
|
|
318
371
|
steps.push({
|
|
319
372
|
name: `${pass.type === undefined ? label : `${pass.type} · ${label}`} · ${files.length} files${
|
|
320
373
|
batches.length > 1 ? msg('cli.test.batches', { batches: batches.length }) : ''
|
|
@@ -323,14 +376,17 @@ export async function runShards(options: RunShardsOptions): Promise<CommandResul
|
|
|
323
376
|
durationMs: result.durationMs,
|
|
324
377
|
// `output.ts` documents this field as absent for a NON-test step, so omitting it here made
|
|
325
378
|
// `renderJson` describe the test step as one — recoverable only by parsing `name`.
|
|
326
|
-
workers:
|
|
327
|
-
findings: result.ok
|
|
379
|
+
workers: reached,
|
|
380
|
+
findings: result.ok
|
|
381
|
+
? []
|
|
382
|
+
: [failureOf(result.code, files.length, plan, failingFiles(result.output, files))],
|
|
328
383
|
output: result.output,
|
|
329
384
|
});
|
|
330
385
|
spent.push({
|
|
331
386
|
...(pass.type === undefined ? {} : { type: pass.type }),
|
|
332
387
|
files: files.length,
|
|
333
388
|
workers: pass.workers,
|
|
389
|
+
...(narrowed ? { peakWorkers: reached } : {}),
|
|
334
390
|
...(batches.length > 1 ? { batches: batches.length } : {}),
|
|
335
391
|
ok: result.ok,
|
|
336
392
|
exitCode: result.code,
|
|
@@ -338,6 +394,7 @@ export async function runShards(options: RunShardsOptions): Promise<CommandResul
|
|
|
338
394
|
});
|
|
339
395
|
ok = ok && result.ok;
|
|
340
396
|
if (exitCode === 0) exitCode = result.code;
|
|
397
|
+
results.push(...result.results);
|
|
341
398
|
}
|
|
342
399
|
const durationMs = Math.round(performance.now() - started);
|
|
343
400
|
const fileCount = options.files.length;
|
|
@@ -350,7 +407,7 @@ export async function runShards(options: RunShardsOptions): Promise<CommandResul
|
|
|
350
407
|
SLOWEST_KEPT,
|
|
351
408
|
);
|
|
352
409
|
// Each pass's line names its own slowest, so a mixed run's serial half is not hidden by the rest.
|
|
353
|
-
|
|
410
|
+
let timedSteps = steps.map((step, index) => {
|
|
354
411
|
const own = slowestOf(timings, passes[index]?.files.map((file) => file.path) ?? []);
|
|
355
412
|
return own.length === 0 ? step : { ...step, slowest: own };
|
|
356
413
|
});
|
|
@@ -362,12 +419,33 @@ export async function runShards(options: RunShardsOptions): Promise<CommandResul
|
|
|
362
419
|
workers,
|
|
363
420
|
...(options.type === undefined ? {} : { type: options.type }),
|
|
364
421
|
});
|
|
422
|
+
// `bun test` exits 0 over a run whose every test skipped itself: only the counts say nothing ran.
|
|
423
|
+
const counts = countsOf(results);
|
|
424
|
+
const skippedOnly = ok && !watching && counts.ran === 0 && counts.skipped > 0;
|
|
425
|
+
if (skippedOnly) {
|
|
426
|
+
const finding = allSkippedFinding({
|
|
427
|
+
...(options.type === undefined ? {} : { type: options.type }),
|
|
428
|
+
skipped: counts.skipped,
|
|
429
|
+
files: options.files.map((file) => file.path),
|
|
430
|
+
env: childEnv(options.env ?? Bun.env, envOverrides),
|
|
431
|
+
rerun: reproduceWords(plan),
|
|
432
|
+
});
|
|
433
|
+
timedSteps = timedSteps.map((step) => ({
|
|
434
|
+
...step,
|
|
435
|
+
ok: false,
|
|
436
|
+
findings: [...step.findings, finding],
|
|
437
|
+
}));
|
|
438
|
+
ok = false;
|
|
439
|
+
exitCode = 1;
|
|
440
|
+
}
|
|
365
441
|
const type = options.type;
|
|
366
442
|
const typeParam = type === undefined ? {} : { type };
|
|
367
443
|
const sample = options.sample;
|
|
368
444
|
const data: JsonValue = {
|
|
369
445
|
...typeParam,
|
|
370
446
|
workers,
|
|
447
|
+
// Only when the machine held the run below `workers`, which stays the width to reproduce with.
|
|
448
|
+
...(peak < workers ? { peakWorkers: peak } : {}),
|
|
371
449
|
files: fileCount,
|
|
372
450
|
durationMs,
|
|
373
451
|
...(options.filter === undefined ? {} : { filter: options.filter }),
|
|
@@ -386,18 +464,20 @@ export async function runShards(options: RunShardsOptions): Promise<CommandResul
|
|
|
386
464
|
return {
|
|
387
465
|
ok,
|
|
388
466
|
command: 'test',
|
|
389
|
-
summary:
|
|
390
|
-
? msg(
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
467
|
+
summary: skippedOnly
|
|
468
|
+
? msg('cli.test.allSkipped', { label: type ?? 'test', skipped: counts.skipped })
|
|
469
|
+
: ok
|
|
470
|
+
? msg(type === undefined ? 'cli.test.pass' : 'cli.test.type.pass', {
|
|
471
|
+
...typeParam,
|
|
472
|
+
files: fileCount,
|
|
473
|
+
workers: Math.min(peak, workers),
|
|
474
|
+
ms: durationMs,
|
|
475
|
+
})
|
|
476
|
+
: msg(type === undefined ? 'cli.test.fail' : 'cli.test.type.fail', {
|
|
477
|
+
...typeParam,
|
|
478
|
+
failed: steps.filter((step) => !step.ok).length,
|
|
479
|
+
workers,
|
|
480
|
+
}),
|
|
401
481
|
steps: timedSteps,
|
|
402
482
|
...(sample === undefined
|
|
403
483
|
? {}
|
package/src/test-slots.ts
CHANGED
|
@@ -1,168 +1,42 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// agents' gates on one 45 GB box each planned 14-18 workers off the same free-memory reading and
|
|
5
|
-
// the kernel OOM-killed the machine with 36 `bun` processes holding ~40 GB. So each batch of
|
|
6
|
-
// workers first LEASES that many slots from a pool of lock files — one file per worker the machine
|
|
7
|
-
// budget allows — and a second run on the same box gets what is left: it runs narrower, or waits
|
|
8
|
-
// for one slot, instead of doubling the machine's memory.
|
|
9
|
-
//
|
|
10
|
-
// A slot is a file created with O_EXCL holding the leasing process's pid. A holder that died
|
|
11
|
-
// without releasing (SIGKILL, OOM, a closed terminal) is detected by its pid no longer existing,
|
|
12
|
-
// and its slot is taken over. Nothing here needs a daemon, and nothing survives a reboot that
|
|
13
|
-
// matters: the directory is under the OS temp dir.
|
|
14
|
-
//
|
|
15
|
-
// Bun ships no O_EXCL create and no pid probe: `openSync(…, 'wx')` and `process.kill(pid, 0)` are
|
|
16
|
-
// the node:fs / process primitives for exactly those two.
|
|
17
|
-
// why: Bun ships no O_EXCL create (writeFileSync flag 'wx') and no sync unlink/mkdir.
|
|
18
|
-
import { mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
19
|
-
// why: Bun exposes no tmpdir(); only node:os answers the platform temp root.
|
|
20
|
-
import { tmpdir } from 'node:os';
|
|
21
|
-
// why: Bun ships no path-join primitive.
|
|
22
|
-
import { join } from 'node:path';
|
|
1
|
+
// A test run's share of the machine: each batch of `bun test` workers reserves its measured memory
|
|
2
|
+
// in the machine ledger (`heavy-ledger.ts`) and takes the width the core cap and the ledger allow,
|
|
3
|
+
// so a second run on the same box narrows or queues instead of doubling its memory.
|
|
23
4
|
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
import type { WorkerLease } from './heavy';
|
|
6
|
+
import { leaseWorkers } from './heavy';
|
|
7
|
+
import type { HeavyEnv } from './heavy-env';
|
|
8
|
+
import { E2E_LANE_PEAK_MB, TEST_RUN_BASE_MB, TEST_WORKER_PEAK_MB } from './heavy-weights';
|
|
26
9
|
|
|
27
|
-
/** `0` turns the
|
|
10
|
+
/** `0` turns the lease off for one run; the ledger's own switch is `ULTIMATE_HEAVY_MEMORY=0`. */
|
|
28
11
|
export const SLOTS_ENV = 'ULTIMATE_TEST_SLOTS';
|
|
29
12
|
|
|
30
|
-
|
|
31
|
-
* Set on every `bun test` a leased batch spawns: the slots are already held for that process
|
|
32
|
-
* tree, so an `x test` / `x verify` a test runs inside it (the framework's own suites do) must
|
|
33
|
-
* not lease again — it would wait on its own parent's slots.
|
|
34
|
-
*/
|
|
35
|
-
export const SLOT_HELD_ENV = 'ULTIMATE_TEST_SLOT_HELD';
|
|
13
|
+
export type MachineLease = (want: number) => Promise<WorkerLease>;
|
|
36
14
|
|
|
37
|
-
/**
|
|
38
|
-
export const
|
|
15
|
+
/** What a run of this suite reserves: a browser lane is one measured whole. */
|
|
16
|
+
export const suiteWeight = (
|
|
17
|
+
type: string | undefined,
|
|
18
|
+
): { readonly unitMb: number; readonly baseMb: number } =>
|
|
19
|
+
type === 'e2e'
|
|
20
|
+
? { unitMb: E2E_LANE_PEAK_MB, baseMb: 0 }
|
|
21
|
+
: { unitMb: TEST_WORKER_PEAK_MB, baseMb: TEST_RUN_BASE_MB };
|
|
39
22
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
type Env = Readonly<Record<string, string | undefined>>;
|
|
43
|
-
|
|
44
|
-
export const slotsDir = (env: Env = Bun.env): string =>
|
|
45
|
-
env[SLOTS_DIR_ENV] ??
|
|
46
|
-
join(tmpdir(), `ultimate-test-slots-${String(process.getuid?.() ?? 'user')}`);
|
|
47
|
-
|
|
48
|
-
export const slotsEnabled = (env: Env = Bun.env): boolean =>
|
|
49
|
-
env[SLOTS_ENV] !== '0' && env[SLOT_HELD_ENV] !== '1' && Bun.env[SLOT_HELD_ENV] !== '1';
|
|
50
|
-
|
|
51
|
-
/** A lease on `count` workers' worth of the machine. `count` is at least 1. */
|
|
52
|
-
export interface SlotLease {
|
|
53
|
-
readonly count: number;
|
|
54
|
-
/** Slots actually held — 0 when the wait ran out and the run went ahead unleased. */
|
|
55
|
-
readonly held: number;
|
|
56
|
-
/** How long the lease waited for its first slot. */
|
|
57
|
-
readonly waitedMs: number;
|
|
58
|
-
release(): void;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const pidAlive = (pid: number): boolean => {
|
|
62
|
-
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
63
|
-
try {
|
|
64
|
-
process.kill(pid, 0);
|
|
65
|
-
return true;
|
|
66
|
-
} catch (error) {
|
|
67
|
-
// EPERM is a live process another user owns — alive, and not ours to take.
|
|
68
|
-
return (error as { code?: string } | null)?.code === 'EPERM';
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export interface AcquireInput {
|
|
73
|
-
/** Workers this batch wants. */
|
|
74
|
-
readonly want: number;
|
|
75
|
-
/** Slots the machine budget allows in all — `defaultWorkers()` for this box. */
|
|
76
|
-
readonly capacity: number;
|
|
77
|
-
readonly dir?: string;
|
|
78
|
-
readonly pid?: number;
|
|
79
|
-
readonly alive?: (pid: number) => boolean;
|
|
80
|
-
readonly waitMs?: number;
|
|
81
|
-
readonly sleep?: (ms: number) => Promise<void>;
|
|
82
|
-
readonly now?: () => number;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Take one slot file, or take it over from a dead holder. */
|
|
86
|
-
function tryTake(path: string, pid: number, alive: (pid: number) => boolean): boolean {
|
|
87
|
-
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
88
|
-
try {
|
|
89
|
-
writeFileSync(path, String(pid), { flag: 'wx' });
|
|
90
|
-
return true;
|
|
91
|
-
} catch (error) {
|
|
92
|
-
if ((error as { code?: string } | null)?.code !== 'EEXIST') return false;
|
|
93
|
-
}
|
|
94
|
-
let holder: number;
|
|
95
|
-
try {
|
|
96
|
-
holder = Number.parseInt(readFileSync(path, 'utf8'), 10);
|
|
97
|
-
} catch {
|
|
98
|
-
// Released between the create and the read: try the create once more.
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
if (alive(holder)) return false;
|
|
102
|
-
try {
|
|
103
|
-
unlinkSync(path);
|
|
104
|
-
} catch {
|
|
105
|
-
// Another run took it over first; the second create decides.
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Lease up to `want` slots out of `capacity`. Never zero: with every slot held, it polls until one
|
|
113
|
-
* frees, and after `waitMs` it runs one worker unleased rather than hang a gate forever.
|
|
114
|
-
*/
|
|
115
|
-
export async function acquireSlots(input: AcquireInput): Promise<SlotLease> {
|
|
116
|
-
const dir = input.dir ?? slotsDir();
|
|
117
|
-
const pid = input.pid ?? process.pid;
|
|
118
|
-
const alive = input.alive ?? pidAlive;
|
|
119
|
-
const sleep = input.sleep ?? ((ms: number) => Bun.sleep(ms));
|
|
120
|
-
const now = input.now ?? (() => performance.now());
|
|
121
|
-
const want = Math.max(1, Math.trunc(input.want));
|
|
122
|
-
const capacity = Math.max(1, Math.trunc(input.capacity));
|
|
123
|
-
mkdirSync(dir, { recursive: true });
|
|
124
|
-
const started = now();
|
|
125
|
-
const waitMs =
|
|
126
|
-
input.waitMs !== undefined && Number.isFinite(input.waitMs) && input.waitMs >= 0
|
|
127
|
-
? input.waitMs
|
|
128
|
-
: SLOT_WAIT_MS;
|
|
129
|
-
const deadline = started + waitMs;
|
|
130
|
-
for (;;) {
|
|
131
|
-
const held: string[] = [];
|
|
132
|
-
for (let index = 0; index < capacity && held.length < want; index += 1) {
|
|
133
|
-
const path = join(dir, `slot-${String(index)}`);
|
|
134
|
-
if (tryTake(path, pid, alive)) held.push(path);
|
|
135
|
-
}
|
|
136
|
-
if (held.length > 0 || now() >= deadline) {
|
|
137
|
-
const waitedMs = Math.round(now() - started);
|
|
138
|
-
let released = false;
|
|
139
|
-
return {
|
|
140
|
-
count: Math.max(1, held.length),
|
|
141
|
-
held: held.length,
|
|
142
|
-
waitedMs,
|
|
143
|
-
release: () => {
|
|
144
|
-
if (released) return;
|
|
145
|
-
released = true;
|
|
146
|
-
for (const path of held) {
|
|
147
|
-
try {
|
|
148
|
-
if (readFileSync(path, 'utf8') === String(pid)) unlinkSync(path);
|
|
149
|
-
} catch {
|
|
150
|
-
// Already gone — a crashed-holder sweep by another run took it.
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
await sleep(POLL_MS);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* The lease a default-width run takes per batch, or none: an explicit `--workers` is the caller's
|
|
162
|
-
* call (as it is over the budget), and `ULTIMATE_TEST_SLOTS=0` turns the pool off.
|
|
163
|
-
*/
|
|
23
|
+
/** `exact` is an explicit `--workers`: that width, waited for, and no core cap. */
|
|
164
24
|
export const machineLease = (
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
25
|
+
env: HeavyEnv,
|
|
26
|
+
input: {
|
|
27
|
+
readonly cwd: string;
|
|
28
|
+
readonly label: string;
|
|
29
|
+
readonly type?: string;
|
|
30
|
+
readonly exact?: boolean;
|
|
31
|
+
},
|
|
32
|
+
): MachineLease | undefined =>
|
|
33
|
+
env[SLOTS_ENV] === '0'
|
|
34
|
+
? undefined
|
|
35
|
+
: (want) =>
|
|
36
|
+
leaseWorkers(want, {
|
|
37
|
+
label: input.label,
|
|
38
|
+
cwd: input.cwd,
|
|
39
|
+
env,
|
|
40
|
+
...suiteWeight(input.type),
|
|
41
|
+
...(input.exact === true ? { exact: true } : {}),
|
|
42
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// What a finished `x test` run says beyond its exit code: which files failed, read out of bun's own
|
|
2
|
+
// per-file headers, and why a run in which every test skipped itself is not a pass. Split from
|
|
3
|
+
// `test-shards.ts`, which spends the files; this file only reads what came back.
|
|
4
|
+
|
|
5
|
+
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
6
|
+
import { TEST_SERVICE_ENV, TEST_SERVICES_START } from '@ultimat3/testing';
|
|
7
|
+
import type { Finding } from './output';
|
|
8
|
+
import { quoteArg } from './shell-quote';
|
|
9
|
+
|
|
10
|
+
/** Bun prints `<path>:` above a file's own lines, and only for a file that printed something. */
|
|
11
|
+
const HEADER = /^(\S.*):$/;
|
|
12
|
+
/** What makes a file's section a failure: a failed test, or an error outside any test. */
|
|
13
|
+
const FAILED = /^\(fail\) |^# Unhandled error/;
|
|
14
|
+
|
|
15
|
+
const normal = (path: string): string => path.split('\\').join('/').replace(/^\.\//, '');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The run's files whose section in bun's output holds a failure, in the order bun printed them.
|
|
19
|
+
* A header naming no file of the run is ignored, so a log line ending in `:` is never a file.
|
|
20
|
+
*/
|
|
21
|
+
export function failingFiles(output: string, files: readonly string[]): readonly string[] {
|
|
22
|
+
const known = new Set(files.map(normal));
|
|
23
|
+
const failing: string[] = [];
|
|
24
|
+
let current: string | undefined;
|
|
25
|
+
for (const line of output.split('\n')) {
|
|
26
|
+
const header = HEADER.exec(line.trimEnd())?.[1];
|
|
27
|
+
if (header !== undefined && known.has(normal(header))) {
|
|
28
|
+
current = normal(header);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (current !== undefined && FAILED.test(line) && !failing.includes(current)) {
|
|
32
|
+
failing.push(current);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return failing;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type Env = Readonly<Record<string, string | undefined>>;
|
|
39
|
+
|
|
40
|
+
/** The service variables the children ran without: a test that `needs` one skips over it. */
|
|
41
|
+
const unsetServices = (env: Env): readonly string[] =>
|
|
42
|
+
Object.values(TEST_SERVICE_ENV).filter((key) => (env[key]?.trim() ?? '') === '');
|
|
43
|
+
|
|
44
|
+
const SHOWN_FILES = 3;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A run whose every test skipped itself executed nothing, and `bun test` still exits 0 over it —
|
|
48
|
+
* so "passed" would be the one answer that is certainly wrong. `X_TEST_FAILED`: the type ran no
|
|
49
|
+
* check. The cause names what the children lacked; the fix starts it, or shows each skip's
|
|
50
|
+
* condition when nothing the framework knows of was missing.
|
|
51
|
+
*/
|
|
52
|
+
export function allSkippedFinding(input: {
|
|
53
|
+
readonly type?: string;
|
|
54
|
+
readonly skipped: number;
|
|
55
|
+
readonly files: readonly string[];
|
|
56
|
+
/** The environment the `bun test` children saw. */
|
|
57
|
+
readonly env: Env;
|
|
58
|
+
/** `reproduceWords`: the selection's words after `x`, every selector kept, quoted here. */
|
|
59
|
+
readonly rerun: readonly string[];
|
|
60
|
+
}): Finding {
|
|
61
|
+
const missing = unsetServices(input.env);
|
|
62
|
+
const label = input.type ?? 'test';
|
|
63
|
+
const why =
|
|
64
|
+
missing.length === 0
|
|
65
|
+
? 'each skip is its own condition in the file (a skipIf, a test.skip, a needs: whose service is unset)'
|
|
66
|
+
: `the run's environment leaves ${missing.join(', ')} unset, and a test that needs that service skips without it`;
|
|
67
|
+
const shown = input.files.slice(0, SHOWN_FILES).map(quoteArg).join(' ');
|
|
68
|
+
return {
|
|
69
|
+
code: 'X_TEST_FAILED',
|
|
70
|
+
cause: `${label} run executed 0 of ${input.skipped} test(s): every one skipped itself, so nothing was checked — ${why}`,
|
|
71
|
+
fix:
|
|
72
|
+
missing.length === 0
|
|
73
|
+
? `grep -nE 'skip|needs:' ${shown} # set what each skip waits for, then: x ${quoteArg(input.rerun)}`
|
|
74
|
+
: // The reproduce line, whole: `--affected`, `--sample` and a passthrough decide the
|
|
75
|
+
// selection, and a rebuilt `x test <type> --filter` reran a broader one.
|
|
76
|
+
`${TEST_SERVICES_START} && x ${quoteArg(input.rerun)} # this selection, now with the services`,
|
|
77
|
+
docs: ERROR_DOCS_URL,
|
|
78
|
+
};
|
|
79
|
+
}
|
package/src/test-workers.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { cpus, totalmem } from 'node:os';
|
|
10
10
|
import { UltimateError } from '@ultimat3/core';
|
|
11
11
|
import type { TestType } from '@ultimat3/testing';
|
|
12
|
+
import { msg } from './messages';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* `ULTIMATE_TEST_MEMORY_BUDGET` or `ULTIMATE_TEST_MAX_WORKERS` set to something that does not
|
|
@@ -227,6 +228,20 @@ export function workerPlan(
|
|
|
227
228
|
return { workers, budgetBytes, boundBy, reason: `${String(workers)} ${noun} (${why})` };
|
|
228
229
|
}
|
|
229
230
|
|
|
231
|
+
/**
|
|
232
|
+
* A plan cut short by the selection: one worker per file. It read `4 of 6 workers`, and a run the
|
|
233
|
+
* machine then narrowed read `2 of 4 of 6 workers`.
|
|
234
|
+
*/
|
|
235
|
+
export const fileBoundWidth = (files: number, reason: string): string =>
|
|
236
|
+
`${String(files)} ${files === 1 ? 'worker' : 'workers'}, one per file (plan: ${reason})`;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* The step line's width: the plan when the run reached it, else the widest batch beside the plan.
|
|
240
|
+
* Never "held by another run": the core cap narrows a run on a machine with nobody else on it.
|
|
241
|
+
*/
|
|
242
|
+
export const reachedWidth = (peak: number, planned: number, reason: string): string =>
|
|
243
|
+
peak < planned ? msg('cli.test.narrowedWhy', { peak, planned, reason }) : reason;
|
|
244
|
+
|
|
230
245
|
/** The width alone — `workerPlan(...).workers`. */
|
|
231
246
|
export const defaultWorkers = (
|
|
232
247
|
cpus: number = availableCpus(),
|
|
@@ -15,6 +15,7 @@ import { LOCAL_CLI_BIN } from './local-cli';
|
|
|
15
15
|
import type { Finding } from './output';
|
|
16
16
|
import { documentIn } from './upgrade-document';
|
|
17
17
|
import { manifestSnapshot, reinstallIfMoved } from './upgrade-gate-codemods-install';
|
|
18
|
+
import { installMergeDrivers } from './upgrade-merge-drivers';
|
|
18
19
|
import type { HopCodemods } from './upgrade-report-codemods';
|
|
19
20
|
|
|
20
21
|
const SKIP = t.object({ path: t.string, reason: t.string, diff: t.optional(t.string) });
|
|
@@ -106,9 +107,10 @@ export async function applyHopCodemods(input: {
|
|
|
106
107
|
})),
|
|
107
108
|
source: 'driver',
|
|
108
109
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
const reinstalled = await reinstallIfMoved({ runner, root, to, before });
|
|
111
|
+
// After the install: the driver command runs the app's own `node_modules/.bin/x`.
|
|
112
|
+
await installMergeDrivers(runner, root);
|
|
113
|
+
return reinstalled ? { ...report, reinstalled: true } : report;
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
/**
|
package/src/upgrade-gate.ts
CHANGED
|
@@ -21,6 +21,7 @@ import type { BaselinedGuard, WithheldGuard } from './upgrade-guards';
|
|
|
21
21
|
import { installMissingGuards } from './upgrade-guards';
|
|
22
22
|
import { parseJson } from './upgrade-registry';
|
|
23
23
|
import type { HopCodemods } from './upgrade-report-codemods';
|
|
24
|
+
import { installedNotRun } from './upgrade-scope';
|
|
24
25
|
|
|
25
26
|
// Where it always was: `verify-exercise.ts` and `verify-budgets-build.ts` read it from here.
|
|
26
27
|
export { documentIn } from './upgrade-document';
|
|
@@ -145,6 +146,10 @@ export interface HopGate {
|
|
|
145
146
|
/** The steps that went red, whether or not they carried a finding. */
|
|
146
147
|
readonly failed: readonly string[];
|
|
147
148
|
readonly findings: readonly GateFinding[];
|
|
149
|
+
/** `x upgrade --only`'s list, as run; absent when the hop ran the full gate. */
|
|
150
|
+
readonly only?: readonly string[];
|
|
151
|
+
/** The gate's steps this hop did NOT run, owed elsewhere (CI); absent beside a full gate. */
|
|
152
|
+
readonly notRun?: readonly string[];
|
|
148
153
|
};
|
|
149
154
|
}
|
|
150
155
|
|
|
@@ -254,6 +259,8 @@ export async function runHopGate(input: {
|
|
|
254
259
|
readonly bunMoved?: CoverageRebaseline;
|
|
255
260
|
/** The span whose codemods run first, so every later stage judges the carried-across tree. */
|
|
256
261
|
readonly codemods?: { readonly from: string; readonly to: string };
|
|
262
|
+
/** `x upgrade --only`: verify narrowed to these steps, a strict subset of the gate's. */
|
|
263
|
+
readonly only?: { readonly steps: readonly string[]; readonly notRun: readonly string[] };
|
|
257
264
|
}): Promise<HopGate> {
|
|
258
265
|
const { runner, root, onStage } = input;
|
|
259
266
|
const installed = (args: readonly string[]): Promise<ExecResult> =>
|
|
@@ -294,7 +301,18 @@ export async function runHopGate(input: {
|
|
|
294
301
|
// Before `verify`, from the report that exercise just wrote: the gate judges the figures it holds.
|
|
295
302
|
const exerciseFloor = await ratchetExerciseFloor(root, stamp);
|
|
296
303
|
onStage('verify');
|
|
297
|
-
const
|
|
304
|
+
const { only } = input;
|
|
305
|
+
// The installed gate's own list first: the steps owed to CI are steps that CLI has. None owed
|
|
306
|
+
// (every one of its steps named) is that CLI's full gate, run and reported as one.
|
|
307
|
+
const notRun = only === undefined ? undefined : await installedNotRun(installed, only);
|
|
308
|
+
const verify =
|
|
309
|
+
only === undefined || notRun === undefined || notRun.length === 0
|
|
310
|
+
? readVerify(await installed(['verify', '--json']))
|
|
311
|
+
: {
|
|
312
|
+
...readVerify(await installed(['verify', '--only', only.steps.join(','), '--json'])),
|
|
313
|
+
only: only.steps,
|
|
314
|
+
notRun,
|
|
315
|
+
};
|
|
298
316
|
return {
|
|
299
317
|
codemods,
|
|
300
318
|
superseded,
|