Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/DeveloperDistribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
echo "::notice::Sources build $building; DeveloperReleaseData.hpp still pins the published $pinned."
node js/developer/tools/pin-check.mjs
fi
node --test js/developer/tools/check.mjs js/developer/tools/distribution-check.mjs js/developer/tools/manifest-check.mjs js/developer/tools/restore-check.mjs js/developer/tools/scripts-check.mjs js/developer/tools/development-check.mjs
node --test js/developer/tools/check.mjs js/developer/tools/distribution-check.mjs js/developer/tools/manifest-check.mjs js/developer/tools/restore-check.mjs js/developer/tools/scripts-check.mjs js/developer/tools/development-check.mjs js/developer/tools/testing-check.mjs
- name: Check the dedicated release tag
if: startsWith(github.ref, 'refs/tags/developer-v')
env:
Expand Down
7 changes: 7 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

### Added

- `wf test [--timeout <s>] [pattern]` (#310, environment sources; release pin unchanged): builds the manifest's
`test.specs` with esbuild-wasm and runs them under the project's locked `jasmine-core`, obtained by `wf install` from
the registry, in a hidden same-origin frame. Progress and a summary stream to the terminal; the structured report
(counts, failures, pending specs) is bounded, and the exit code is 0, 1 (failure, load error, nothing run), 124 (time
limit) or 130 (Ctrl+C). `runNonInteractive` runs a command without a terminal, sends `{exitCode, output, report}` to an
application's C++ function and ends the session. `DeveloperFS` also serves `.webfront/developer/test/`.

- `wf build [entry]` / `wf dev [entry]` (#309, environment sources; release pin unchanged): build all manifest
entries to `.webfront/developer/build/` without opening the preview, or continuously rebuild one preview
with a persistent esbuild/WASM context. Sequential 750 ms polling watches read inputs and missing imports
Expand Down
64 changes: 61 additions & 3 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ A project has one manifest, the equivalent of `package.json`, which every `wf` c
Only `format`, `name` and `version` are required. Validation is strict: an unknown key, a format
newer than the environment reads, a path leaving the project, a non-HTTPS registry or origin and an
unknown permission are errors printed in the terminal, never silently ignored. `scripts` and `permissions` are
used by `wf run` and `wf exec` (below); `test` is validated here and used by `wf test` (#310). Permissions only frame
used by `wf run` and `wf exec` (below); `test.specs` lists the spec files of `wf test`. Permissions only frame
the operations of the `context` API of scripts; they are not a sandbox.

- `wf init [name]` writes `webfront.project.json` at the project root, the manifest every `wf` command
Expand Down Expand Up @@ -435,9 +435,67 @@ the Worker, cancels polling and aborts staged publication; a publication already
the preview before stopping.
The last successful preview stays available. Browser disconnection also stops the loop.

These commands are in the 0.6.0 environment sources (not published); the release pin stays on published 0.5.0. To try
`wf build`, `wf dev` and `wf test` are in the 0.6.0 environment sources (not published); the release pin stays on published 0.5.0. To try
them before the next release, provision an archive rebuilt from these sources as described below.

## Tests (`wf test`)

`wf test [--timeout <seconds>] [pattern]` runs the project's Jasmine specs in the browser. The project chooses
the Jasmine: `wf install jasmine-core` resolves it from the registry like any package, and the lock pins its version
and integrity. Nothing else is needed: no Node.js, no npm and no public network once the package is in the cache.

```json
{
"dependencies": {"jasmine-core": "7.0.2"},
"test": {"specs": ["tests/model.spec.ts", "tests/view.spec.tsx"]}
}
```

- `test.specs` lists project paths, run in that order (JS, JSX, TS and TSX are built by esbuild-wasm in the Worker of
`wf build`, with the locked dependencies). Specs use the Jasmine globals (`describe`, `it`, `expect`, `jasmine`);
they do not import `jasmine-core`. A spec may import a stylesheet, which the runner page loads. Both the Jasmine 7 and the earlier `jasmine.js`, which only exposes `jasmineRequire`, are started. Without specs, or without `jasmine-core` in the lock, the command says what to
declare or install.
- The specs run in a hidden frame of the environment's page (1024 × 768, same origin, with the bridge loaded, so a
spec can call `webFront.cppFunction`). The runner page, Jasmine and everything the specs built (JS, CSS imported by a spec, assets) are published to a
directory of the run's own, `.webfront/developer/test/<run id>/`, and served by the developer HTTP provider; two
sessions on a project never run each other's specs. The files are removed when the run ends (an empty directory
remains) and the frame is removed at the end, on a time limit and on Ctrl+C.
- `pattern` keeps the specs whose full name (suites and spec names) contains it; the others count as filtered out.
The order is fixed: no random shuffling.
- The terminal shows `.`, `F` and `*` (passed, failed, pending) as specs end, then a summary line (`PASSED: 3 specs,
0 failures, 1 pending (12 ms, jasmine-core 7.0.2)`), each failure with its message and first stack frames, failures
outside any spec (a load error) and those of a suite (an `afterAll` that throws, shown as `FAIL <suite> (suite)`) and the pending specs with their reason.
- Exit codes: 0 when every executed spec passed; 1 for a failed spec, a failure outside the specs, an unhandled
asynchronous exception or rejection (Jasmine reports both as failures), a spec file that does not build or load,
`fit`/`fdescribe`, and a run that executed nothing (no specs, or a pattern matching none); 124 at the time limit
(`--timeout`, default 60 s, 1 to 3600, covering the build and the publication as well as the run, and never later than the `--timeout` of a `wf run` script that runs `wf test`); 130 on Ctrl+C, at any step. Jasmine's own per-spec timeout (5 s by default) still ends a
spec that never completes, which fails.
- A synchronous infinite loop in a spec blocks the page that hosts the frame, as it would in any same-origin frame:
the time limit cannot fire. Use asynchronous waits, which the time limit and Ctrl+C do stop.

The result sent to C++ is cut to 60,000 bytes when it is larger (a bridge string holds 65,535): the output first, then stack frames, messages and the lists, never the counts or the status; `truncated` is then `true`.

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`.

### Without a terminal

An application that drives the environment from its own page (the C++ driver of #321 will be one) calls
`runNonInteractive(argv, {bridge, config, preview, reporter, onExit})` from `runtime.mjs`:

```js
const runtime = await import('/webfront/developer/environment/runtime.mjs');
await runtime.runNonInteractive(['test'], {bridge: webFront, config, preview,
reporter: json => webFront.cppFunction('app.result')(json)});
```

It runs the command, sends `{exitCode, output, report}` as JSON to the C++ function the application registered
(`app.result` here; the report is `null` for commands other than `wf test`) and then calls `onExit(exitCode)`, which
by default closes the window. A command that fails, or a result that cannot be sent, ends with a non-zero code and
the session is never left open. The C++ side reads the result, closes the application's window if it has not been
closed and returns the code as its process status.

## Dependencies, storage and limitations

- `wf install` accepts exact versions, registry tags and semver ranges, resolves ordinary
Expand Down Expand Up @@ -525,7 +583,7 @@ WKWebView and all 14 Linux CEF/Xvfb cases with both GCC and Clang in
The packed 0.3.0 version passes WKWebView and all 14 GCC CEF/Xvfb cases in
[run 39490581423](https://github.com/ambroise-leclerc/WebFront/actions/runs/39490581423).
For Linux, select CEF and Xvfb instead; the same developer tests use the selected test frontend.
`DeveloperBrowserIntegration` exercises the real WASM compiler, local registry, build without navigation, incremental dev reload/error/recovery/Ctrl+C, PI and Life previews, C++ generation/animation and
`DeveloperBrowserIntegration` exercises the real WASM compiler, local registry, `wf test` under the locked jasmine-core (pass, fail, pending, asynchronous failures, pattern, time limit, Ctrl+C, non-interactive report to C++), build without navigation, incremental dev reload/error/recovery/Ctrl+C, PI and Life previews, C++ generation/animation and
repeatable header generation. Its CTest fixtures then build that **browser-generated** header and run
`DeveloperEmbeddedIntegration` and `LifeEmbeddedIntegration` from empty working directories
with no developer callbacks.
Expand Down
2 changes: 1 addition & 1 deletion docs/PROJECT_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Status snapshot: 2026-07-19. Optional mddlog integration note: 2026-10-02. Newco
manifest permissions, which frame the `context` API only and are not a sandbox. Peers require explicit compatible roots/direct
dependencies. The environment's terminal (#308) runs `wf`, built-in and C++ commands (`webfront::Commands`:
per-browser coroutine sessions, streamed output, Ctrl+C cancellation without waiting, drained at shutdown) with
multi-row editing, CJK/emoji widths, persistent history and completion. `wf build` / `wf dev` (#309, environment sources) publish manifest entries and rebuild the preview automatically with a reused esbuild context, bounded input polling, error overlays and Ctrl+C cancellation; the release pin is unchanged. `wf restore [--offline]` (0.5.0, #306) rebuilds or checks
multi-row editing, CJK/emoji widths, persistent history and completion. `wf build` / `wf dev` (#309, environment sources) publish manifest entries and rebuild the preview automatically with a reused esbuild context, bounded input polling, error overlays and Ctrl+C cancellation; `wf test` (#310, environment sources) runs the manifest's specs under the project's locked `jasmine-core` in a hidden frame, with a structured report, exit codes 0/1/124/130 and a non-interactive entry that reports to C++; the release pin is unchanged. `wf restore [--offline]` (0.5.0, #306) rebuilds or checks
the cache from the lock, from the application's registry option, else the manifest's, else npmjs.
See [DEVELOPER_ENVIRONMENT](DEVELOPER_ENVIRONMENT.md) for exact commands and limits.

Expand Down
2 changes: 1 addition & 1 deletion include/webfront/system/DeveloperFS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DeveloperFS {
if (!root.empty() && path.starts_with(prefix)) {
const auto relative = std::string_view(path).substr(prefix.size());
// Only published resources, never source files, staging or the cached archive.
if (!relative.starts_with("environment/") && !relative.starts_with("preview/"))
if (!relative.starts_with("environment/") && !relative.starts_with("preview/") && !relative.starts_with("test/"))
return {};
if (auto published = openPublished(relative))
return published;
Expand Down
20 changes: 20 additions & 0 deletions js/developer/environment/bundler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,23 @@ export async function bundleScript(esbuild, {entry, lock, packages, readProject}
plugins: [scriptPlugin(entry, lock, find), virtualPluginWith(lock, packages, readProject, loaded)]});
return new Map(result.outputFiles.map(file => [file.path.replace(/^\/output\//, ''), file.contents]));
}

/**
* The specs of `wf test` as one ES module: the project's spec files imported in the manifest's order, with the locked
* dependencies. The Jasmine functions are globals of the runner page, so no spec imports jasmine-core.
*/
export async function bundleTests(esbuild, {specs, lock, packages, readProject}) {
const loaded = new Map();
const {find} = createFinder(packages, readProject, loaded, lock);
const contents = specs.map(path => `import ${JSON.stringify(`webfront-spec:${path}`)};`).join('\n');
const entry = {name: 'webfront-tests', setup(build) {
build.onResolve({filter: /^webfront-test-entry$/}, () => ({path: 'entry', namespace: 'webfront-tests'}));
build.onLoad({filter: /.*/, namespace: 'webfront-tests'}, () => ({contents, loader: 'js'}));
build.onResolve({filter: /^webfront-spec:/}, args => find('project', normalize(args.path.slice('webfront-spec:'.length))));
}};
const result = await esbuild.build({entryPoints: ['webfront-test-entry'], bundle: true, write: false,
outdir: '/output', entryNames: 'specs', assetNames: 'assets/[name]-[hash]', format: 'esm', platform: 'browser', target: 'es2022', jsx: 'automatic',
define: {'process.env.NODE_ENV': '"test"'}, legalComments: 'inline',
plugins: [entry, virtualPluginWith(lock, packages, readProject, loaded)]});
return new Map(result.outputFiles.map(file => [file.path.replace(/^\/output\//, ''), file.contents]));
}
11 changes: 6 additions & 5 deletions js/developer/environment/bundles.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
"js/developer/environment/packages.mjs": "6636219f3fef20ea1d274dc9298d8af451ef257b86fe6c1ed0de9a7c797b11d8",
"js/developer/environment/starter.mjs": "f38e290e03aebe146623c2ca9b590d645fb91a51acdf7a98101bb00b5b88096c",
"js/developer/environment/paths.mjs": "3b6114df78eb193161c5c84499dda084cb7ff91c56a4496371c30295d00880e3",
"js/developer/environment/runtime.mjs": "391403965c1661c23359d49fd25e2ddb3f7b026225d32256c578f977dd8a7c8a",
"js/developer/environment/runtime.mjs": "a469f6af149e92c2d25d6055ff69a4af5304d9ccd287d915a29f861fb363d25b",
"js/developer/environment/development.mjs": "dd07bc64e12c3392223f0e7aab0ae2f5223e093930bee8abe78a0cd3e2940d85",
"js/developer/environment/testing.mjs": "326e003f114bdbad68fedbceaded30717b3fc15315e6d87fa747972b681e2dce",
"js/developer/environment/terminal.mjs": "7ffcf7ac6ef63c35cdf5ef70284b384525b13ba18422af069289e53b6c4f6be1",
"js/developer/environment/tarball.mjs": "1c1e1aea067910e1fec74e85b4bf9fbefed9b38187a04d8d2764f0b9a96fca39",
"js/developer/environment/commands.mjs": "8de20c01f02f33c0566f204fcf1ee2382a23344d2103581fe2914469ec570531",
"js/developer/environment/compiler.mjs": "64bf490cd09e1324ff95b88f1b1579c8ca186b953cc96862ab49262fe1a85cca",
"js/developer/environment/bundler.mjs": "8ad11d122478a4c6be2025580c28adfeb801f629ffd8b0ed5f05f8d1520b5a2f",
"js/developer/environment/compiler.mjs": "0158931132aa9b43b7bbbd01de6fa4fc34fce8c65515d593dd494930f7a1910f",
"js/developer/environment/bundler.mjs": "48658151aae4fa5ad54c9fa3386ef4095b793de0f3ad242f95e8e5de0cd0ce4d",
"js/developer/environment/entry.mjs": "b2b942443e3c74ae2c008392ba244d9b7e91db70ba1b4ebbe1357c455ebf51bb",
"js/developer/environment/conditions.mjs": "7f0ecba239480831e38985ccffd4c82309949924f4eb9d938e4ad1b09f5f36ed",
"js/developer/environment/io.mjs": "21af39f07c7eb863908c1df768e3c31de1c6eb8ff757c2a287c4a47c76855db6",
Expand All @@ -39,11 +40,11 @@
"examples/life/ui/main.tsx": "ed11a82aad1639eb6997af8b0fca4d5c5ed4c36422c22a74ac49ae73078d0a91",
"examples/life/ui/style.css": "9bb55eb0f0a3287e5b7dc78af9d69608b87ff42c4d9c8a653bc83a52fe293c44",
"js/developer/tools/distribution.json": "4c8703b10e0bfca70e47e1c2b9f5afe7bbe4b4b87cd8be99e15082cfd2915373",
"js/developer/tools/build.mjs": "ac26574972e1b0ebfb58c8d39ea52a9cf24d2a686370c893308b24c9350183f5",
"js/developer/tools/build.mjs": "c0ee8d7502688f14cc45f0234cc90d3df062c9d05e4e51597ce435a63fa41662",
"js/developer/tools/site.mjs": "1827d3fd7e1e470336aab25ea8686c912c2b674a10f7be496f2f0077fbc45292",
"js/developer/tools/archive.mjs": "bfe9feeb5e4d4e1b7c44c4dec4dcbeab4ae59c2bf16a1d2b32cd6910a2b84e7b",
"js/developer/vendor/package-lock.json": "f6aefe8b4cb0b15f866f41eae425f6654d2c6c2d96438fd0da878c5651585616",
"js/core/bootstrap/bootstrap.bundle.mjs": "1069b307799ed2b0de53914748521731bc9796414a416d56340bbda983ef2443",
"js/developer/environment/packages.bundle.mjs": "7c5b721c9252e81a4228bbef0441576fdb77af983e40675dbeab5976da582529",
"js/developer/environment/packages.bundle.mjs": "e36d1052285a313f7db67c1f58f8332da9e97446b1e2085422ebdae379288045",
"include/webfront/system/DeveloperReleaseData.hpp": "d5aaddb2ba839e4c8df46b7d37e2861163233a9018b0f2fb35a6f79831e16569"
}
7 changes: 4 additions & 3 deletions js/developer/environment/compiler.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as esbuild from 'esbuild-wasm';
import {bundle, bundleScript, bundleContext} from './bundler.mjs';
import {bundle, bundleScript, bundleTests, bundleContext} from './bundler.mjs';

const pending = new Map();
let nextId = 0;
Expand All @@ -10,6 +10,7 @@ const readProject = path => new Promise((resolve, reject) => {
});
const initialized = esbuild.initialize({wasmURL: new URL('./esbuild.wasm', import.meta.url).href, worker: false});
let context, contextKey;
const bundlers = {build: bundle, script: bundleScript, tests: bundleTests};
self.onmessage = async ({data}) => {
if (data.type === 'read-result') {
const request = pending.get(data.id);
Expand All @@ -19,7 +20,7 @@ self.onmessage = async ({data}) => {
else request.resolve(data.bytes);
return;
}
if (data.type !== 'build' && data.type !== 'script') return;
if (!Object.hasOwn(bundlers, data.type)) return;
try {
await initialized;
let files;
Expand All @@ -32,7 +33,7 @@ self.onmessage = async ({data}) => {
contextKey = key;
}
files = await context.rebuild();
} else files = await (data.type === 'script' ? bundleScript : bundle)(esbuild, {...data, readProject});
} else files = await bundlers[data.type](esbuild, {...data, readProject});
self.postMessage({type: 'result', files});
} catch (error) {
self.postMessage({type: 'error', error: error.message, diagnostics: error.errors?.map(({text, location}) => ({text, location}))});
Expand Down
22 changes: 11 additions & 11 deletions js/developer/environment/packages.bundle.mjs

Large diffs are not rendered by default.

Loading
Loading