From b858df715800ea0aa56193588852c98a67d06e05 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 28 Nov 2026 08:39:57 +0100 Subject: [PATCH 1/5] wf test: a run stopped at its time limit names how far the runner frame got (#690) The runner posts its stages (started, bridge settled, specs loaded, the spec it runs); at the time limit or on Ctrl+C the parent adds them to the message and the report with the runner files whose response the frame never completed, read from the frame's Resource Timing. The next stalled run says whether runner.js was never requested or never received. --- docs/DEVELOPER_ENVIRONMENT.md | 5 ++ js/developer/environment/bundles.json | 2 +- js/developer/environment/testing.mjs | 70 +++++++++++++++++++++++--- test/developer/specs/testing-specs.mjs | 49 +++++++++++++++++- test/web/developer-specs.mjs | 4 ++ 5 files changed, 122 insertions(+), 8 deletions(-) diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index d0a1e623..c28add00 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -793,6 +793,11 @@ The result sent to C++ is cut to 60,000 bytes when it is larger (a bridge string The report is structured: `{status, exitCode, total, passed, failed, pending, excluded, durationMs, jasmine, failures: [{name, messages: [{message, stack}]}], pendingSpecs, suites, global, incomplete}`, bounded (100 failures, 8 messages of 16 KiB each per spec). `status` is `passed`, `failed`, `incomplete`, `error` (the specs did not load), `timeout` or `interrupted`. +A run stopped at the time limit or by Ctrl+C once its frame was in the page also has `stage: {reached, specs, current, +loaded, missing}`, which its message repeats: the last step the runner reached (`page requested` when it never started, +`runner started`, `bridge settled`, `specs loaded`, `specs running`), the specs it finished, the spec it was running, and +the runner's files (`index.html`, `specs.css`, `WebFront.js`, `jasmine.js`, `runner.js`, `specs.js`) whose response the +frame received in full or not: a file that is missing was never requested or never completely received. ### Without a terminal diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index fc819621..7a4f898d 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -20,7 +20,7 @@ "js/developer/environment/runtime.mjs": "1b5f0bfc5964b902725a4c765d83db0644cdad91a8f07d8bf6a3bbd0f550c1eb", "js/developer/environment/automation.mjs": "773dcca7b8847c11670995f759c218c86af95a29ea46b44f350f79c4b71a143c", "js/developer/environment/development.mjs": "1f32f911610c72ad3e935de1c2b138fa275ce9eda04bb63c824d5e09923305a6", - "js/developer/environment/testing.mjs": "aeb584505fab5957b9c02e78536e12f7d7f3d12f8adb2e17f1a1a6e395e43f3c", + "js/developer/environment/testing.mjs": "f6651e19026342ff41fc1ea713f09f0c7f8abc334d3c0294d74dee9c569ae132", "js/developer/environment/terminal.mjs": "e7c3ca8f9833f10e07939277996eb01fb989c986420c96052271ff469fa59062", "js/developer/environment/workspace.mjs": "e82ec4df21ffb2b112550e0212504aba05af4f924b5645c0712f40f8466257fc", "js/developer/environment/menu.mjs": "b4fe4c38e6b8cc6c1101df842e282ab85e6c6e029b2225738b9d27bc5efbc88d", diff --git a/js/developer/environment/testing.mjs b/js/developer/environment/testing.mjs index 5070a3e0..493ecd1c 100644 --- a/js/developer/environment/testing.mjs +++ b/js/developer/environment/testing.mjs @@ -60,11 +60,16 @@ function boot() { for (const name in members) globalThis[name] = members[name]; } try { + post({type: 'stage', stage: 'runner started'}); try { await webFront.ready; } catch { /* the specs that need the bridge fail on their own */ } + post({type: 'stage', stage: 'bridge settled'}); boot(); const env = jasmine.getEnv(); env.configure({random: false, specFilter: spec => spec.getFullName().includes(pattern)}); env.addReporter({ + specStarted(result) { + post({type: 'stage', stage: 'specs running', spec: clip(result.fullName, 256)}); + }, specDone(result) { specs.push({name: clip(result.fullName, 1024), status: result.status, reason: clip(result.pendingReason, 1024), failures: problems(result.failedExpectations)}); @@ -80,6 +85,7 @@ try { }, }); await import('./specs.js'); + post({type: 'stage', stage: 'specs loaded'}); await env.execute(); } catch (error) { // WebKit's stack lacks the message, so it is always put first. @@ -158,11 +164,55 @@ export function abortable(promise, signal) { }); } -export const stoppedRun = (reason, pattern) => { - const [message, exitCode] = reason === 'timeout' ? ['Tests stopped at their time limit', 124] : ['Tests stopped by Ctrl+C', 130]; - return Object.assign(new ScriptExit(message, exitCode), {report: emptyReport(reason, exitCode, {pattern, error: message})}); +/** + * A run stopped before its report: 'timeout' (124) or 'interrupted' (130). `stage`, when the runner frame was started, + * says how far it got (frameStage) and is added to the message and to the report. + */ +export const stoppedRun = (reason, pattern, stage) => { + const [stopped, exitCode] = reason === 'timeout' ? ['Tests stopped at their time limit', 124] : ['Tests stopped by Ctrl+C', 130]; + const message = stage ? `${stopped} (${describeStage(stage)})` : stopped; + return Object.assign(new ScriptExit(message, exitCode), {report: emptyReport(reason, exitCode, {pattern, error: message, ...(stage ? {stage} : {})})}); }; +/** The files of the runner, in the order the page loads them; specs.css only when the specs built one. */ +export const runnerResources = ['index.html', 'specs.css', 'WebFront.js', 'jasmine.js', 'runner.js', 'specs.js']; + +/** + * How far the runner frame got, for a run stopped before its report (#690): `reached` is the last stage the runner + * posted ('page requested' when it posted none: it did not start), `specs` the specs it finished, `current` the last spec + * it started (the one that hangs when the stage is 'specs running'), `loaded` the runner's + * files whose response the frame received completely, and `missing` those it did not (never requested, or a response + * still incomplete). A frame that cannot be read leaves both lists empty. + */ +export function frameStage(frameWindow, {reached = 'page requested', specs = 0, current = '', resources = runnerResources} = {}) { + let loaded = []; + let missing = []; + try { + const names = new Set(); + const entries = [...frameWindow.performance.getEntriesByType('navigation'), ...frameWindow.performance.getEntriesByType('resource')]; + for (const entry of entries) { + if (!(entry.responseEnd > 0)) continue; + const file = new URL(entry.name).pathname.split('/').at(-1); + names.add(file === '' ? 'index.html' : file); + } + // The page links specs.css only when the specs built one: unknown while the page itself did not load. + const styled = names.has('specs.css') || Boolean(frameWindow.document.querySelector('link[href="./specs.css"]')); + const expected = resources.filter(file => file !== 'specs.css' || styled); + loaded = expected.filter(file => names.has(file)); + missing = expected.filter(file => !names.has(file)); + } catch { /* a frame that navigated away or was never attached: only the stage is known */ } + return {reached, specs, current, loaded, missing}; +} + +/** The stage of a stopped run in words: "stage: specs running, 3 specs done, in suite spec" or "stage: page requested; not loaded: runner.js, specs.js". */ +export function describeStage({reached, specs, current, missing}) { + const parts = [`stage: ${reached}`]; + if (specs) parts[0] += `, ${plural(specs, 'spec')} done`; + if (current && reached === 'specs running') parts[0] += `, in ${current}`; + if (missing.length) parts.push(`not loaded: ${missing.join(', ')}`); + return parts.join('; '); +} + // Out of sight but laid out like a page: specs that measure the DOM need a real viewport. function defaultFrame() { const frame = document.createElement('iframe'); @@ -181,6 +231,11 @@ export function runInFrame({pattern, timeout, runId, signal, write = () => {}, c return new Promise((resolve, reject) => { const frame = createFrame(); let timer; + let reached; + let specs = 0; + let current = ''; + // Known once the frame is in the page; a run stopped before that has no stage to give. + const stage = () => frame.isConnected ? frameStage(frame.contentWindow, {reached, specs, current}) : undefined; const finish = (error, report) => { clearTimeout(timer); removeEventListener('message', receive); @@ -191,13 +246,16 @@ export function runInFrame({pattern, timeout, runId, signal, write = () => {}, c const receive = ({source, origin, data}) => { if (source !== frame.contentWindow || origin !== location.origin) return; const message = data?.webfrontTest; - if (message?.type === 'spec') write(progress[message.status] ?? ''); + if (message?.type === 'stage' && typeof message.stage === 'string') { + reached = message.stage.slice(0, 64); + if (typeof message.spec === 'string') current = message.spec.slice(0, 256); + } else if (message?.type === 'spec') { specs += 1; write(progress[message.status] ?? ''); } else if (message?.type === 'done' || message?.type === 'error') finish(null, buildReport(message, {pattern})); }; - const interrupt = () => finish(stoppedRun('interrupted', pattern)); + const interrupt = () => finish(stoppedRun('interrupted', pattern, stage())); addEventListener('message', receive); signal?.addEventListener('abort', interrupt, {once: true}); - timer = setTimeout(() => finish(stoppedRun('timeout', pattern)), timeout * 1000); + timer = setTimeout(() => finish(stoppedRun('timeout', pattern, stage())), timeout * 1000); if (signal?.aborted) return interrupt(); frame.src = `/webfront/developer/test/${runId}/index.html?pattern=${encodeURIComponent(pattern)}&run=${Date.now()}`; document.body.append(frame); diff --git a/test/developer/specs/testing-specs.mjs b/test/developer/specs/testing-specs.mjs index 2747ca63..9037b32b 100644 --- a/test/developer/specs/testing-specs.mjs +++ b/test/developer/specs/testing-specs.mjs @@ -1,5 +1,5 @@ // Specs of wf test's host side, which supplement the real-browser regression in test/web/developer-specs.mjs. -import {parseTestOptions, specFiles, jasmineCore, buildReport, formatReport, reportResult, runnerFiles, fitResult, abortable} from '../../../js/developer/environment/testing.mjs'; +import {parseTestOptions, specFiles, jasmineCore, buildReport, formatReport, reportResult, runnerFiles, fitResult, abortable, frameStage, describeStage, stoppedRun} from '../../../js/developer/environment/testing.mjs'; import {execute} from '../../../js/developer/environment/runtime.mjs'; import {bundleTests} from '../../../js/developer/environment/bundler.mjs'; import {rejects, throws, esbuild, reportSpecStarted, reportSpecDone} from '../support.mjs'; @@ -329,3 +329,50 @@ describe('wf test', () => { await rejects(bundleTests(await esbuild(), {specs: ['absent.spec.js'], lock, readProject}), /absent\.spec\.js/); }, 60000); }); + +// A run stopped at its time limit names how far the runner frame got (#690): the last stage the runner posted, the spec +// it was running, and the runner's files whose response never completed. +describe('the stage of a stopped wf test run', () => { + const at = (file, end = 3) => ({name: `http://127.0.0.1:9002/webfront/developer/test/run/${file}`, responseEnd: end}); + const frame = ({page = true, resources = [], styled = false}) => ({ + performance: { + getEntriesByType: type => type === 'navigation' + ? (page ? [at('index.html?pattern=&run=1', 5)] : []) + : resources.map(file => file === 'WebFront.js' ? {name: 'http://127.0.0.1:9002/WebFront.js', responseEnd: 4} : at(file)), + }, + document: {querySelector: selector => styled && selector === 'link[href="./specs.css"]' ? {} : null}, + }); + + it('lists the runner files the frame did not receive, specs.css only when the page links it', () => { + expect(frameStage(frame({resources: ['specs.css', 'WebFront.js', 'jasmine.js'], styled: true}), {reached: 'bridge settled'})).toEqual({ + reached: 'bridge settled', specs: 0, current: '', + loaded: ['index.html', 'specs.css', 'WebFront.js', 'jasmine.js'], missing: ['runner.js', 'specs.js']}); + expect(frameStage(frame({resources: ['WebFront.js', 'jasmine.js', 'runner.js', 'specs.js']})).missing).toEqual([]); + // Nothing posted and no page: the runner never started. + expect(frameStage(frame({page: false}))).toEqual({reached: 'page requested', specs: 0, current: '', loaded: [], + missing: ['index.html', 'WebFront.js', 'jasmine.js', 'runner.js', 'specs.js']}); + }); + + it('counts a resource only once its response ended', () => { + const stalled = frame({resources: ['WebFront.js']}); + const entries = stalled.performance.getEntriesByType; + stalled.performance.getEntriesByType = type => type === 'resource' ? [...entries(type), at('jasmine.js', 0)] : entries(type); + expect(frameStage(stalled).missing).toEqual(['jasmine.js', 'runner.js', 'specs.js']); + }); + + it('keeps the stage of a frame it cannot read', () => { + expect(frameStage(null, {reached: 'specs loaded', specs: 2})).toEqual({reached: 'specs loaded', specs: 2, current: '', loaded: [], missing: []}); + }); + + it('says the stage in the message and keeps it in the report', () => { + const stage = {reached: 'specs running', specs: 3, current: 'suite never ends', loaded: [], missing: []}; + const stopped = stoppedRun('timeout', 'suite', stage); + expect([stopped.exitCode, stopped.message]).toEqual([124, 'Tests stopped at their time limit (stage: specs running, 3 specs done, in suite never ends)']); + expect([stopped.report.status, stopped.report.stage, stopped.report.error]).toEqual(['timeout', stage, stopped.message]); + expect(describeStage({reached: 'page requested', specs: 0, current: '', loaded: ['index.html'], missing: ['runner.js', 'specs.js']})) + .toBe('stage: page requested; not loaded: runner.js, specs.js'); + // Stopped before the frame existed: no stage, and the message stays the plain one. + const early = stoppedRun('interrupted', ''); + expect([early.exitCode, early.message, 'stage' in early.report]).toEqual([130, 'Tests stopped by Ctrl+C', false]); + }); +}); diff --git a/test/web/developer-specs.mjs b/test/web/developer-specs.mjs index 17f383a6..89568580 100644 --- a/test/web/developer-specs.mjs +++ b/test/web/developer-specs.mjs @@ -750,6 +750,10 @@ try { clock.fire(60000); const hung = await hanging; assert(hung.error?.exitCode === 124 && hung.report?.status === 'timeout' && /time limit/.test(hung.error.message), `A hanging run must stop at its time limit: ${hung.error}`); + // It names how far the runner got (#690): every runner file loaded, and the spec that hangs. + const stage = hung.report.stage; + assert(stage?.reached === 'specs running' && stage.current === 'hanging never ends' && stage.specs === 0 && stage.missing.length === 0 && + /stage: specs running, in hanging never ends/.test(hung.error.message), `A hanging run must name its stage: ${JSON.stringify(stage)}`); assert(!document.querySelector('iframe[title="WebFront tests"]'), 'A timed out run must remove its frame'); } finally { started.dispose(); } }); From 73c0cfb9de6b3f64c327cd976617716bab1af824 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 28 Nov 2026 08:40:07 +0100 Subject: [PATCH 2/5] Changelog: the stage of a stopped wf test run (#690) --- docs/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b4d0162a..8265a63e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -41,6 +41,7 @@ these entries stays in the GitHub releases and the Git history. - The test helpers, `webfront_add_jasmine_test` included, export the real `XDG_DATA_HOME` and `XDG_CACHE_HOME` as `WEBFRONT_TEST_REAL_XDG_DATA_HOME` and `WEBFRONT_TEST_REAL_XDG_CACHE_HOME`, so an application under test can keep the throwaway WebKitGTK profile away from the programs it starts ([#664](https://github.com/ambroise-leclerc/WebFront/issues/664), `docs/CONSUMER_TESTING.md`). ### Changed +- `wf test` stopped at its time limit or by Ctrl+C says how far its runner got, in its message and in the report's new `stage`: the last step reached, the spec in progress, and the runner files that never finished loading (#690, `docs/DEVELOPER_ENVIRONMENT.md`). - Destroying the handle of a watch (`inspect::Watch`) waits for an operation of the inspectors in progress on another thread: destroy it outside every lock its source takes, or declare the watch with the state it owns (#682, ADR-027, `docs/WATCHES.md`). - `cppFunction` and `Space::cppFunction` take a last, defaulted `std::source_location`, which the inspectors show; existing calls compile unchanged, the explicit `cppFunction` form included (#681, ADR-027). - Document the security contract of the application's callbacks: one that writes the project or what the server serves, starts a process or exposes a sensitive state takes the calling `UI` and checks `ui.isLocalClient()`, since WebFront guards only its own functions (#686, ADR-027, `docs/DEVELOPING_WITH_AGENTS.md`). From 93a8ea8fdbbb3b0e630846ac813c89ea0df61e6b Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 28 Nov 2026 08:45:30 +0100 Subject: [PATCH 3/5] wf test: after a spec, the stage of a stopped run is between specs, with no spec named (#690) --- docs/DEVELOPER_ENVIRONMENT.md | 3 ++- js/developer/environment/bundles.json | 2 +- js/developer/environment/testing.mjs | 13 ++++++++++--- test/developer/specs/testing-specs.mjs | 2 ++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index c28add00..cb0bca1e 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -795,7 +795,8 @@ The report is structured: `{status, exitCode, total, passed, failed, pending, ex each per spec). `status` is `passed`, `failed`, `incomplete`, `error` (the specs did not load), `timeout` or `interrupted`. A run stopped at the time limit or by Ctrl+C once its frame was in the page also has `stage: {reached, specs, current, loaded, missing}`, which its message repeats: the last step the runner reached (`page requested` when it never started, -`runner started`, `bridge settled`, `specs loaded`, `specs running`), the specs it finished, the spec it was running, and +`runner started`, `bridge settled`, `specs loaded`, `specs running`, `between specs` in a suite's hook or after a spec), +the specs it finished, the spec in progress, and the runner's files (`index.html`, `specs.css`, `WebFront.js`, `jasmine.js`, `runner.js`, `specs.js`) whose response the frame received in full or not: a file that is missing was never requested or never completely received. diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index 7a4f898d..74edbd84 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -20,7 +20,7 @@ "js/developer/environment/runtime.mjs": "1b5f0bfc5964b902725a4c765d83db0644cdad91a8f07d8bf6a3bbd0f550c1eb", "js/developer/environment/automation.mjs": "773dcca7b8847c11670995f759c218c86af95a29ea46b44f350f79c4b71a143c", "js/developer/environment/development.mjs": "1f32f911610c72ad3e935de1c2b138fa275ce9eda04bb63c824d5e09923305a6", - "js/developer/environment/testing.mjs": "f6651e19026342ff41fc1ea713f09f0c7f8abc334d3c0294d74dee9c569ae132", + "js/developer/environment/testing.mjs": "935284c8d66fa9507b9015a2197ac3a95f12692069c9a7e14237fc0e9d8cd2af", "js/developer/environment/terminal.mjs": "e7c3ca8f9833f10e07939277996eb01fb989c986420c96052271ff469fa59062", "js/developer/environment/workspace.mjs": "e82ec4df21ffb2b112550e0212504aba05af4f924b5645c0712f40f8466257fc", "js/developer/environment/menu.mjs": "b4fe4c38e6b8cc6c1101df842e282ab85e6c6e029b2225738b9d27bc5efbc88d", diff --git a/js/developer/environment/testing.mjs b/js/developer/environment/testing.mjs index 493ecd1c..3078220e 100644 --- a/js/developer/environment/testing.mjs +++ b/js/developer/environment/testing.mjs @@ -179,8 +179,9 @@ export const runnerResources = ['index.html', 'specs.css', 'WebFront.js', 'jasmi /** * How far the runner frame got, for a run stopped before its report (#690): `reached` is the last stage the runner - * posted ('page requested' when it posted none: it did not start), `specs` the specs it finished, `current` the last spec - * it started (the one that hangs when the stage is 'specs running'), `loaded` the runner's + * posted ('page requested' when it posted none: it did not start; 'between specs' after a spec finished, in a suite's + * hook or before the next spec), `specs` the specs it finished, `current` the spec in progress (the one that hangs when + * the stage is 'specs running'), `loaded` the runner's * files whose response the frame received completely, and `missing` those it did not (never requested, or a response * still incomplete). A frame that cannot be read leaves both lists empty. */ @@ -249,7 +250,13 @@ export function runInFrame({pattern, timeout, runId, signal, write = () => {}, c if (message?.type === 'stage' && typeof message.stage === 'string') { reached = message.stage.slice(0, 64); if (typeof message.spec === 'string') current = message.spec.slice(0, 256); - } else if (message?.type === 'spec') { specs += 1; write(progress[message.status] ?? ''); } + } else if (message?.type === 'spec') { + // Until the next spec starts, the run is in a suite's hook or between two specs: no spec is running. + specs += 1; + reached = 'between specs'; + current = ''; + write(progress[message.status] ?? ''); + } else if (message?.type === 'done' || message?.type === 'error') finish(null, buildReport(message, {pattern})); }; const interrupt = () => finish(stoppedRun('interrupted', pattern, stage())); diff --git a/test/developer/specs/testing-specs.mjs b/test/developer/specs/testing-specs.mjs index 9037b32b..f2e3b700 100644 --- a/test/developer/specs/testing-specs.mjs +++ b/test/developer/specs/testing-specs.mjs @@ -371,6 +371,8 @@ describe('the stage of a stopped wf test run', () => { expect([stopped.report.status, stopped.report.stage, stopped.report.error]).toEqual(['timeout', stage, stopped.message]); expect(describeStage({reached: 'page requested', specs: 0, current: '', loaded: ['index.html'], missing: ['runner.js', 'specs.js']})) .toBe('stage: page requested; not loaded: runner.js, specs.js'); + // A run stopped in a suite's hook or between specs names no spec as running. + expect(describeStage({reached: 'between specs', specs: 2, current: '', loaded: [], missing: []})).toBe('stage: between specs, 2 specs done'); // Stopped before the frame existed: no stage, and the message stays the plain one. const early = stoppedRun('interrupted', ''); expect([early.exitCode, early.message, 'stage' in early.report]).toEqual([130, 'Tests stopped by Ctrl+C', false]); From bab26af57a22f4c33ee5c76850c26260b2ba235b Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 28 Nov 2026 09:01:52 +0100 Subject: [PATCH 4/5] wf test: a stopped run names the suite whose beforeAll or afterAll it was in (#690) --- docs/DEVELOPER_ENVIRONMENT.md | 4 ++-- js/developer/environment/bundles.json | 2 +- js/developer/environment/testing.mjs | 32 ++++++++++++++++++-------- test/developer/specs/testing-specs.mjs | 14 ++++++----- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index cb0bca1e..61e125b4 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -793,10 +793,10 @@ The result sent to C++ is cut to 60,000 bytes when it is larger (a bridge string The report is structured: `{status, exitCode, total, passed, failed, pending, excluded, durationMs, jasmine, failures: [{name, messages: [{message, stack}]}], pendingSpecs, suites, global, incomplete}`, bounded (100 failures, 8 messages of 16 KiB each per spec). `status` is `passed`, `failed`, `incomplete`, `error` (the specs did not load), `timeout` or `interrupted`. -A run stopped at the time limit or by Ctrl+C once its frame was in the page also has `stage: {reached, specs, current, +A run stopped at the time limit or by Ctrl+C once its frame was in the page also has `stage: {reached, specs, current, suite, loaded, missing}`, which its message repeats: the last step the runner reached (`page requested` when it never started, `runner started`, `bridge settled`, `specs loaded`, `specs running`, `between specs` in a suite's hook or after a spec), -the specs it finished, the spec in progress, and +the specs it finished, the spec in progress or the innermost suite whose hooks run, and the runner's files (`index.html`, `specs.css`, `WebFront.js`, `jasmine.js`, `runner.js`, `specs.js`) whose response the frame received in full or not: a file that is missing was never requested or never completely received. diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index 74edbd84..859d2eed 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -20,7 +20,7 @@ "js/developer/environment/runtime.mjs": "1b5f0bfc5964b902725a4c765d83db0644cdad91a8f07d8bf6a3bbd0f550c1eb", "js/developer/environment/automation.mjs": "773dcca7b8847c11670995f759c218c86af95a29ea46b44f350f79c4b71a143c", "js/developer/environment/development.mjs": "1f32f911610c72ad3e935de1c2b138fa275ce9eda04bb63c824d5e09923305a6", - "js/developer/environment/testing.mjs": "935284c8d66fa9507b9015a2197ac3a95f12692069c9a7e14237fc0e9d8cd2af", + "js/developer/environment/testing.mjs": "079539320e6b3eaa16af233758c7681c73fd0359fe4d8ef5f6d2970ea3843699", "js/developer/environment/terminal.mjs": "e7c3ca8f9833f10e07939277996eb01fb989c986420c96052271ff469fa59062", "js/developer/environment/workspace.mjs": "e82ec4df21ffb2b112550e0212504aba05af4f924b5645c0712f40f8466257fc", "js/developer/environment/menu.mjs": "b4fe4c38e6b8cc6c1101df842e282ab85e6c6e029b2225738b9d27bc5efbc88d", diff --git a/js/developer/environment/testing.mjs b/js/developer/environment/testing.mjs index 3078220e..a7169dd6 100644 --- a/js/developer/environment/testing.mjs +++ b/js/developer/environment/testing.mjs @@ -66,16 +66,26 @@ try { boot(); const env = jasmine.getEnv(); env.configure({random: false, specFilter: spec => spec.getFullName().includes(pattern)}); + // The suites entered, innermost last: outside a spec, the run is in the hooks of the innermost one (beforeAll, afterAll). + const open = []; + const between = () => post({type: 'stage', stage: 'between specs', suite: open.at(-1) ?? ''}); env.addReporter({ + suiteStarted(result) { + open.push(clip(result.fullName, 256)); + between(); + }, specStarted(result) { - post({type: 'stage', stage: 'specs running', spec: clip(result.fullName, 256)}); + post({type: 'stage', stage: 'specs running', spec: clip(result.fullName, 256), suite: open.at(-1) ?? ''}); }, specDone(result) { specs.push({name: clip(result.fullName, 1024), status: result.status, reason: clip(result.pendingReason, 1024), failures: problems(result.failedExpectations)}); post({type: 'spec', status: result.status}); + between(); }, suiteDone(result) { + open.pop(); + between(); // An afterAll that throws is reported here, not by any spec. if (result.failedExpectations?.length) suites.push({name: clip(result.fullName, 1024), failures: problems(result.failedExpectations)}); }, @@ -181,11 +191,12 @@ export const runnerResources = ['index.html', 'specs.css', 'WebFront.js', 'jasmi * How far the runner frame got, for a run stopped before its report (#690): `reached` is the last stage the runner * posted ('page requested' when it posted none: it did not start; 'between specs' after a spec finished, in a suite's * hook or before the next spec), `specs` the specs it finished, `current` the spec in progress (the one that hangs when - * the stage is 'specs running'), `loaded` the runner's + * the stage is 'specs running'), `suite` the innermost suite entered (whose beforeAll or afterAll hangs when the stage is + * 'between specs'), `loaded` the runner's * files whose response the frame received completely, and `missing` those it did not (never requested, or a response * still incomplete). A frame that cannot be read leaves both lists empty. */ -export function frameStage(frameWindow, {reached = 'page requested', specs = 0, current = '', resources = runnerResources} = {}) { +export function frameStage(frameWindow, {reached = 'page requested', specs = 0, current = '', suite = '', resources = runnerResources} = {}) { let loaded = []; let missing = []; try { @@ -202,14 +213,15 @@ export function frameStage(frameWindow, {reached = 'page requested', specs = 0, loaded = expected.filter(file => names.has(file)); missing = expected.filter(file => !names.has(file)); } catch { /* a frame that navigated away or was never attached: only the stage is known */ } - return {reached, specs, current, loaded, missing}; + return {reached, specs, current, suite, loaded, missing}; } /** The stage of a stopped run in words: "stage: specs running, 3 specs done, in suite spec" or "stage: page requested; not loaded: runner.js, specs.js". */ -export function describeStage({reached, specs, current, missing}) { +export function describeStage({reached, specs, current, suite, missing}) { const parts = [`stage: ${reached}`]; if (specs) parts[0] += `, ${plural(specs, 'spec')} done`; if (current && reached === 'specs running') parts[0] += `, in ${current}`; + else if (suite && reached === 'between specs') parts[0] += `, in suite ${suite}`; if (missing.length) parts.push(`not loaded: ${missing.join(', ')}`); return parts.join('; '); } @@ -235,8 +247,9 @@ export function runInFrame({pattern, timeout, runId, signal, write = () => {}, c let reached; let specs = 0; let current = ''; + let suite = ''; // Known once the frame is in the page; a run stopped before that has no stage to give. - const stage = () => frame.isConnected ? frameStage(frame.contentWindow, {reached, specs, current}) : undefined; + const stage = () => frame.isConnected ? frameStage(frame.contentWindow, {reached, specs, current, suite}) : undefined; const finish = (error, report) => { clearTimeout(timer); removeEventListener('message', receive); @@ -248,13 +261,12 @@ export function runInFrame({pattern, timeout, runId, signal, write = () => {}, c if (source !== frame.contentWindow || origin !== location.origin) return; const message = data?.webfrontTest; if (message?.type === 'stage' && typeof message.stage === 'string') { + // A stage replaces the spec and the suite of the previous one: between specs, no spec is running. reached = message.stage.slice(0, 64); - if (typeof message.spec === 'string') current = message.spec.slice(0, 256); + current = typeof message.spec === 'string' ? message.spec.slice(0, 256) : ''; + suite = typeof message.suite === 'string' ? message.suite.slice(0, 256) : ''; } else if (message?.type === 'spec') { - // Until the next spec starts, the run is in a suite's hook or between two specs: no spec is running. specs += 1; - reached = 'between specs'; - current = ''; write(progress[message.status] ?? ''); } else if (message?.type === 'done' || message?.type === 'error') finish(null, buildReport(message, {pattern})); diff --git a/test/developer/specs/testing-specs.mjs b/test/developer/specs/testing-specs.mjs index f2e3b700..97af6b82 100644 --- a/test/developer/specs/testing-specs.mjs +++ b/test/developer/specs/testing-specs.mjs @@ -345,11 +345,11 @@ describe('the stage of a stopped wf test run', () => { it('lists the runner files the frame did not receive, specs.css only when the page links it', () => { expect(frameStage(frame({resources: ['specs.css', 'WebFront.js', 'jasmine.js'], styled: true}), {reached: 'bridge settled'})).toEqual({ - reached: 'bridge settled', specs: 0, current: '', + reached: 'bridge settled', specs: 0, current: '', suite: '', loaded: ['index.html', 'specs.css', 'WebFront.js', 'jasmine.js'], missing: ['runner.js', 'specs.js']}); expect(frameStage(frame({resources: ['WebFront.js', 'jasmine.js', 'runner.js', 'specs.js']})).missing).toEqual([]); // Nothing posted and no page: the runner never started. - expect(frameStage(frame({page: false}))).toEqual({reached: 'page requested', specs: 0, current: '', loaded: [], + expect(frameStage(frame({page: false}))).toEqual({reached: 'page requested', specs: 0, current: '', suite: '', loaded: [], missing: ['index.html', 'WebFront.js', 'jasmine.js', 'runner.js', 'specs.js']}); }); @@ -361,18 +361,20 @@ describe('the stage of a stopped wf test run', () => { }); it('keeps the stage of a frame it cannot read', () => { - expect(frameStage(null, {reached: 'specs loaded', specs: 2})).toEqual({reached: 'specs loaded', specs: 2, current: '', loaded: [], missing: []}); + expect(frameStage(null, {reached: 'specs loaded', specs: 2})).toEqual({reached: 'specs loaded', specs: 2, current: '', suite: '', loaded: [], missing: []}); }); it('says the stage in the message and keeps it in the report', () => { - const stage = {reached: 'specs running', specs: 3, current: 'suite never ends', loaded: [], missing: []}; + const stage = {reached: 'specs running', specs: 3, current: 'suite never ends', suite: 'suite', loaded: [], missing: []}; const stopped = stoppedRun('timeout', 'suite', stage); expect([stopped.exitCode, stopped.message]).toEqual([124, 'Tests stopped at their time limit (stage: specs running, 3 specs done, in suite never ends)']); expect([stopped.report.status, stopped.report.stage, stopped.report.error]).toEqual(['timeout', stage, stopped.message]); expect(describeStage({reached: 'page requested', specs: 0, current: '', loaded: ['index.html'], missing: ['runner.js', 'specs.js']})) .toBe('stage: page requested; not loaded: runner.js, specs.js'); - // A run stopped in a suite's hook or between specs names no spec as running. - expect(describeStage({reached: 'between specs', specs: 2, current: '', loaded: [], missing: []})).toBe('stage: between specs, 2 specs done'); + // A run stopped in a suite's hook or between specs names no spec as running, but the suite whose hooks run. + expect(describeStage({reached: 'between specs', specs: 2, current: '', suite: '', loaded: [], missing: []})).toBe('stage: between specs, 2 specs done'); + expect(describeStage({reached: 'between specs', specs: 0, current: '', suite: 'slow setup', loaded: [], missing: []})) + .toBe('stage: between specs, in suite slow setup'); // Stopped before the frame existed: no stage, and the message stays the plain one. const early = stoppedRun('interrupted', ''); expect([early.exitCode, early.message, 'stage' in early.report]).toEqual([130, 'Tests stopped by Ctrl+C', false]); From a489bc04b9b3fb0d5a7a053553102f7bfabc367b Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 28 Nov 2026 09:04:41 +0100 Subject: [PATCH 5/5] wf test: a spec filtered out does not count as done in the stage of a stopped run (#690) --- js/developer/environment/bundles.json | 2 +- js/developer/environment/testing.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index 859d2eed..ff20401c 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -20,7 +20,7 @@ "js/developer/environment/runtime.mjs": "1b5f0bfc5964b902725a4c765d83db0644cdad91a8f07d8bf6a3bbd0f550c1eb", "js/developer/environment/automation.mjs": "773dcca7b8847c11670995f759c218c86af95a29ea46b44f350f79c4b71a143c", "js/developer/environment/development.mjs": "1f32f911610c72ad3e935de1c2b138fa275ce9eda04bb63c824d5e09923305a6", - "js/developer/environment/testing.mjs": "079539320e6b3eaa16af233758c7681c73fd0359fe4d8ef5f6d2970ea3843699", + "js/developer/environment/testing.mjs": "48695dc7c368d5f0671a0549a61d06c732e10604c56e98f7254f3c4dd21a792c", "js/developer/environment/terminal.mjs": "e7c3ca8f9833f10e07939277996eb01fb989c986420c96052271ff469fa59062", "js/developer/environment/workspace.mjs": "e82ec4df21ffb2b112550e0212504aba05af4f924b5645c0712f40f8466257fc", "js/developer/environment/menu.mjs": "b4fe4c38e6b8cc6c1101df842e282ab85e6c6e029b2225738b9d27bc5efbc88d", diff --git a/js/developer/environment/testing.mjs b/js/developer/environment/testing.mjs index a7169dd6..3a6ceba9 100644 --- a/js/developer/environment/testing.mjs +++ b/js/developer/environment/testing.mjs @@ -266,7 +266,7 @@ export function runInFrame({pattern, timeout, runId, signal, write = () => {}, c current = typeof message.spec === 'string' ? message.spec.slice(0, 256) : ''; suite = typeof message.suite === 'string' ? message.suite.slice(0, 256) : ''; } else if (message?.type === 'spec') { - specs += 1; + if (message.status !== 'excluded') specs += 1; // like the report's total: a spec filtered out did not run write(progress[message.status] ?? ''); } else if (message?.type === 'done' || message?.type === 'error') finish(null, buildReport(message, {pattern}));