@hominis/fireforge 0.48.0 → 0.49.1
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/CHANGELOG.md +29 -0
- package/dist/build-info.json +4 -4
- package/dist/src/cli.js +16 -28
- package/dist/src/commands/build.js +30 -4
- package/dist/src/commands/doctor-engine-eslint.d.ts +3 -0
- package/dist/src/commands/doctor-engine-eslint.js +12 -0
- package/dist/src/commands/doctor-macos-sdk.js +7 -5
- package/dist/src/commands/doctor-source-pin.js +9 -2
- package/dist/src/commands/doctor.js +2 -0
- package/dist/src/commands/furnace/apply.js +10 -4
- package/dist/src/commands/furnace/create-templates.js +0 -3
- package/dist/src/commands/lint.js +4 -0
- package/dist/src/commands/manifest.d.ts +1 -2
- package/dist/src/commands/patch/delete.js +18 -4
- package/dist/src/commands/re-export-options.js +7 -0
- package/dist/src/commands/re-export-register.js +1 -0
- package/dist/src/commands/re-export-removed.d.ts +4 -0
- package/dist/src/commands/re-export-removed.js +49 -0
- package/dist/src/commands/re-export-single.js +4 -1
- package/dist/src/commands/re-export.js +4 -0
- package/dist/src/commands/test-browser-preflight.d.ts +28 -0
- package/dist/src/commands/test-browser-preflight.js +181 -0
- package/dist/src/commands/test-build-phase.js +30 -7
- package/dist/src/commands/test-checkjs.d.ts +3 -0
- package/dist/src/commands/test-checkjs.js +27 -0
- package/dist/src/commands/test-diagnose.js +3 -0
- package/dist/src/commands/test-harness-env.d.ts +5 -6
- package/dist/src/commands/test-harness-env.js +27 -7
- package/dist/src/commands/test-modes.d.ts +2 -4
- package/dist/src/commands/test-register.js +11 -5
- package/dist/src/commands/test-run.d.ts +2 -0
- package/dist/src/commands/test-run.js +21 -1
- package/dist/src/commands/test-verdict.d.ts +2 -2
- package/dist/src/commands/test.js +83 -211
- package/dist/src/core/build-baseline-types.d.ts +12 -14
- package/dist/src/core/build-baseline-validate.d.ts +3 -0
- package/dist/src/core/build-baseline-validate.js +53 -0
- package/dist/src/core/build-baseline.d.ts +4 -3
- package/dist/src/core/build-baseline.js +23 -11
- package/dist/src/core/component-source-guard.d.ts +20 -0
- package/dist/src/core/component-source-guard.js +68 -0
- package/dist/src/core/coverage-extend.d.ts +5 -34
- package/dist/src/core/coverage-extend.js +26 -37
- package/dist/src/core/engine-write-boundary.d.ts +5 -0
- package/dist/src/core/engine-write-boundary.js +41 -0
- package/dist/src/core/furnace-apply-helpers.js +8 -2
- package/dist/src/core/furnace-apply.js +7 -0
- package/dist/src/core/furnace-validate-accessibility.js +9 -12
- package/dist/src/core/furnace-validate.js +0 -43
- package/dist/src/core/gecko-dom-types.d.ts +2 -0
- package/dist/src/core/gecko-dom-types.js +17 -0
- package/dist/src/core/lit-template-regions.d.ts +4 -0
- package/dist/src/core/lit-template-regions.js +50 -0
- package/dist/src/core/mach-build-artifacts.d.ts +6 -6
- package/dist/src/core/mach-build-artifacts.js +13 -7
- package/dist/src/core/mach-resource-shim.d.ts +1 -1
- package/dist/src/core/mach-resource-shim.js +2 -0
- package/dist/src/core/marionette-port.d.ts +2 -0
- package/dist/src/core/marionette-port.js +38 -53
- package/dist/src/core/mochitest-server-port.d.ts +1 -1
- package/dist/src/core/mochitest-server-port.js +20 -17
- package/dist/src/core/objdir-maintenance.d.ts +10 -0
- package/dist/src/core/objdir-maintenance.js +167 -0
- package/dist/src/core/patch-lint-checkjs.js +2 -1
- package/dist/src/core/patch-parse.js +8 -6
- package/dist/src/core/preflight-wait.d.ts +2 -0
- package/dist/src/core/preflight-wait.js +24 -0
- package/dist/src/core/process-owner.d.ts +9 -0
- package/dist/src/core/process-owner.js +43 -0
- package/dist/src/core/test-harness-crash.d.ts +1 -1
- package/dist/src/core/test-harness-crash.js +5 -5
- package/dist/src/core/test-host-state.d.ts +14 -0
- package/dist/src/core/test-host-state.js +80 -0
- package/dist/src/core/test-profile-files.d.ts +17 -0
- package/dist/src/core/test-profile-files.js +75 -0
- package/dist/src/core/test-stale-check.d.ts +6 -7
- package/dist/src/core/test-stale-check.js +9 -32
- package/dist/src/core/token-category.d.ts +7 -26
- package/dist/src/core/token-category.js +91 -117
- package/dist/src/core/token-inventory.js +12 -7
- package/dist/src/core/typecheck.js +6 -6
- package/dist/src/types/commands/options.d.ts +14 -3
- package/dist/src/utils/assert.js +2 -7
- package/dist/src/utils/child-env.d.ts +0 -3
- package/dist/src/utils/child-env.js +0 -3
- package/dist/src/utils/concurrency.d.ts +2 -2
- package/dist/src/utils/concurrency.js +15 -4
- package/dist/src/utils/fs.js +11 -1
- package/dist/src/utils/options.d.ts +16 -1
- package/dist/src/utils/options.js +5 -3
- package/dist/src/utils/paths.js +3 -2
- package/dist/src/utils/process-group.d.ts +1 -2
- package/dist/src/utils/process-group.js +1 -2
- package/dist/src/utils/process-input.js +0 -3
- package/dist/src/utils/process.d.ts +3 -2
- package/dist/src/utils/process.js +19 -7
- package/docs/configuration.md +12 -11
- package/docs/lifecycle-invariants.md +9 -5
- package/docs/machine-output.md +36 -19
- package/docs/patch-workflow.md +15 -0
- package/docs/testing.md +77 -12
- package/package.json +6 -5
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EUPL-1.2
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { reportOrphanedHarnessProcesses } from '../core/harness-orphans.js';
|
|
4
|
+
import { assertMarionettePortAvailable, ensureLaunchableBrowserNotRunning, ensureMarionettePortAvailable, extractForwardedMarionettePort, forwardedMachArgsIncludeMarionetteClient, shouldAutoForwardMarionettePortToMach, } from '../core/marionette-port.js';
|
|
5
|
+
import { formatMarionettePreflightLine, reportMarionettePreflight, runMarionettePreflight, } from '../core/marionette-preflight.js';
|
|
6
|
+
import { ensureMochitestServerPortAvailable } from '../core/mochitest-server-port.js';
|
|
7
|
+
import { waitForPreflight } from '../core/preflight-wait.js';
|
|
8
|
+
import { GeneralError } from '../errors/base.js';
|
|
9
|
+
import { info, outro, verbose } from '../utils/logger.js';
|
|
10
|
+
import { resolveWaitLockSeconds } from '../utils/options.js';
|
|
11
|
+
import { addVerdictRunCount, emitFailVerdict, emitPassVerdict } from './test-verdict.js';
|
|
12
|
+
/**
|
|
13
|
+
* Runs the `--doctor` marionette handshake probe. With no test paths the
|
|
14
|
+
* probe is the entire command (returns `'stop'` after reporting). With
|
|
15
|
+
* paths it gates the mach invocation, where a FAIL throws before mach runs.
|
|
16
|
+
*/
|
|
17
|
+
export async function runDoctorPreflight(args) {
|
|
18
|
+
const { engineDir, effectivePort, hasTestPaths, objDir, binaryName, launchablePath } = args;
|
|
19
|
+
// Non-TTY captures need the banner even if clack's renderer defers output
|
|
20
|
+
// in pipe mode. TTY users need the clack framing. Gated rather than
|
|
21
|
+
// written twice: the unconditional pair printed the same line twice on a
|
|
22
|
+
// terminal.
|
|
23
|
+
if (process.stdout.isTTY) {
|
|
24
|
+
info('Running marionette preflight...');
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
process.stdout.write('Running marionette preflight...\n');
|
|
28
|
+
}
|
|
29
|
+
const preflight = effectivePort !== undefined
|
|
30
|
+
? await runMarionettePreflight(engineDir, { port: effectivePort })
|
|
31
|
+
: await runMarionettePreflight(engineDir);
|
|
32
|
+
// The authoritative PASS/FAIL line is written with `process.stdout.write`
|
|
33
|
+
// as the first output after the probe returns, because clack's renderer
|
|
34
|
+
// can drop the summary under non-TTY capture.
|
|
35
|
+
//
|
|
36
|
+
// Gated on non-TTY: unconditional, it stacks with the two clack renderings
|
|
37
|
+
// below and the same line appears three times on a terminal. Captured
|
|
38
|
+
// streams are exactly where this branch still fires.
|
|
39
|
+
const directLine = formatMarionettePreflightLine(preflight);
|
|
40
|
+
if (!process.stdout.isTTY) {
|
|
41
|
+
process.stdout.write(`${directLine}\n`);
|
|
42
|
+
}
|
|
43
|
+
process.stdout.write(`Marionette preflight environment: objdir=${objDir ?? '(none)'}; binary=${binaryName}; app=${launchablePath ? `engine/${launchablePath}` : '(unknown)'}; port=${effectivePort ?? 2828}; elapsed=${preflight.durationMs}ms\n`);
|
|
44
|
+
reportMarionettePreflight(preflight);
|
|
45
|
+
if (!hasTestPaths) {
|
|
46
|
+
if (!preflight.ok) {
|
|
47
|
+
emitFailVerdict('preflight');
|
|
48
|
+
throw new GeneralError('Marionette preflight reported FAIL — see output above.');
|
|
49
|
+
}
|
|
50
|
+
// Doctor-only runs end here, so they carry their own verdict line
|
|
51
|
+
// (reason=preflight on failure). With test paths the verdict comes
|
|
52
|
+
// from the actual harness run downstream.
|
|
53
|
+
emitPassVerdict();
|
|
54
|
+
outro('Test completed');
|
|
55
|
+
return 'stop';
|
|
56
|
+
}
|
|
57
|
+
if (!preflight.ok) {
|
|
58
|
+
emitFailVerdict('preflight');
|
|
59
|
+
throw new GeneralError('Marionette preflight reported FAIL — see output above. Aborting before mach test runs.');
|
|
60
|
+
}
|
|
61
|
+
return 'continue';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Auto-forwards `--marionette-port` to mach (`--setpref=marionette.port`
|
|
65
|
+
* for the listener, `--marionette=127.0.0.1:<n>` for the mochitest
|
|
66
|
+
* client), skipping each piece the operator already forwarded via
|
|
67
|
+
* `--mach-arg` and the xpcshell flavor that ignores the pref entirely.
|
|
68
|
+
* Mutates `extraArgs` in place.
|
|
69
|
+
*/
|
|
70
|
+
export function appendMarionetteForwardingArgs(extraArgs, options, forwardedPort, xpcshellOnly = false) {
|
|
71
|
+
// Auto-forward the Marionette port to mach when `--marionette-port` is set.
|
|
72
|
+
// `--setpref=marionette.port=<n>` configures where the browser listener
|
|
73
|
+
// binds. `--marionette=127.0.0.1:<n>` tells the mochitest harness client to
|
|
74
|
+
// connect there (default client is 127.0.0.1:2828). xpcshell ignores both
|
|
75
|
+
// for browser Marionette.
|
|
76
|
+
//
|
|
77
|
+
// Skip setpref forwarding when the operator already supplied an equivalent
|
|
78
|
+
// arg via `--mach-arg`: duplicates would confuse without changing
|
|
79
|
+
// semantics. Skip when mach args explicitly request `--flavor=xpcshell` (or
|
|
80
|
+
// `xpcshell-tests`): the preflight still honours `--marionette-port`, but
|
|
81
|
+
// mach does not use the marionette.port pref on that harness. Any other arg
|
|
82
|
+
// shape still forwards so toolkit widget paths and mixed suites stay
|
|
83
|
+
// aligned with the probe without duplicate `--mach-arg` flags.
|
|
84
|
+
//
|
|
85
|
+
// Skip auto `--marionette=...` when `--mach-arg` already includes a client
|
|
86
|
+
// `--marionette=...` (or two-token `--marionette host:port`).
|
|
87
|
+
if (options.marionettePort === undefined)
|
|
88
|
+
return;
|
|
89
|
+
if (xpcshellOnly) {
|
|
90
|
+
// Manifest classification says every requested path is xpcshell.
|
|
91
|
+
// xpcshell ignores the browser Marionette path entirely, and forwarding
|
|
92
|
+
// the mochitest client flags here makes mach reject the dispatch.
|
|
93
|
+
info(`--marionette-port=${options.marionettePort} applied to the preflight probe only: the requested paths are xpcshell-only, and xpcshell ignores the browser Marionette port. Not forwarding --setpref=marionette.port or --marionette to mach.`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
{
|
|
97
|
+
const operatorAlreadyForwarded = forwardedPort !== undefined;
|
|
98
|
+
const machArgs = options.machArg ?? [];
|
|
99
|
+
if (operatorAlreadyForwarded) {
|
|
100
|
+
info(`--marionette-port=${options.marionettePort} set, but the same port is already forwarded via --mach-arg; skipping auto-forward.`);
|
|
101
|
+
}
|
|
102
|
+
else if (shouldAutoForwardMarionettePortToMach(machArgs)) {
|
|
103
|
+
extraArgs.push(`--setpref=marionette.port=${options.marionettePort}`);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
info(`--marionette-port=${options.marionettePort} applied to the preflight probe, but --flavor=xpcshell is set — mach is not auto-configured with --setpref=marionette.port or --marionette (xpcshell ignores the browser Marionette path). Pass --mach-arg --setpref=marionette.port=${options.marionettePort} explicitly if you still need mach to see the port.`);
|
|
107
|
+
}
|
|
108
|
+
if (shouldAutoForwardMarionettePortToMach(machArgs) &&
|
|
109
|
+
!forwardedMachArgsIncludeMarionetteClient(machArgs)) {
|
|
110
|
+
extraArgs.push(`--marionette=127.0.0.1:${options.marionettePort}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function ensureTestMarionettePortAvailable(port, binaryName, options, skip) {
|
|
115
|
+
// Refuse a stale listener before mach surfaces a generic bind failure.
|
|
116
|
+
// This also recognizes a fork-branded browser via binaryName.
|
|
117
|
+
if (skip.xpcshellOnly && !skip.doctor) {
|
|
118
|
+
// xpcshell does not bind the browser Marionette port, so a developer's
|
|
119
|
+
// interactive browser holding 2828 must not kill an xpcshell run.
|
|
120
|
+
// --doctor keeps the preflight: its probe launches a
|
|
121
|
+
// Marionette browser regardless of the requested harness.
|
|
122
|
+
const message = 'Skipping the Marionette stale-port preflight: all requested paths are xpcshell ' +
|
|
123
|
+
'(xpcshell does not bind the browser Marionette port).';
|
|
124
|
+
if (options.marionettePort !== undefined || options.killStaleMarionette === true) {
|
|
125
|
+
info(message);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
verbose(message);
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (options.killStaleMarionette === true) {
|
|
133
|
+
await ensureMarionettePortAvailable(port, { binaryName, killStaleBrowser: true });
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
await assertMarionettePortAvailable(port, { binaryName });
|
|
137
|
+
}
|
|
138
|
+
/** Prepares profile overlays and browser/port ownership preconditions. */
|
|
139
|
+
export async function ensureTestBrowserEnvironment(engineDir, launchablePath, xpcshellOnly, projectConfig, options, objDir) {
|
|
140
|
+
// A timed-out mochitest can leave the built app alive after its Marionette
|
|
141
|
+
// listener has disappeared. The port probe cannot see that case, but the
|
|
142
|
+
// survivor can still steal focus and wedge every later headed run.
|
|
143
|
+
if (!xpcshellOnly && launchablePath) {
|
|
144
|
+
await waitForPreflight(() => ensureLaunchableBrowserNotRunning(join(engineDir, launchablePath), {
|
|
145
|
+
killStaleBrowser: options.killStaleMarionette === true,
|
|
146
|
+
}), options.waitBrowser === undefined ? undefined : resolveWaitLockSeconds(options.waitBrowser));
|
|
147
|
+
}
|
|
148
|
+
// Packaging-only runs must protect a running objdir, but do not bind any
|
|
149
|
+
// harness ports or launch tests, so peer listeners cannot block packaging.
|
|
150
|
+
if (options.buildOnly)
|
|
151
|
+
return { forwardedPort: undefined, effectivePort: undefined };
|
|
152
|
+
// A zombie mochitest httpd squatting the server port makes a fresh
|
|
153
|
+
// browser connect to a server that cannot serve this run's manifest,
|
|
154
|
+
// which surfaces as a 370s "Ran 0 checks" stall naming nothing. xpcshell
|
|
155
|
+
// does not use the httpd, so an xpcshell-only run is never blocked by it.
|
|
156
|
+
if (!xpcshellOnly) {
|
|
157
|
+
await waitForPreflight(() => ensureMochitestServerPortAvailable(undefined, {
|
|
158
|
+
engineDir,
|
|
159
|
+
killStaleServer: options.killStaleMarionette === true,
|
|
160
|
+
}), options.waitPort === undefined ? undefined : resolveWaitLockSeconds(options.waitPort));
|
|
161
|
+
}
|
|
162
|
+
// Helpers that outlived an earlier run (httpd, pywebsocket, ssltunnel,
|
|
163
|
+
// moz-http2) slow every later run without appearing in its output. Both
|
|
164
|
+
// harnesses are affected, so this census is not gated on xpcshellOnly.
|
|
165
|
+
// Reaping is opt-in per invocation (--reap-orphans) or per repo
|
|
166
|
+
// (test.reapOrphans: "reap"); a reap is stamped on the verdict line so a
|
|
167
|
+
// green after one is not mistaken for a green on a quiet machine.
|
|
168
|
+
const census = await reportOrphanedHarnessProcesses(objDir, {
|
|
169
|
+
reap: options.reapOrphans === true || projectConfig.test?.reapOrphans === 'reap',
|
|
170
|
+
});
|
|
171
|
+
addVerdictRunCount('orphans-reaped', census.reaped);
|
|
172
|
+
const forwardedPort = options.machArg
|
|
173
|
+
? extractForwardedMarionettePort(options.machArg)
|
|
174
|
+
: undefined;
|
|
175
|
+
const effectivePort = options.marionettePort ?? forwardedPort;
|
|
176
|
+
await waitForPreflight(() => ensureTestMarionettePortAvailable(effectivePort, projectConfig.binaryName, options, {
|
|
177
|
+
xpcshellOnly,
|
|
178
|
+
doctor: options.doctor === true,
|
|
179
|
+
}), options.waitPort === undefined ? undefined : resolveWaitLockSeconds(options.waitPort));
|
|
180
|
+
return { forwardedPort, effectivePort };
|
|
181
|
+
}
|
|
@@ -7,12 +7,15 @@
|
|
|
7
7
|
import { readBuildBaseline, writeBuildBaseline } from '../core/build-baseline.js';
|
|
8
8
|
import { prepareBuildEnvironment } from '../core/build-prepare.js';
|
|
9
9
|
import { checkExtendCoverageAnchor, checkExtendMozconfigAnchor, formatExtendCoverageRefusal, unionTestPackagingCoverage, } from '../core/coverage-extend.js';
|
|
10
|
+
import { hasBuildArtifacts } from '../core/mach.js';
|
|
10
11
|
import { runProtectedMachBuild, withBuildLock } from '../core/mach.js';
|
|
12
|
+
import { assertHealthyPartialConfig, pruneDanglingTestLinks } from '../core/objdir-maintenance.js';
|
|
11
13
|
import { buildHarnessCrashMessage } from '../core/test-harness-crash.js';
|
|
12
14
|
import { GeneralError, InvalidArgumentError } from '../errors/base.js';
|
|
13
15
|
import { BuildError } from '../errors/build.js';
|
|
14
16
|
import { toError } from '../utils/errors.js';
|
|
15
17
|
import { info, notice, spinner, verbose } from '../utils/logger.js';
|
|
18
|
+
import { checkRequestedTestTypes } from './test-checkjs.js';
|
|
16
19
|
import { reportBuildOnlyCompletion } from './test-modes.js';
|
|
17
20
|
import { enforceStaleBuildGate, enforceStaticComponentsGate } from './test-stale-gate.js';
|
|
18
21
|
import { emitPassVerdict } from './test-verdict.js';
|
|
@@ -31,6 +34,14 @@ async function runPreTestBuild(options) {
|
|
|
31
34
|
// `mach build faster` would: a failed pre-test build followed by a full
|
|
32
35
|
// rebuild is an hour where an incremental one would have sufficed.
|
|
33
36
|
const previousBaseline = await readBuildBaseline(projectRoot);
|
|
37
|
+
const artifacts = await hasBuildArtifacts(paths.engine);
|
|
38
|
+
if (artifacts.objDir) {
|
|
39
|
+
await assertHealthyPartialConfig(paths.engine, artifacts.objDir);
|
|
40
|
+
const pruned = await pruneDanglingTestLinks(paths.engine, artifacts.objDir);
|
|
41
|
+
if (pruned > 0)
|
|
42
|
+
notice(`Pruned ${pruned} dangling _tests symlink(s).`);
|
|
43
|
+
}
|
|
44
|
+
await checkRequestedTestTypes(paths, projectConfig, testPackagingCoverage === 'full' ? [] : testPackagingCoverage);
|
|
34
45
|
const preparation = await prepareBuildEnvironment(projectRoot, paths, projectConfig, {
|
|
35
46
|
previousBaseline,
|
|
36
47
|
refuseUnexportedDrift,
|
|
@@ -39,10 +50,22 @@ async function runPreTestBuild(options) {
|
|
|
39
50
|
// only be checked once prepareBuildEnvironment has regenerated
|
|
40
51
|
// engine/mozconfig (the file this build will configure with), and must
|
|
41
52
|
// still be checked before mach, so a refusal costs no build.
|
|
42
|
-
|
|
53
|
+
let retainCoverage = false;
|
|
54
|
+
if (testPackagingCoverage !== 'full' && previousBaseline) {
|
|
55
|
+
const anchor = await checkExtendCoverageAnchor(paths.engine, previousBaseline, testPackagingCoverage);
|
|
43
56
|
const mozconfigAnchor = await checkExtendMozconfigAnchor(paths.engine, previousBaseline);
|
|
44
|
-
|
|
45
|
-
|
|
57
|
+
retainCoverage =
|
|
58
|
+
anchor.ok && mozconfigAnchor.ok && previousBaseline.testInputFingerprints !== undefined;
|
|
59
|
+
if (extend !== undefined && (!anchor.ok || !mozconfigAnchor.ok)) {
|
|
60
|
+
throw new GeneralError(formatExtendCoverageRefusal(!anchor.ok ? anchor : mozconfigAnchor));
|
|
61
|
+
}
|
|
62
|
+
if (!retainCoverage) {
|
|
63
|
+
const old = previousBaseline.testPackagingCoverage;
|
|
64
|
+
const dropped = old === undefined || old === 'full'
|
|
65
|
+
? ['full coverage outside this scope']
|
|
66
|
+
: old.filter((file) => !testPackagingCoverage.includes(file));
|
|
67
|
+
if (dropped.length)
|
|
68
|
+
notice(`Scoped build drops previous packaging coverage: ${dropped.join(', ')}. Earlier staging inputs changed or have no complete fingerprint anchor; rebuild those paths together to retain them.`);
|
|
46
69
|
}
|
|
47
70
|
}
|
|
48
71
|
const buildKind = preparation.fullBuildRequired ? 'full' : 'faster';
|
|
@@ -85,8 +108,8 @@ async function runPreTestBuild(options) {
|
|
|
85
108
|
// is always carried forward: that union can evaluate to 'full'
|
|
86
109
|
// while the build behind it was a scoped `mach build faster` that
|
|
87
110
|
// did not rebake the compiled table.
|
|
88
|
-
const recordedCoverage =
|
|
89
|
-
? unionTestPackagingCoverage(previousBaseline?.testPackagingCoverage,
|
|
111
|
+
const recordedCoverage = retainCoverage
|
|
112
|
+
? unionTestPackagingCoverage(previousBaseline?.testPackagingCoverage, testPackagingCoverage === 'full' ? [] : testPackagingCoverage)
|
|
90
113
|
: testPackagingCoverage;
|
|
91
114
|
await writeBuildBaseline({
|
|
92
115
|
projectRoot,
|
|
@@ -97,7 +120,7 @@ async function runPreTestBuild(options) {
|
|
|
97
120
|
recordedBy: describeBuildInvocation(extend !== undefined, testPackagingCoverage),
|
|
98
121
|
staticComponentsHandling: preparation.fullBuildRequired
|
|
99
122
|
? 'refresh'
|
|
100
|
-
:
|
|
123
|
+
: retainCoverage
|
|
101
124
|
? 'carry-forward'
|
|
102
125
|
: 'auto',
|
|
103
126
|
buildKind,
|
|
@@ -176,7 +199,7 @@ export async function runTestBuildPhase(projectRoot, paths, projectConfig, harne
|
|
|
176
199
|
if (extending) {
|
|
177
200
|
// Head/fingerprint half of the anchor, before the build lock: a
|
|
178
201
|
// refusal here costs neither build time nor the lock.
|
|
179
|
-
const anchor = await checkExtendCoverageAnchor(paths.engine, previousBaseline);
|
|
202
|
+
const anchor = await checkExtendCoverageAnchor(paths.engine, previousBaseline, normalizedPaths);
|
|
180
203
|
if (!anchor.ok) {
|
|
181
204
|
throw new GeneralError(formatExtendCoverageRefusal(anchor));
|
|
182
205
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FireForgeConfig, ProjectPaths } from '../types/config.js';
|
|
2
|
+
/** Runs the configured patch test checkJs pass before paying for a proving build. */
|
|
3
|
+
export declare function checkRequestedTestTypes(paths: ProjectPaths, config: FireForgeConfig, requested: string[]): Promise<void>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EUPL-1.2
|
|
2
|
+
import { runCheckJsTestFilesGrouped } from '../core/patch-lint-checkjs.js';
|
|
3
|
+
import { isTestScriptFile } from '../core/patch-lint-ownership.js';
|
|
4
|
+
import { loadPatchesManifest } from '../core/patch-manifest.js';
|
|
5
|
+
import { analyzeTestPathScopes } from '../core/test-path-scope.js';
|
|
6
|
+
import { GeneralError } from '../errors/base.js';
|
|
7
|
+
import { notice } from '../utils/logger.js';
|
|
8
|
+
/** Runs the configured patch test checkJs pass before paying for a proving build. */
|
|
9
|
+
export async function checkRequestedTestTypes(paths, config, requested) {
|
|
10
|
+
if (config.patchLint?.checkJs !== true ||
|
|
11
|
+
config.patchLint.checkJsTestFiles !== true ||
|
|
12
|
+
requested.length === 0)
|
|
13
|
+
return;
|
|
14
|
+
const manifest = await loadPatchesManifest(paths.patches);
|
|
15
|
+
const owned = new Set(manifest?.patches.flatMap((patch) => patch.filesAffected.filter(isTestScriptFile)) ?? []);
|
|
16
|
+
const scopes = await analyzeTestPathScopes(paths.engine, requested);
|
|
17
|
+
const selected = new Set(scopes.flatMap((scope) => scope.dispatchPaths.filter(isTestScriptFile)));
|
|
18
|
+
for (const file of selected)
|
|
19
|
+
owned.add(file);
|
|
20
|
+
const result = await runCheckJsTestFilesGrouped(paths.engine, owned, config.patchLint, paths.root, selected);
|
|
21
|
+
const issues = [...result.global, ...[...result.byFile.values()].flat()];
|
|
22
|
+
for (const issue of issues)
|
|
23
|
+
notice(`Pre-build checkJs: ${issue.file}: ${issue.message}`);
|
|
24
|
+
if (issues.some((issue) => issue.severity === 'error')) {
|
|
25
|
+
throw new GeneralError('Named test files failed the configured patch checkJs pass before build. Fix the type errors above before running the proof.');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -143,6 +143,9 @@ verdict) {
|
|
|
143
143
|
if (result.exitCode === 0 || result.exitCode === 130)
|
|
144
144
|
return;
|
|
145
145
|
const combinedOutput = `${result.stdout}\n${result.stderr}`;
|
|
146
|
+
if (/copyExtraFilesToProfile/.test(combinedOutput) && /FileExistsError/.test(combinedOutput)) {
|
|
147
|
+
throw new GeneralError('Harness argument failure: --extra-profile-file collided with the existing profile directory. Use --profile-file source=chrome/userChrome.css to merge an individual file; rebuilding does not repair this argument.');
|
|
148
|
+
}
|
|
146
149
|
const failureContext = postRebuildContext
|
|
147
150
|
? completePostRebuildFailureContext(postRebuildContext, combinedOutput)
|
|
148
151
|
: undefined;
|
|
@@ -11,14 +11,13 @@ export declare function buildPerfSampleEnv(projectRoot: string, binaryName: stri
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function mergeHarnessEnv(...parts: (Record<string, string> | undefined)[]): Record<string, string> | undefined;
|
|
13
13
|
/**
|
|
14
|
-
* Resolves the
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* shuffling could not be reproduced. FireForge draws the seed, exports it
|
|
18
|
-
* as `FIREFORGE_SHUFFLE_SEED` for harness code that reorders inside a file,
|
|
19
|
-
* prints it, and stamps it on the verdict line.
|
|
14
|
+
* Resolves the seed for FireForge's isolated shard order and exports it for
|
|
15
|
+
* custom in-file task code. Native mach file shuffling remains unseeded;
|
|
16
|
+
* replaying this seed guarantees only the FireForge shard permutation.
|
|
20
17
|
*
|
|
21
18
|
* Mochitest-only: the xpcshell harness has no shuffle, and generic `mach
|
|
22
19
|
* test` dispatch would forward the flag to every suite it fans out to.
|
|
23
20
|
*/
|
|
24
21
|
export declare function resolveShuffleSeed(shuffle: number | boolean | undefined, suite: TestSuite): number | undefined;
|
|
22
|
+
/** Returns a deterministic Fisher–Yates permutation without mutating the selection. */
|
|
23
|
+
export declare function shuffleTestGroups<T>(groups: readonly T[], seed: number): T[];
|
|
@@ -36,12 +36,9 @@ export function mergeHarnessEnv(...parts) {
|
|
|
36
36
|
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* Resolves the
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* shuffling could not be reproduced. FireForge draws the seed, exports it
|
|
43
|
-
* as `FIREFORGE_SHUFFLE_SEED` for harness code that reorders inside a file,
|
|
44
|
-
* prints it, and stamps it on the verdict line.
|
|
39
|
+
* Resolves the seed for FireForge's isolated shard order and exports it for
|
|
40
|
+
* custom in-file task code. Native mach file shuffling remains unseeded;
|
|
41
|
+
* replaying this seed guarantees only the FireForge shard permutation.
|
|
45
42
|
*
|
|
46
43
|
* Mochitest-only: the xpcshell harness has no shuffle, and generic `mach
|
|
47
44
|
* test` dispatch would forward the flag to every suite it fans out to.
|
|
@@ -56,6 +53,29 @@ export function resolveShuffleSeed(shuffle, suite) {
|
|
|
56
53
|
}
|
|
57
54
|
const seed = shuffle === true ? randomInt(1, 2 ** 31 - 1) : shuffle;
|
|
58
55
|
setVerdictRunAttribute('shuffle', String(seed));
|
|
59
|
-
info(`Test order
|
|
56
|
+
info(`Test shard order: seed=${seed} (replay with "fireforge test --shuffle=${seed}"). ` +
|
|
57
|
+
'Native harness file shuffle remains unseeded.');
|
|
60
58
|
return seed;
|
|
61
59
|
}
|
|
60
|
+
/** Returns a deterministic Fisher–Yates permutation without mutating the selection. */
|
|
61
|
+
export function shuffleTestGroups(groups, seed) {
|
|
62
|
+
const shuffled = [...groups];
|
|
63
|
+
// Hash the decimal seed so every accepted safe integer contributes, rather
|
|
64
|
+
// than silently discarding its high bits in the 32-bit PRNG.
|
|
65
|
+
let state = 2166136261;
|
|
66
|
+
for (const character of String(seed))
|
|
67
|
+
state = Math.imul(state ^ character.charCodeAt(0), 16777619);
|
|
68
|
+
state = state >>> 0 || 1;
|
|
69
|
+
for (let index = shuffled.length - 1; index > 0; index--) {
|
|
70
|
+
state ^= state << 13;
|
|
71
|
+
state ^= state >>> 17;
|
|
72
|
+
state ^= state << 5;
|
|
73
|
+
const destination = Math.floor(((state >>> 0) / 2 ** 32) * (index + 1));
|
|
74
|
+
// Both indexes are bounded by the array length, including under
|
|
75
|
+
// noUncheckedIndexedAccess; T may itself contain undefined.
|
|
76
|
+
const selected = shuffled[index];
|
|
77
|
+
shuffled[index] = shuffled[destination];
|
|
78
|
+
shuffled[destination] = selected;
|
|
79
|
+
}
|
|
80
|
+
return shuffled;
|
|
81
|
+
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { TestOptions } from '../types/commands/index.js';
|
|
2
2
|
import type { FireForgeConfig } from '../types/config.js';
|
|
3
3
|
import type { TestRunOutcome } from './test-run.js';
|
|
4
|
-
type ProjectConfig = FireForgeConfig;
|
|
5
4
|
/** Rejects pathless `fireforge test` unless the operator selected a pathless mode. */
|
|
6
5
|
export declare function assertPathlessTestMode(testPaths: readonly string[], options: TestOptions): void;
|
|
7
6
|
/** Rejects invalid combinations for mode-like `fireforge test` options. */
|
|
8
7
|
export declare function assertTestModeCombinations(testPaths: readonly string[], options: TestOptions, canaryPath: string | undefined): void;
|
|
9
8
|
/** Resolves the canary path from CLI or config. */
|
|
10
|
-
export declare function resolveCanaryPath(options: TestOptions, projectConfig:
|
|
9
|
+
export declare function resolveCanaryPath(options: TestOptions, projectConfig: FireForgeConfig): string | undefined;
|
|
11
10
|
/** Returns the configured canary no-output budget, defaulting to 60 seconds. */
|
|
12
|
-
export declare function canaryTimeoutSeconds(projectConfig:
|
|
11
|
+
export declare function canaryTimeoutSeconds(projectConfig: FireForgeConfig): number;
|
|
13
12
|
/** Emits or throws the one-word canary verdict. */
|
|
14
13
|
export declare function reportCanaryOutcome(outcome: TestRunOutcome): void;
|
|
15
14
|
/** Per-harness bucketing of the requested test paths. */
|
|
@@ -41,4 +40,3 @@ export declare function classifyBeforeDispatch(engineDir: string, normalizedPath
|
|
|
41
40
|
* run build-less without tripping the stale/coverage gate.
|
|
42
41
|
*/
|
|
43
42
|
export declare function reportBuildOnlyCompletion(classification: HarnessClassification, normalizedPaths: readonly string[]): void;
|
|
44
|
-
export {};
|
|
@@ -28,7 +28,7 @@ const TEST_HELP_TEXT = [
|
|
|
28
28
|
'',
|
|
29
29
|
'Machine-readable verdict: every run (single, sharded, --canary,',
|
|
30
30
|
'--doctor) ends with exactly one raw stdout line',
|
|
31
|
-
' FIREFORGE-VERDICT: PASS|FAIL [reason=crash|test-failures|',
|
|
31
|
+
' FIREFORGE-VERDICT: PASS|FAIL [reason=crash|harness-arguments|test-failures|',
|
|
32
32
|
' no-tests|preflight|inconclusive|lock-timeout|killed] [checks=<n>]',
|
|
33
33
|
' [unexpected=<n>] [shards=<p>/<t>] [(<note>)] [shuffle=<seed>]',
|
|
34
34
|
' [log=<path>]',
|
|
@@ -41,8 +41,8 @@ const TEST_HELP_TEXT = [
|
|
|
41
41
|
'a green-summary-override pass says PASS despite a non-zero mach',
|
|
42
42
|
'exit. reason=preflight covers any failure before the harness ran',
|
|
43
43
|
'(missing/stale build, invalid paths, port conflicts, config',
|
|
44
|
-
'errors); reason=inconclusive means engine/
|
|
45
|
-
'tests ran, so the
|
|
44
|
+
'errors); reason=inconclusive means engine/ or perf power source',
|
|
45
|
+
'changed while tests ran, so the result cannot be trusted;',
|
|
46
46
|
'reason=lock-timeout means the run never started because another',
|
|
47
47
|
'engine-mutating command held the lock past the wait budget;',
|
|
48
48
|
'reason=killed means a signal terminated the run before it reached',
|
|
@@ -57,6 +57,12 @@ const TEST_HELP_TEXT = [
|
|
|
57
57
|
'stall whose display was measured asleep. Key on this line',
|
|
58
58
|
'instead of mach internals.',
|
|
59
59
|
].join('\n');
|
|
60
|
+
function registerTestSharingOptions(test) {
|
|
61
|
+
return test
|
|
62
|
+
.option('--wait-browser [seconds]', 'Wait for this objdir browser before any deployment/build (default 60)', commanderArgParser((raw) => resolveWaitLockSeconds(raw)))
|
|
63
|
+
.option('--wait-port [seconds]', 'Wait for the mochitest and Marionette ports (default 60)', commanderArgParser((raw) => resolveWaitLockSeconds(raw)))
|
|
64
|
+
.option('--profile-file <source=destination>', 'Merge a file into the harness profile, e.g. sheet.css=chrome/userChrome.css. Repeatable.', ...stringListOption());
|
|
65
|
+
}
|
|
60
66
|
/** Registers the test command on the CLI program. */
|
|
61
67
|
export function registerTest(program, { getProjectRoot, withErrorHandling }) {
|
|
62
68
|
const test = program
|
|
@@ -77,7 +83,7 @@ export function registerTest(program, { getProjectRoot, withErrorHandling }) {
|
|
|
77
83
|
.option('--canary [path]', 'Run one short browser-chrome harness canary. Uses test.canaryPath from fireforge.json when no path is supplied.')
|
|
78
84
|
.option('--doctor', 'Run a marionette handshake preflight before tests (exit 1 on FAIL). With no paths, runs the preflight only.')
|
|
79
85
|
.option('--mach-arg <arg>', 'Forward this argument verbatim to `mach test` (repeatable). Escape valve for upstream xpcshell/mochitest flags FireForge does not model.', ...stringListOption())
|
|
80
|
-
.option('--shuffle [seed]', '
|
|
86
|
+
.option('--shuffle [seed]', 'Shuffle isolated mochitest path arguments in a repeatable seeded order (fresh seed when omitted). Native mach --shuffle within each invocation remains unseeded. Export FIREFORGE_SHUFFLE_SEED for custom task code and stamp shuffle=<seed> on the verdict. --no-shard disables the seeded argument permutation. Write --shuffle=<seed> or place it after the paths.', commanderArgParser((raw) => parsePositiveIntegerFlag('--shuffle', raw)))
|
|
81
87
|
.option('--harness-retries <n>', `Retry budget for recognized harness crashes (resource-monitor tracebacks, pre-test hangs, post-green shutdown re-entry). 0 disables retries. Default: ${DEFAULT_HARNESS_RETRIES}.`, commanderArgParser((raw) => {
|
|
82
88
|
const n = Number.parseInt(raw, 10);
|
|
83
89
|
if (!Number.isFinite(n) || n < 0 || n > 10) {
|
|
@@ -96,7 +102,7 @@ export function registerTest(program, { getProjectRoot, withErrorHandling }) {
|
|
|
96
102
|
return n;
|
|
97
103
|
}))
|
|
98
104
|
.addHelpText('after', TEST_HELP_TEXT);
|
|
99
|
-
addWaitLockOption(test).action(withErrorHandling(async (paths, options) => {
|
|
105
|
+
addWaitLockOption(registerTestSharingOptions(test)).action(withErrorHandling(async (paths, options) => {
|
|
100
106
|
const projectRoot = getProjectRoot();
|
|
101
107
|
// The engine session lock is acquired outside testCommand's own
|
|
102
108
|
// exactly-one-verdict guarantee, so a lock failure must emit here or
|
|
@@ -24,6 +24,8 @@ export declare const DEFAULT_HARNESS_RETRIES = 2;
|
|
|
24
24
|
export type TestSuite = 'xpcshell' | 'mochitest' | 'generic';
|
|
25
25
|
/** Inputs shared by every harness invocation in one `fireforge test` run. */
|
|
26
26
|
export interface TestRunContext {
|
|
27
|
+
/** A perf run changed power source; no green result can be trusted. */
|
|
28
|
+
powerChanged?: boolean;
|
|
27
29
|
engineDir: string;
|
|
28
30
|
objDir: string | undefined;
|
|
29
31
|
classification: {
|
|
@@ -17,6 +17,7 @@ import { parentExited } from '../core/parent-exit-watchdog.js';
|
|
|
17
17
|
import { getActiveRunLogPath } from '../core/run-log.js';
|
|
18
18
|
import { changedPrefNoiseVerdictNote } from '../core/test-changed-prefs.js';
|
|
19
19
|
import { buildHarnessCrashMessage, classifyHarnessRun, headedDisplayAsleepVerdictNote, headedNoOutputTimeoutHint, } from '../core/test-harness-crash.js';
|
|
20
|
+
import { reportTestHost, sampleTestHost, stampPerfHost } from '../core/test-host-state.js';
|
|
20
21
|
import { retryAfterXpcshellSymlinkRepair } from '../core/test-xpcshell-retry.js';
|
|
21
22
|
import { withXpcshellProfileDir } from '../core/xpcshell-profile-dir.js';
|
|
22
23
|
import { TestFailureError } from '../errors/build.js';
|
|
@@ -24,7 +25,7 @@ import { info, note, warn } from '../utils/logger.js';
|
|
|
24
25
|
import { getPlatform } from '../utils/platform.js';
|
|
25
26
|
import { maybeInjectAppdirArg } from './test-appdir.js';
|
|
26
27
|
import { createHarnessTeardown } from './test-harness-teardown.js';
|
|
27
|
-
import { emitHarnessVerdict } from './test-verdict.js';
|
|
28
|
+
import { emitHarnessVerdict, setVerdictRunAttribute } from './test-verdict.js';
|
|
28
29
|
/** Default bounded retry budget for recognized harness crashes. */
|
|
29
30
|
export const DEFAULT_HARNESS_RETRIES = 2;
|
|
30
31
|
/** Resolves the mach test command a suite dispatches to. */
|
|
@@ -121,6 +122,15 @@ async function runTrackedMachTestSuite(ctx, kind, paths, extraArgs, env) {
|
|
|
121
122
|
objDir: ctx.objDir === undefined ? undefined : join(ctx.engineDir, ctx.objDir),
|
|
122
123
|
pgidFile: ctx.pgidFile,
|
|
123
124
|
});
|
|
125
|
+
const start = await sampleTestHost();
|
|
126
|
+
const warned = reportTestHost(start, 'suite start');
|
|
127
|
+
setVerdictRunAttribute('host-load', start.load.toFixed(2));
|
|
128
|
+
if (warned)
|
|
129
|
+
setVerdictRunAttribute('host-cpu-warning', 'true');
|
|
130
|
+
if (env && Object.keys(env).some((key) => key.endsWith('_PERF_SAMPLE_JSON'))) {
|
|
131
|
+
setVerdictRunAttribute('power-source', start.power);
|
|
132
|
+
env = { ...env, FIREFORGE_POWER_SOURCE: start.power };
|
|
133
|
+
}
|
|
124
134
|
try {
|
|
125
135
|
await teardown.prepare();
|
|
126
136
|
return await runMachTestSuite(kind, {
|
|
@@ -134,6 +144,13 @@ async function runTrackedMachTestSuite(ctx, kind, paths, extraArgs, env) {
|
|
|
134
144
|
}
|
|
135
145
|
finally {
|
|
136
146
|
teardown.dispose();
|
|
147
|
+
const end = await sampleTestHost();
|
|
148
|
+
if (reportTestHost(end, 'suite end'))
|
|
149
|
+
setVerdictRunAttribute('host-cpu-warning', 'true');
|
|
150
|
+
if (await stampPerfHost(env, start, end)) {
|
|
151
|
+
ctx.powerChanged = true;
|
|
152
|
+
setVerdictRunAttribute('power-changed', 'true');
|
|
153
|
+
}
|
|
137
154
|
}
|
|
138
155
|
}
|
|
139
156
|
/**
|
|
@@ -158,6 +175,7 @@ const SHARD_STATUS_LABEL = {
|
|
|
158
175
|
'test-failures': 'FAIL',
|
|
159
176
|
'harness-crash': 'CRASH',
|
|
160
177
|
'no-tests': 'NO-TESTS',
|
|
178
|
+
'harness-arguments': 'ARGUMENTS',
|
|
161
179
|
};
|
|
162
180
|
/**
|
|
163
181
|
* Derives the aggregate classification for a sharded run: all-green is
|
|
@@ -168,6 +186,8 @@ const SHARD_STATUS_LABEL = {
|
|
|
168
186
|
*/
|
|
169
187
|
export function deriveAggregateShardVerdict(shards) {
|
|
170
188
|
const kinds = new Set(shards.map(({ outcome }) => outcome.verdict.kind));
|
|
189
|
+
if (kinds.has('harness-arguments'))
|
|
190
|
+
return { kind: 'harness-arguments' };
|
|
171
191
|
if (kinds.has('harness-crash'))
|
|
172
192
|
return { kind: 'harness-crash' };
|
|
173
193
|
if (kinds.has('no-tests'))
|
|
@@ -11,9 +11,9 @@ import type { HarnessRunVerdict } from '../core/test-harness-crash.js';
|
|
|
11
11
|
* and `killed` marks a run terminated by a signal before it could reach any
|
|
12
12
|
* of the others.
|
|
13
13
|
*/
|
|
14
|
-
export type FireforgeVerdictReason = 'crash' | 'no-tests' | 'test-failures' | 'preflight' | 'inconclusive' | 'lock-timeout' | 'killed';
|
|
14
|
+
export type FireforgeVerdictReason = 'crash' | 'harness-arguments' | 'no-tests' | 'test-failures' | 'preflight' | 'inconclusive' | 'lock-timeout' | 'killed';
|
|
15
15
|
/** Additive keys a run can stamp on its verdict line. */
|
|
16
|
-
export type VerdictRunAttributeKey = 'shuffle' | 'orphans-reaped';
|
|
16
|
+
export type VerdictRunAttributeKey = 'shuffle' | 'orphans-reaped' | 'host-load' | 'host-cpu-warning' | 'power-source' | 'power-changed';
|
|
17
17
|
/** Records an additive attribute for this run's verdict line. */
|
|
18
18
|
export declare function setVerdictRunAttribute(key: VerdictRunAttributeKey, value: string): void;
|
|
19
19
|
/**
|