From 84640723240c2efdd41cb603ae2bfb8c5392be00 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc Date: Sat, 24 Oct 2026 00:29:28 +0200 Subject: [PATCH] Fix wf test WebKit compatibility and remove redundant CI work [#335] --- .gitattributes | 1 - .github/scripts/check-no-ai-attribution.sh | 22 +- .github/scripts/test-no-ai-attribution.sh | 52 +- .github/workflows/DeveloperDistribution.yml | 5 +- AGENTS.md | 2 +- docs/CHANGELOG.md | 21 + docs/DEVELOPER_ENVIRONMENT.md | 31 +- docs/NODE_TOOLS_MIGRATION.md | 5 + docs/PROJECT_STATUS.md | 26 +- docs/TEST_PERFORMANCE.md | 24 +- ...DR-009-modules-et-assets-reproductibles.md | 2 +- ...-013-bootstrap-developpeur-a-la-demande.md | 5 +- ...015-ressources-generees-par-application.md | 3 +- docs/adr/README.md | 4 +- include/webfront/system/WebFrontJsData.hpp | 846 +++++++++--------- js/core/WebFront.js | 2 +- js/developer/environment/bundles.json | 12 +- js/developer/environment/runtime.mjs | 18 +- js/developer/environment/starter.mjs | 2 +- js/developer/scripts/build.mjs | 4 +- js/developer/tools/bundle-inputs.json | 2 - js/developer/tools/distribution.json | 2 +- js/developer/tools/starters/pi/main.tsx | 29 - js/developer/tools/starters/pi/style.css | 5 - test/cmake/AssembleDeveloperFixtures.cmake | 3 +- test/cmake/CheckCEFCopy.cmake | 8 + test/cmake/RunWfDriver.cmake | 30 + test/developer/specs/distribution-specs.mjs | 24 +- test/developer/specs/environment-specs.mjs | 4 +- test/developer/specs/manifest-specs.mjs | 6 +- test/developer/specs/testing-specs.mjs | 92 ++ test/developer/specs/timers-specs.mjs | 48 + test/developer/timers.mjs | 38 + test/driver/WfDriver.hpp | 45 +- test/fixtures/Pi.hpp | 55 -- test/fixtures/SignalDemo.hpp | 30 - test/fixtures/wf-project/tools/sleep.mjs | 2 - .../fixtures/wf-project/webfront.project.json | 10 +- .../wf-sleep-environment/environment.json | 1 + .../fixtures/wf-sleep-environment/runtime.mjs | 14 + test/unit/CMakeLists.txt | 4 +- test/unit/DeveloperTests.cpp | 21 +- test/unit/SignalDemoTests.cpp | 43 - test/unit/WfDriverTests.cpp | 38 + test/web/CMakeLists.txt | 56 +- test/web/DeveloperEmbeddedTest.cpp | 58 -- test/web/DeveloperTest.cpp | 46 +- test/web/JasmineTest.cpp | 4 +- test/web/developer-specs.mjs | 344 ++++--- test/web/suite/react-demo/SignalStudio.jsx | 100 --- test/web/suite/react-demo/style.css | 59 -- test/web/suite/specs/react-demo-specs.mjs | 72 -- test/web/suite/specs/webfront-specs.mjs | 19 +- test/web/suite/webfront.project.json | 2 +- webfront.project.json | 1 + 55 files changed, 1248 insertions(+), 1154 deletions(-) delete mode 100644 js/developer/tools/starters/pi/main.tsx delete mode 100644 js/developer/tools/starters/pi/style.css create mode 100644 test/developer/specs/timers-specs.mjs create mode 100644 test/developer/timers.mjs delete mode 100644 test/fixtures/Pi.hpp delete mode 100644 test/fixtures/SignalDemo.hpp delete mode 100644 test/fixtures/wf-project/tools/sleep.mjs create mode 100644 test/fixtures/wf-sleep-environment/environment.json create mode 100644 test/fixtures/wf-sleep-environment/runtime.mjs delete mode 100644 test/unit/SignalDemoTests.cpp create mode 100644 test/unit/WfDriverTests.cpp delete mode 100644 test/web/DeveloperEmbeddedTest.cpp delete mode 100644 test/web/suite/react-demo/SignalStudio.jsx delete mode 100644 test/web/suite/react-demo/style.css delete mode 100644 test/web/suite/specs/react-demo-specs.mjs diff --git a/.gitattributes b/.gitattributes index 42ea0949..e5d86758 100644 --- a/.gitattributes +++ b/.gitattributes @@ -169,7 +169,6 @@ include/webfront/system/*Data.hpp text eol=lf js/developer/environment/* text eol=lf # Starter archives and every hashed distribution input must be identical on Windows. -js/developer/tools/starters/pi/* text eol=lf examples/life/ui/* text eol=lf js/developer/tools/* text eol=lf diff --git a/.github/scripts/check-no-ai-attribution.sh b/.github/scripts/check-no-ai-attribution.sh index dd452fdd..c66c95ba 100755 --- a/.github/scripts/check-no-ai-attribution.sh +++ b/.github/scripts/check-no-ai-attribution.sh @@ -25,20 +25,28 @@ revision="$head" if [ -n "$base" ]; then revision="$base..$head" fi -if ! git rev-list "$revision" >"$commits"; then +# One Git process supplies all records. Bash matches each line directly, avoiding four grep +# processes and two git-show processes per regression case (especially costly on macOS). +if ! git log --no-show-signature --no-notes --no-decorate --no-patch --no-color --no-graph -z --format='%H%x00%an <%ae>%n%cn <%ce>%x00%B' "$revision" >"$commits"; then echo "::error::unable to list the commits in $revision" exit 1 fi +shopt -s nocasematch +matches_lines() { + local line + while IFS= read -r line; do + if [[ "$line" =~ $2 ]]; then return 0; fi + done <<<"$1" + return 1 +} status=0 -while read -r sha; do - ident="$(git show -s --format='%an <%ae>%n%cn <%ce>' "$sha")" - message="$(git show -s --format='%B' "$sha")" - if grep -qiE "$identity" <<<"$ident"; then +while IFS= read -r -d '' sha && IFS= read -r -d '' ident && IFS= read -r -d '' message; do + if matches_lines "$ident" "$identity"; then echo "::error::$sha has an AI author or committer" status=1 fi - if grep -qiE "$trailer" <<<"$message"; then + if matches_lines "$message" "$trailer"; then echo "::error::$sha message contains AI attribution" status=1 fi @@ -46,7 +54,7 @@ done <"$commits" # Do not print untrusted PR text into workflow commands/logs. for field in PR_TITLE PR_BODY; do - if grep -qiE "$trailer" <<<"${!field-}"; then + if matches_lines "${!field-}" "$trailer"; then echo "::error::$field contains AI attribution" status=1 fi diff --git a/.github/scripts/test-no-ai-attribution.sh b/.github/scripts/test-no-ai-attribution.sh index 11152786..147f5231 100755 --- a/.github/scripts/test-no-ai-attribution.sh +++ b/.github/scripts/test-no-ai-attribution.sh @@ -13,10 +13,21 @@ export GIT_COMMITTER_NAME='Alice Example' GIT_COMMITTER_EMAIL='alice@example.org git init -q "$work" cd -- "$work" +# These checks inspect Git metadata, not the index/worktree or the porcelain commit command. +# commit-tree creates the same real commit chain without scanning the index or updating reflogs. +tree="$(git mktree "$work/parent" + printf '%s\n' "$sha" } + expect() { local expected="$1" label="$2" actual=0 shift 2 @@ -35,6 +46,43 @@ expect 0 'base excluded from range' "$root" "$clean" expect 0 'empty range' "$clean" "$clean" expect 1 'invalid revision fails' "$clean" missing-revision +# Signed commits must have exactly the same record framing under user log settings. +# A fixture verifier exercises Git's signature display without keys or network access. +signed() { + printf 'tree %s\nparent %s\nauthor Alice Example 1700000000 +0000\ncommitter Alice Example 1700000000 +0000\ngpgsig -----BEGIN PGP SIGNATURE-----\n invalid\n -----END PGP SIGNATURE-----\n\n%s\n' "$tree" "$1" "$2" | + git hash-object -t commit -w --stdin +} +cat >"$work/verify-signature" <<'VERIFY' +#!/usr/bin/env bash +: >"${0%/*}/signature-checked" +cat >/dev/null +printf 'gpg: Good signature from "Alice Example"\n' >&2 +printf '[GNUPG:] GOODSIG 0123456789ABCDEF Alice Example\n' +printf '[GNUPG:] VALIDSIG 0123456789ABCDEF0123456789ABCDEF01234567 2023-11-14 1700000000 0 4 0 1 10 00 0123456789ABCDEF0123456789ABCDEF01234567\n' +VERIFY +chmod +x "$work/verify-signature" +git config gpg.program "$work/verify-signature" +git config log.showSignature true +git config log.decorate full +git config log.showNotes true +git config format.pretty oneline +signed_clean="$(signed "$clean" 'Ordinary signed change')" +expect 0 'signed clean commit with user log settings' "$clean" "$signed_clean" +signed_dirty="$(signed "$signed_clean" 'Generated-by: Codex ')" +expect 1 'signed attribution with user log settings' "$clean" "$signed_dirty" +# A second signed record verifies that the parser stays aligned across the range. +signed_after="$(signed "$signed_dirty" 'Another ordinary signed change')" +expect 1 'signed attribution before a clean commit' "$clean" "$signed_after" +if [ -e "$work/signature-checked" ]; then + echo 'FAIL: user signature display invoked the verifier during metadata parsing' + exit 1 +fi +git config --unset gpg.program +git config --unset log.showSignature +git config --unset log.decorate +git config --unset log.showNotes +git config --unset format.pretty + for name in 'Claude Martin' 'Jules Dupont' 'Gemini Rossi' 'Vibe Hansen' 'Copilot Smith'; do sha="$(GIT_AUTHOR_NAME="$name" GIT_COMMITTER_NAME="$name" commit 'Ordinary change')" expect 0 "human author and committer: $name" "$clean" "$sha" diff --git a/.github/workflows/DeveloperDistribution.yml b/.github/workflows/DeveloperDistribution.yml index 8186bcb1..e2425c3e 100644 --- a/.github/workflows/DeveloperDistribution.yml +++ b/.github/workflows/DeveloperDistribution.yml @@ -6,7 +6,6 @@ on: branches: [develop, master] paths: - 'js/developer/environment/**' - - 'js/developer/tools/starters/pi/**' - 'js/developer/scripts/**' - 'examples/life/ui/**' - 'js/developer/tools/**' @@ -23,7 +22,6 @@ on: branches: [develop, master] paths: - 'js/developer/environment/**' - - 'js/developer/tools/starters/pi/**' - 'js/developer/scripts/**' - 'examples/life/ui/**' - 'js/developer/tools/**' @@ -70,7 +68,7 @@ jobs: run: | wf run build build-distribution wf run build build-distribution-repeat - for name in environment.tgz pi-starter.tgz life-starter.tgz provision.json DeveloperReleaseData.hpp; do + for name in environment.tgz life-starter.tgz provision.json DeveloperReleaseData.hpp; do cmp "build-distribution/$name" "build-distribution-repeat/$name" done echo "environment.tgz sha512-$(openssl dgst -sha512 -binary build-distribution/environment.tgz | base64 -w0)" @@ -99,7 +97,6 @@ jobs: if-no-files-found: error path: | build-distribution/environment.tgz - build-distribution/pi-starter.tgz build-distribution/life-starter.tgz build-distribution/provision.json build-distribution/DeveloperReleaseData.hpp diff --git a/AGENTS.md b/AGENTS.md index 4451db53..f819fc6b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -19,7 +19,7 @@ The README introduces WebFront through the Game of Life walkthrough, demonstrati - `include/webfront/frontend/`: system-browser, CEF, optional Windows WebView2 and macOS WKWebView frontend adapters. - `examples/`: only Hello World (`hello-world/`) and Game of Life (`life/`, with console, developer and embedded stages). - `js/core/`: readable browser bridge, fallback and bootstrap loader compiled into `include/webfront/`, plus the embedding CMake modules; `js/developer/`: developer environment (its terminal and `wf`), the wf scripts that build it (`scripts/`), build and vendoring tools. The repository is itself a `wf` project (`webfront.project.json` and its lock at the root): the environment builds itself, and its pure JavaScript specs (`test/developer/`) run with `wf test`. `docs/NODE_TOOLS_MIGRATION.md` records where each former Node.js tool went. Production C++ remains header-only in `include/webfront/`. -- `js/developer/tools/starters/pi/`, `test/fixtures/`, `test/web/fixtures/`: retained package and regression fixtures, not public example applications. +- `test/fixtures/`, `test/web/fixtures/`: retained regression fixtures, not public example applications. - `test/unit/`: Catch2 unit tests; `test/web/`: real-browser integration (`suite/` is the WebFront project of the Jasmine specs, run by `webtest` through `wf test`); `test/driver/`: `webfront-wf`, the non-interactive `wf` driver for tests; `test/fuzz/`, `test/fixtures/`; `test/cmake/`: CMake test scripts and sub-projects. The `RepositoryLayout` CTest case pins the tracked root. - `cmake/`: build modules (frontends, CEF, CPM, compiler options); `.github/`: workflows, `.github/CONTRIBUTING.md`. - `.devcontainer/`: devcontainer and its Dockerfile; `docs/`: documentation, `docs/CHANGELOG.md`, `docs/Doxyfile.in`. diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1c99a460..0f808628 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,27 @@ ## Unreleased +- Remove the retired PI starter from source distributions and `wf create`; Life remains the maintained React/C++ starter. + Preserve real-time fallbacks in scoped test clocks, release preparation cancellation before the test frame runs, + and retain independent reproducibility, bootstrap-refresh and packaged permission checks. The attribution audit + ignores user signature/log display settings. + +### Fixed + +- Script injection works before the page body exists, including a driver handshake completed during HTML parsing. + +- `wf test` supports WebKit engines without `AbortSignal.any()` (#335), preserving cancellation/deadline reports and + exit codes. Deadline and cleanup timers and the external cancellation listener are released on every exit. + The driver also remembers a watchdog close requested before the browser handshake; a late connection closes + without launching a command. Environment sources advance to 0.6.2 while the release and test-bootstrap pins remain on published 0.6.1. +- Browser regressions advance deadlines, grace periods and dev polling explicitly instead of sleeping. Native command + cancellation uses a release handshake, repeated type checks reuse immutable fixture bytes, cache/command fixtures + drop the large application-only dependency graph after the Life checks, and the shared bridge + runner avoids full binary debug dumps. Retired PI and Signal Studio application tests are removed; Life retains + React/TSX, preview, reproducible generation and rootless embedded coverage. Reproducibility compares two identical + builds, followed by a separate bootstrap refresh; packaged-script permission checks remain end-to-end. + + ### Added - Tests, regeneration and CI without a JavaScript runtime or package manager (#318, epic #303). Configuring with `ENABLE_TESTING=ON` downloads, and diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index a62d62dc..05d0c94b 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -53,7 +53,7 @@ its SHA-512 rather than resolving a mutable `latest` channel. An explicit `DeveloperBootstrapOptions{.environment = url, .integrity = trustedHash}` still selects a different HTTPS/CORS repository or a same-origin test fixture. Users install no JavaScript tooling. -The environment archive contains pinned Life and PI starter descriptors. `wf create life` downloads and +The current environment archive contains the pinned Life starter descriptor. `wf create life` downloads and verifies that separate archive, creates a new `ui` directory and prints the install/preview/embed commands. Existing directories are never replaced. The trusted environment hash protects both its own code and the starter descriptor; `provision.json` on the server is not a new trust anchor. @@ -136,9 +136,8 @@ Reconfigure the native build with `WebFrontLifeEmbedded` and run it. Recompilation is explicit. The resulting binary needs neither project sources, downloaded cache nor network. -The PI starter remains available through `wf create pi` for existing projects and regression -coverage. Its sources are maintained under `js/developer/tools/starters/pi/`; the public C++ -examples are limited to Hello World and Life. Existing embedded React/Babel providers remain supported. +The current distribution provides the Life starter; the retired PI starter is no longer shipped. +The former embedded React/Babel providers have been removed; use the generated application provider. ## Project manifest (`webfront.project.json`) @@ -582,13 +581,13 @@ wf run build build-developer-environment --refresh-bootstrap `js/developer/scripts/build.mjs` bundles the environment and compiler with the locked esbuild-wasm (run in the script's Worker), includes esbuild.wasm, xterm styles and licenses, and writes deterministic `environment.tgz`, `life-starter.tgz`, -`pi-starter.tgz`, `provision.json` and `DeveloperReleaseData.hpp`. The version and public base URL are in +`provision.json` and `DeveloperReleaseData.hpp`. The version and public base URL are in `js/developer/tools/distribution.json`. `--refresh-bootstrap` additionally refreshes the two checked-in JS bundles, their input checksums (`bundles.json`, over `js/developer/tools/bundle-inputs.json`) and the pinned header; the core headers that embed the bundles come from `cmake --build --target webfront-embedded-assets`. Without that flag, it writes only to the output directory. `site.mjs` stages a build into the GitHub Pages site and `pin.mjs` checks the pinned header against the published archive. The headers of the core's embedded assets are rendered by `js/core/EmbedAsset.cmake`, in pure CMake (see below). The archives have the package identifiers -`@webfront/developer-environment`, `@webfront/life-starter` and `@webfront/pi-starter`. They are distributed as static +`@webfront/developer-environment` and `@webfront/life-starter`. They are distributed as static GitHub Pages downloads; no npm publication or scope ownership is required. The `SelfBuild*` CTest cases run the scripts on a copy of the sources, with the dependencies installed from the local @@ -637,9 +636,21 @@ 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, `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 +`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, the Life preview, C++ generation/animation and repeatable header generation. Its CTest fixtures then build that +**browser-generated** header and run `LifeEmbeddedIntegration` from an empty working directory with no developer callbacks. -The standard CEF-off suite also checks project transactions, path rejection, PI, Life rules and boundaries, MIME types, +Deadline and grace-period regressions advance a scoped clock instead of sleeping for seconds; Worker startup, +bridge transfers and UI rendering still use the real browser. Dev polling is advanced explicitly after a committed +edit, and native command cancellation waits on a test-controlled release rather than an arbitrary linger duration. +Repeated type checks reuse immutable package bytes after the first real bridge read. After the Life application +checks, cache/command fixtures drop React DOM and retain a small real dependency graph, avoiding repeated transfers +of unrelated server/development bundles while preserving restore, integrity, compilation and rollback assertions. Retired PI and Signal Studio +application tests are removed; bridge scalars, arrays, exceptions and Promise rejection remain covered by the shared +bridge suite, and React/TSX/embedding by the maintained Life example. The browser suite remains one CTest case: +its total duration is reported without subdividing it into artificial timing units. Snapshot/NodeNext assertions +use the already installed real TypeScript compiler in the browser workflow. Developer specs, including cancellation +and clock regressions, run through the repository's own `wf test`. Two identical self-build invocations verify byte reproducibility; a separate build verifies bootstrap refresh. +The packaged-script permission rejection is also exercised end to end. + +The standard CEF-off suite also checks project transactions, path rejection, Life rules and boundaries, MIME types, bootstrap freshness, package resolution, gzip generation, interruption and offline cache reuse. diff --git a/docs/NODE_TOOLS_MIGRATION.md b/docs/NODE_TOOLS_MIGRATION.md index 5bfd4263..95cd53e5 100644 --- a/docs/NODE_TOOLS_MIGRATION.md +++ b/docs/NODE_TOOLS_MIGRATION.md @@ -39,3 +39,8 @@ tracked file; this note and the files of the guard are among its listed exceptio The specs run with `wf test` on the repository (`webfront.project.json`, `test.specs`); the CTest case `DeveloperSpecs` runs them on a copy of the sources, and the `wf-package` job on the checkout with its lock. + +The cancellation/listener/timer regression of #335 is in `testing-specs.mjs`, and its scoped-clock regression is in +`timers-specs.mjs`, sharing `test/developer/timers.mjs` with the browser integration fixture. Both run with `wf test`. +The bounded-snapshot and NodeNext/no-emit checks retain the real compiler already installed by the developer browser +workflow; no separate host runner or fallback was restored when rebasing #335 over #344. diff --git a/docs/PROJECT_STATUS.md b/docs/PROJECT_STATUS.md index d67f75f3..460815bd 100644 --- a/docs/PROJECT_STATUS.md +++ b/docs/PROJECT_STATUS.md @@ -21,8 +21,8 @@ The Jasmine bridge suite is `test/web/suite/`, a WebFront project (`webfront.pro specs call: CTest prepares a copy of the project (`WebSuiteProject`), `wf install` resolves its dependencies from the local registry built by `wf run test-registry` (`WebSuiteInstall`), and the `Web*Integration` case runs `wf test` in the pinned 0.6.1 bootstrap environment under CEF/Xvfb, WebKitGTK, WebView2 or WKWebView. `SpecRunner.html`, the `TestFS` -composition and the use of the embedded Jasmine, React and Babel providers by the browser test are gone; the Signal Studio page is a -JSX module built by esbuild-wasm with the locked React and rendered in the runner frame by the specs. The specs now run +composition and the use of the embedded Jasmine, React and Babel providers by the browser test are gone. +The retired Signal Studio page is no longer part of the suite; Life covers React/TSX in the developer integration. The specs now run in the hidden frame of `wf test`, so the URL assertions of the former top-level page (path, query, fragment) are covered by the `path-encoding` lifecycle case, and `webtest` also checks that C++ observed every call the specs make. The Jasmine case needs no prepared fixtures: configure downloads the registry's packages (#318). The embedded Jasmine, React and Babel providers, their headers (~2.1 MB), `third_party/{babel,react,jasmine}`, `vendor/update.mjs` and `vendor/check.mjs`, their freshness tests and `EmbeddedGzipContents` were removed by #312 (migration: `wf install` and `wf embed`, see `docs/EMBEDDED_ASSETS.md`); the HTTP gzip and identity negotiation tests use a neutral fixture module. @@ -48,7 +48,8 @@ building the environment, publishing it, and the CI. the configure; `-DWEBFRONT_BOOTSTRAP_DIR` and `-DWEBFRONT_REGISTRY_DIR` replace the downloads offline). `WEBFRONT_DEVELOPER_FIXTURES` is gone: the CTest chain builds the registry (`TestRegistry`: `wf run test-registry`), installs the build dependencies from it, builds the environment from the current sources (`SelfBuild*`) and assembles the fixtures of the browser tests - (`DeveloperFixtures`). The environment it builds is byte for byte the published 0.6.1. + (`DeveloperFixtures`). At the #344 merge, this rebuilt the published 0.6.1 byte for byte; #335 advances the + development sources to 0.6.2 while preserving the published 0.6.1 pins. - **Tests.** The pure JavaScript tests of the former runner became Jasmine specs in `test/developer/specs/`, run by the repository's own `wf test` (`DeveloperSpecs`, and the `wf-package` job on the real checkout and lock); 86 tests became 84 specs because two moved to CMake: the checksums of the bundle inputs (`BundleInputsFresh`, `BundleInputsRejectsChange`) and @@ -99,6 +100,21 @@ be checked on the corrected head before merging. See the `docs/CHANGELOG.md`. The developer distribution 0.4.0 is published and archived as `developer-v0.4.0`; published 0.1.0 to 0.4.0 remain immutable. APIs and packaging remain experimental. +## CI regression scope (2026-10-24) + +- Developer sources advance to 0.6.2; the release and test-bootstrap pins stay on the immutable published 0.6.1. +- The retired PI starter, its sources and its distribution archive are removed. Life is the maintained starter and covers + React/TSX, preview, bitset calls, reproducible embedding and an offline executable without developer callbacks. + Retired Signal Studio application regressions are also removed. +- Deadline, grace-period and dev-polling checks advance a scoped clock. Worker startup and bridge/UI operations stay + real. Native command cancellation uses a release handshake; repeated checks reuse immutable fixture package bytes. +- Bounded-snapshot and NodeNext/no-emit compiler checks retain the real compiler in the browser workflow. New + cancellation and clock specs run with the repository's own `wf test`, preserving #344's self-hosted test pipeline. + Two identical self-builds demonstrate reproducibility; a separate build verifies bootstrap refresh. + An end-to-end packaged script verifies publication permissions. +- Tests retain their original CTest grouping: total suite time remains visible. Compilation and complete browser + workflows are still longer than the two-second target; no timing claim is made by splitting the reporting units. + ## Repository presentation for 0.4 (2026-10-21) - Public examples now live in `examples/`: Hello World and the three stages of Game of Life. @@ -152,7 +168,7 @@ Status snapshot: 2026-07-19. Optional mddlog integration note: 2026-10-02. Newco the Linux sanitizers, WebKitGTK and macOS/WKWebView checks. -## Browser-powered development (2026-10-20) +## Historical browser-powered development (2026-10-20) - `NativeApp` can bootstrap a pinned developer environment with a small embedded loader. The downloadable terminal, npm library resolver, esbuild/WASM Worker and gzip/header generator do @@ -172,7 +188,7 @@ Status snapshot: 2026-07-19. Optional mddlog integration note: 2026-10-02. Newco its WKWebView job also passed. The later Windows and sanitizer results are in the validation above. - Versioned environment and Life/PI starter archives have a GitHub Pages publication workflow, immutable-version checks, dedicated prerelease archiving and a checked-in pinned bootstrap - configuration. `wf create life` and `wf create pi` create fresh editable projects without + configuration. At that time, `wf create life` and `wf create pi` created fresh editable projects without overwriting existing files. Maintainer preparation uses `wf` itself (#318); consumers install nothing. Version 0.2.0 was served at `https://ambroise-leclerc.github.io/WebFront/developer/0.2.0/`, with the same archives retained in the `developer-v0.2.0` prerelease; 0.1.0 and later versions are preserved. diff --git a/docs/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index 7e4c13e2..be5c3091 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -11,13 +11,15 @@ manual dispatch still runs only the extended checks. ## Starting point The [21 October 2026 run](https://github.com/ambroise-leclerc/WebFront/actions/runs/39640036175) -reported these elapsed CTest durations, rather than timeout limits: +reported these elapsed CTest durations, rather than timeout limits. These are historical test names: +`DeveloperEmbeddedBuild` and `DeveloperEmbeddedIntegration` were removed with the PI starter; +`LifeEmbeddedBuild` and `LifeEmbeddedIntegration` are the current embedded application checks. | Test | Windows MSVC / WebView2 | | --- | ---: | | BabelAssetFresh | 120.68 s | | LifeEmbeddedBuild | 39.59 s | -| DeveloperEmbeddedBuild | 39.20 s | +| DeveloperEmbeddedBuild (retired PI fixture) | 39.20 s | | AddSubdirectoryConsumer | 26.33 s | | DeveloperBrowserIntegration | 26.01 s | | CEFTestingState | 25.06 s | @@ -41,7 +43,7 @@ their totals should not be compared as a compiler benchmark. generation time, instead of depending on a configure-time variable or independently discovering a different cache. It still configures, cleans, compiles and links the real consumer on every invocation. -- Independent tests overlap under CTest. The two embedded builds retain +- Independent tests overlap under CTest. The remaining Life embedded build retains `RUN_SERIAL` so a CMake regeneration or shared relink cannot race a running binary in the same tree, including on Windows. A build-only resource lock was insufficient for that guarantee. @@ -60,6 +62,11 @@ their totals should not be compared as a compiler benchmark. [macOS job](https://github.com/ambroise-leclerc/WebFront/actions/runs/39674764032/job/119481980751) (61.46 seconds before CTest stopped it). +The four-second `WfDriverTimeout` case intentionally exercises the real driver watchdog. A tiny compatible +environment starts a sleeping command and publishes a readiness marker; the test requires that marker as well as +exit status 71. Compiler startup is covered by the other real-script driver cases and does not consume this watchdog's +budget. This case retains a real elapsed-time check rather than advancing a test clock. + ## Resource audit | Tests | Scheduling constraint | @@ -71,13 +78,12 @@ their totals should not be compared as a compiler benchmark. | CEF option scope | Its own `cef-testing-state` directory; each state still configures separately. | | Consumer | Separate `consumer-build` tree; no browser is opened. | | Browser integration and lifecycle | Keep `RESOURCE_LOCK webfront_port_9002`, including the shared CEF profile and generated browser resources. | -| Developer/Life embedded builds | Keep `FIXTURES_REQUIRED DeveloperGenerated`, then their individual build/run fixture dependencies. `RUN_SERIAL TRUE` excludes every other test while either build runs, protecting running executables from regeneration/relinking. `PROCESSORS 2` records the nested build's two workers. | +| Life embedded build | Keep `FIXTURES_REQUIRED DeveloperGenerated`, then the build/run fixture dependencies. `RUN_SERIAL TRUE` excludes every other test while it runs, protecting running executables from regeneration/relinking. `PROCESSORS 2` records the nested build's two workers. | -The browser setup must finish generating headers before either embedded build -starts. Browser tests remain mutually exclusive; embedded builds remain mutually -exclusive. No test runs alongside a nested build. The consumer has a different -build tree; ordinary independent tests can overlap when neither embedded build -is running. +The browser setup must finish generating headers before the Life embedded build +starts. Browser tests remain mutually exclusive. No test runs alongside the nested build. The consumer has a different +build tree; ordinary independent tests can overlap when the embedded build +is not running. Linux coverage processes still write GCC's normal `.gcda` files on the runner's local filesystem, using libgcov's file locking. Do not copy this parallel coverage diff --git a/docs/adr/ADR-009-modules-et-assets-reproductibles.md b/docs/adr/ADR-009-modules-et-assets-reproductibles.md index aba14546..5dabce1f 100644 --- a/docs/adr/ADR-009-modules-et-assets-reproductibles.md +++ b/docs/adr/ADR-009-modules-et-assets-reproductibles.md @@ -84,5 +84,5 @@ décision et ne s'appliquent plus qu'aux providers produits par `wf embed`. - [Maintenance des assets](../EMBEDDED_ASSETS.md), [contrat HTTP](../HTTP_ASSETS.md), [génération](../../js/core/WebFrontAssets.cmake). - Tests : `Asset.*Fresh`, `EmbeddedGzipContents`, [HTTPEncodingTests](../../test/unit/HTTPEncodingTests.cpp), - [React dans le navigateur](../../test/web/suite/specs/react-demo-specs.mjs). + [React/TSX et application Life dans le navigateur](../../test/web/developer-specs.mjs). - Voir [ADR-002](ADR-002-systemes-de-fichiers-composables.md) et [ADR-016](ADR-016-bootstrap-comme-socle.md). diff --git a/docs/adr/ADR-013-bootstrap-developpeur-a-la-demande.md b/docs/adr/ADR-013-bootstrap-developpeur-a-la-demande.md index b5a04ee4..98277f4a 100644 --- a/docs/adr/ADR-013-bootstrap-developpeur-a-la-demande.md +++ b/docs/adr/ADR-013-bootstrap-developpeur-a-la-demande.md @@ -7,6 +7,7 @@ | 0.1 | 2026-10-20 | Proposée | Ambroise Leclerc | Proposition et première implémentation du bootstrap développeur versionné. | À renseigner après intégration. | | 0.2 | 2026-10-22 | Proposée | Ambroise Leclerc | Alignement sur ADR-016 : la proposition devient la base de l'architecture ; preuves multiplateformes manquantes listées. | [404fed2](https://github.com/ambroise-leclerc/WebFront/commit/404fed2c2145d4faba8efee035e10522ff87a91f) | | 0.3 | 2026-10-22 | Proposée | Ambroise Leclerc | Provisioning local des paquets (#306) : `wf restore [--offline]`, priorité du registre de l'application sur celui du manifeste. | À renseigner après intégration. | +| 0.4 | 2026-10-24 | Proposée | Ambroise Leclerc | Retrait du starter PI ; Life reste le seul starter distribué, créé avec `wf create life`. | [8368f59](https://github.com/ambroise-leclerc/WebFront/commit/8368f595af1534ea6670ee6d5582f245f9edc1f2) | ## Statut et date @@ -43,8 +44,8 @@ La première distribution vise GitHub Pages, avec des chemins `developer/ data{ + static constexpr std::size_t dataSize{25527}; + static constexpr std::array data{ 0x2f2f2f2040627269, 0x65662042726f7773, 0x65722d7369646520, 0x57656246726f6e74, 0x206272696467652e, 0x0a0a2866756e6374, 0x696f6e2028676c6f, 0x62616c29207b0a20, 0x2020202275736520, 0x737472696374223b, 0x0a0a20202020636f, 0x6e737420436f6d6d, 0x616e64203d204f62, 0x6a6563742e667265, 0x657a65287b0a2020, @@ -225,429 +225,431 @@ struct WebFrontJsData { 0x6e6a656374536372, 0x6970743a207b0a20, 0x2020202020202020, 0x2020202020202063, 0x6f6e737420736372, 0x697074203d20646f, 0x63756d656e742e63, 0x7265617465456c65, 0x6d656e7428227363, 0x7269707422293b0a, 0x2020202020202020, 0x2020202020202020, 0x7363726970742e74, 0x657874203d207465, 0x78743b0a20202020, - 0x2020202020202020, 0x20202020646f6375, 0x6d656e742e626f64, 0x792e617070656e64, 0x4368696c64287363, - 0x72697074293b0a20, 0x2020202020202020, 0x2020202020202062, 0x7265616b3b0a2020, 0x2020202020202020, - 0x20207d0a20202020, 0x2020202020202020, 0x64656661756c743a, 0x0a20202020202020, 0x2020202020202020, - 0x207468726f77206e, 0x6577204572726f72, 0x2860556e73757070, 0x6f72746564205765, 0x6246726f6e742074, - 0x65787420636f6d6d, 0x616e6420247b7669, 0x65772e6765745569, 0x6e74382831297d60, 0x293b0a2020202020, - 0x202020202020207d, 0x0a20202020202020, 0x207d0a0a20202020, 0x2020202063616c6c, 0x4a7346756e637469, - 0x6f6e286d65737361, 0x676529207b0a2020, 0x2020202020202020, 0x2020726571756972, 0x654279746573286d, - 0x6573736167652c20, 0x302c20382c202266, 0x756e6374696f6e20, 0x63616c6c20686561, 0x64657222293b0a20, - 0x2020202020202020, 0x202020636f6e7374, 0x20636f756e74203d, 0x206d657373616765, 0x2e67657455696e74, - 0x382831293b0a2020, 0x2020202020202020, 0x2020636f6e737420, 0x63616c6c4964203d, 0x206d657373616765, - 0x2e67657455696e74, 0x313628322c207468, 0x69732e6c6974746c, 0x65456e6469616e29, 0x3b0a202020202020, - 0x2020202020206966, 0x2028636f756e7420, 0x3d3d3d2030290a20, 0x2020202020202020, 0x2020202020202074, - 0x68726f77206e6577, 0x204572726f722822, 0x46756e6374696f6e, 0x2063616c6c206861, 0x73206e6f2066756e, - 0x6374696f6e206e61, 0x6d6522293b0a2020, 0x2020202020202020, 0x2020636f6e737420, 0x7061796c6f616453, - 0x697a65203d206d65, 0x73736167652e6765, 0x7455696e74333228, 0x342c20746869732e, 0x6c6974746c65456e, - 0x6469616e293b0a20, 0x2020202020202020, 0x2020207265717569, 0x7265427974657328, 0x6d6573736167652c, - 0x20382c207061796c, 0x6f616453697a652c, 0x202266756e637469, 0x6f6e2063616c6c20, 0x7061796c6f616422, - 0x293b0a2020202020, 0x2020202020202063, 0x6f6e737420706179, 0x6c6f6164203d206e, 0x6577204461746156, - 0x696577286d657373, 0x6167652e62756666, 0x65722c206d657373, 0x6167652e62797465, 0x4f6666736574202b, - 0x20382c207061796c, 0x6f616453697a6529, 0x3b0a202020202020, 0x202020202020636f, 0x6e7374205b6e616d, - 0x65732c206e616d65, 0x42797465735d203d, 0x20746869732e6465, 0x636f646550617261, 0x6d65746572732831, - 0x2c207061796c6f61, 0x64293b0a20202020, 0x2020202020202020, 0x636f6e7374205b70, 0x6172616d65746572, - 0x732c20706172616d, 0x6574657242797465, 0x735d203d20746869, 0x732e6465636f6465, 0x506172616d657465, - 0x727328636f756e74, 0x202d20312c207061, 0x796c6f61642c206e, 0x616d654279746573, 0x293b0a2020202020, - 0x2020202020202069, 0x6620286e616d6542, 0x79746573202b2070, 0x6172616d65746572, 0x427974657320213d, - 0x3d207061796c6f61, 0x6453697a65290a20, 0x2020202020202020, 0x2020202020202074, 0x68726f77206e6577, - 0x204572726f722822, 0x46756e6374696f6e, 0x2063616c6c20636f, 0x6e7461696e732074, 0x7261696c696e6720, - 0x7061796c6f616420, 0x6461746122293b0a, 0x2020202020202020, 0x202020206c657420, 0x657865637574696f, - 0x6e3b0a2020202020, 0x2020202020202074, 0x7279207b0a202020, 0x2020202020202020, 0x2020202020657865, - 0x637574696f6e203d, 0x20746869732e6578, 0x656375746546756e, 0x6374696f6e286e61, 0x6d65735b305d2c20, - 0x706172616d657465, 0x7273293b0a202020, 0x2020202020202020, 0x207d206361746368, 0x20286572726f7229, - 0x207b0a2020202020, 0x2020202020202020, 0x202020746869732e, 0x7265706f72744361, 0x6c6c4661696c7572, - 0x652863616c6c4964, 0x2c206572726f7229, 0x3b0a202020202020, 0x2020202020202020, 0x202072657475726e, - 0x3b0a202020202020, 0x2020202020207d0a, 0x2020202020202020, 0x202020202f2f2063, 0x616c6c4964203020, - 0x6d65616e73207468, 0x652063616c6c6572, 0x206973206e6f7420, 0x77616974696e6720, 0x666f7220616e7974, - 0x68696e672c20736f, 0x2074686572652069, 0x73206e6f7468696e, 0x6720746f2073656e, 0x64206261636b2e0a, - 0x2020202020202020, 0x2020202069662028, 0x63616c6c49642021, 0x3d3d2030290a2020, 0x2020202020202020, - 0x2020202020205072, 0x6f6d6973652e7265, 0x736f6c7665286578, 0x65637574696f6e29, 0x2e7468656e280a20, - 0x2020202020202020, 0x2020202020202020, 0x20202076616c7565, 0x203d3e2074686973, 0x2e7265706f727443, - 0x616c6c5375636365, 0x73732863616c6c49, 0x642c2076616c7565, 0x292c0a2020202020, 0x2020202020202020, - 0x2020202020202065, 0x72726f72203d3e20, 0x746869732e73656e, 0x6446756e6374696f, 0x6e4572726f722863, - 0x616c6c49642c2065, 0x72726f7229293b0a, 0x2020202020202020, 0x7d0a0a2020202020, 0x2020207265706f72, - 0x7443616c6c466169, 0x6c7572652863616c, 0x6c49642c20657272, 0x6f7229207b0a2020, 0x2020202020202020, - 0x2020696620286361, 0x6c6c4964203d3d3d, 0x2030290a20202020, 0x2020202020202020, 0x20202020636f6e73, - 0x6f6c652e6572726f, 0x7228225b57656246, 0x726f6e74204a6176, 0x6153637269707420, 0x63616c6c5d222c20, - 0x6572726f72293b0a, 0x2020202020202020, 0x20202020656c7365, 0x0a20202020202020, 0x2020202020202020, - 0x20746869732e7365, 0x6e6446756e637469, 0x6f6e4572726f7228, 0x63616c6c49642c20, 0x6572726f72293b0a, - 0x2020202020202020, 0x7d0a0a2020202020, 0x2020207265706f72, 0x7443616c6c537563, 0x636573732863616c, - 0x6c49642c2076616c, 0x756529207b0a2020, 0x2020202020202020, 0x2020747279207b0a, 0x2020202020202020, - 0x2020202020202020, 0x746869732e73656e, 0x6446756e6374696f, 0x6e52657475726e28, 0x63616c6c49642c20, - 0x76616c7565293b0a, 0x2020202020202020, 0x202020207d206361, 0x7463682028657272, 0x6f7229207b0a2020, - 0x2020202020202020, 0x2020202020207468, 0x69732e73656e6446, 0x756e6374696f6e45, 0x72726f722863616c, - 0x6c49642c20657272, 0x6f72293b0a202020, 0x2020202020202020, 0x207d0a2020202020, 0x2020207d0a0a2020, - 0x2020202020206578, 0x656375746546756e, 0x6374696f6e286e61, 0x6d652c2061726773, 0x29207b0a20202020, - 0x2020202020202020, 0x636f6e7374207061, 0x7468203d206e616d, 0x652e73706c697428, 0x222e22293b0a2020, - 0x2020202020202020, 0x2020636f6e737420, 0x6d656d626572203d, 0x20706174682e706f, 0x7028293b0a202020, - 0x2020202020202020, 0x206c657420636f6e, 0x74657874203d2067, 0x6c6f62616c3b0a20, 0x2020202020202020, - 0x202020666f722028, 0x636f6e737420636f, 0x6d706f6e656e7420, 0x6f66207061746829, 0x207b0a2020202020, - 0x2020202020202020, 0x2020206966202863, 0x6f6e74657874203d, 0x3d206e756c6c207c, 0x7c202128636f6d70, - 0x6f6e656e7420696e, 0x20636f6e74657874, 0x29290a2020202020, 0x2020202020202020, 0x2020202020202074, - 0x68726f77206e6577, 0x204572726f722860, 0x4a61766153637269, 0x7074206e616d6573, 0x706163652027247b, - 0x636f6d706f6e656e, 0x747d272077617320, 0x6e6f7420666f756e, 0x64207768696c6520, 0x7265736f6c76696e, - 0x672027247b6e616d, 0x657d2760293b0a20, 0x2020202020202020, 0x2020202020202063, 0x6f6e74657874203d, - 0x20636f6e74657874, 0x5b636f6d706f6e65, 0x6e745d3b0a202020, 0x2020202020202020, 0x207d0a2020202020, - 0x2020202020202069, 0x662028636f6e7465, 0x7874203d3d206e75, 0x6c6c207c7c207479, 0x70656f6620636f6e, - 0x746578745b6d656d, 0x6265725d20213d3d, 0x202266756e637469, 0x6f6e22290a202020, 0x2020202020202020, - 0x2020202020746872, 0x6f77206e65772045, 0x72726f7228604a61, 0x7661536372697074, 0x2066756e6374696f, - 0x6e2027247b6e616d, 0x657d272077617320, 0x6e6f7420666f756e, 0x6460293b0a202020, 0x2020202020202020, - 0x2072657475726e20, 0x636f6e746578745b, 0x6d656d6265725d28, 0x2e2e2e6172677329, 0x3b0a202020202020, - 0x20207d0a0a202020, 0x202020202068616e, 0x646c6546756e6374, 0x696f6e5265747572, 0x6e286d6573736167, - 0x6529207b0a202020, 0x2020202020202020, 0x2072657175697265, 0x4279746573286d65, 0x73736167652c2030, - 0x2c20382c20226675, 0x6e6374696f6e2072, 0x657475726e206865, 0x6164657222293b0a, 0x2020202020202020, - 0x20202020636f6e73, 0x742063616c6c4964, 0x203d206d65737361, 0x67652e6765745569, 0x6e74313628322c20, - 0x746869732e6c6974, 0x746c65456e646961, 0x6e293b0a20202020, 0x2020202020202020, 0x636f6e7374207065, - 0x6e64696e67203d20, 0x746869732e70656e, 0x64696e6743616c6c, 0x732e676574286361, 0x6c6c4964293b0a20, - 0x2020202020202020, 0x2020206966202821, 0x70656e64696e6729, 0x0a20202020202020, 0x2020202020202020, - 0x207468726f77206e, 0x6577204572726f72, 0x286046756e637469, 0x6f6e207265747572, 0x6e2068617320756e, - 0x6b6e6f776e206361, 0x6c6c20696420247b, 0x63616c6c49647d60, 0x293b0a2020202020, 0x2020202020202074, - 0x6869732e70656e64, 0x696e6743616c6c73, 0x2e64656c65746528, 0x63616c6c4964293b, 0x0a0a202020202020, - 0x2020202020202f2f, 0x2041206465636f64, 0x65206661696c7572, 0x652068617320746f, 0x20736574746c6520, - 0x7468652070656e64, 0x696e672063616c6c, 0x2072617468657220, 0x7468616e20657363, 0x61706520696e746f, - 0x2074686520736f63, 0x6b65742068616e64, 0x6c65722c0a202020, 0x2020202020202020, 0x202f2f206f746865, - 0x7277697365207468, 0x652063616c6c6572, 0x27732070726f6d69, 0x736520776f756c64, 0x2068616e6720666f, - 0x72657665722e0a20, 0x2020202020202020, 0x202020747279207b, 0x0a20202020202020, 0x2020202020202020, - 0x20746869732e7365, 0x74746c6552657475, 0x726e2870656e6469, 0x6e672c206d657373, 0x616765293b0a2020, + 0x2020202020202020, 0x2020202028646f63, 0x756d656e742e626f, 0x6479203f3f20646f, 0x63756d656e742e68, + 0x656164203f3f2064, 0x6f63756d656e742e, 0x646f63756d656e74, 0x456c656d656e7429, 0x2e617070656e6443, + 0x68696c6428736372, 0x697074293b0a2020, 0x2020202020202020, 0x2020202020206272, 0x65616b3b0a202020, + 0x2020202020202020, 0x207d0a2020202020, 0x2020202020202064, 0x656661756c743a0a, 0x2020202020202020, + 0x2020202020202020, 0x7468726f77206e65, 0x77204572726f7228, 0x60556e737570706f, 0x7274656420576562, + 0x46726f6e74207465, 0x787420636f6d6d61, 0x6e6420247b766965, 0x772e67657455696e, 0x74382831297d6029, + 0x3b0a202020202020, 0x2020202020207d0a, 0x2020202020202020, 0x7d0a0a2020202020, 0x20202063616c6c4a, + 0x7346756e6374696f, 0x6e286d6573736167, 0x6529207b0a202020, 0x2020202020202020, 0x2072657175697265, + 0x4279746573286d65, 0x73736167652c2030, 0x2c20382c20226675, 0x6e6374696f6e2063, 0x616c6c2068656164, + 0x657222293b0a2020, 0x2020202020202020, 0x2020636f6e737420, 0x636f756e74203d20, 0x6d6573736167652e, + 0x67657455696e7438, 0x2831293b0a202020, 0x2020202020202020, 0x20636f6e73742063, 0x616c6c4964203d20, + 0x6d6573736167652e, 0x67657455696e7431, 0x3628322c20746869, 0x732e6c6974746c65, 0x456e6469616e293b, + 0x0a20202020202020, 0x2020202020696620, 0x28636f756e74203d, 0x3d3d2030290a2020, 0x2020202020202020, + 0x2020202020207468, 0x726f77206e657720, 0x4572726f72282246, 0x756e6374696f6e20, 0x63616c6c20686173, + 0x206e6f2066756e63, 0x74696f6e206e616d, 0x6522293b0a202020, 0x2020202020202020, 0x20636f6e73742070, + 0x61796c6f61645369, 0x7a65203d206d6573, 0x736167652e676574, 0x55696e7433322834, 0x2c20746869732e6c, + 0x6974746c65456e64, 0x69616e293b0a2020, 0x2020202020202020, 0x2020726571756972, 0x654279746573286d, + 0x6573736167652c20, 0x382c207061796c6f, 0x616453697a652c20, 0x2266756e6374696f, 0x6e2063616c6c2070, + 0x61796c6f61642229, 0x3b0a202020202020, 0x202020202020636f, 0x6e7374207061796c, 0x6f6164203d206e65, + 0x7720446174615669, 0x6577286d65737361, 0x67652e6275666665, 0x722c206d65737361, 0x67652e627974654f, + 0x6666736574202b20, 0x382c207061796c6f, 0x616453697a65293b, 0x0a20202020202020, 0x2020202020636f6e, + 0x7374205b6e616d65, 0x732c206e616d6542, 0x797465735d203d20, 0x746869732e646563, 0x6f6465506172616d, + 0x657465727328312c, 0x207061796c6f6164, 0x293b0a2020202020, 0x2020202020202063, 0x6f6e7374205b7061, + 0x72616d6574657273, 0x2c20706172616d65, 0x7465724279746573, 0x5d203d2074686973, 0x2e6465636f646550, + 0x6172616d65746572, 0x7328636f756e7420, 0x2d20312c20706179, 0x6c6f61642c206e61, 0x6d65427974657329, + 0x3b0a202020202020, 0x2020202020206966, 0x20286e616d654279, 0x746573202b207061, 0x72616d6574657242, + 0x7974657320213d3d, 0x207061796c6f6164, 0x53697a65290a2020, 0x2020202020202020, 0x2020202020207468, + 0x726f77206e657720, 0x4572726f72282246, 0x756e6374696f6e20, 0x63616c6c20636f6e, 0x7461696e73207472, + 0x61696c696e672070, 0x61796c6f61642064, 0x61746122293b0a20, 0x2020202020202020, 0x2020206c65742065, + 0x7865637574696f6e, 0x3b0a202020202020, 0x2020202020207472, 0x79207b0a20202020, 0x2020202020202020, + 0x2020202065786563, 0x7574696f6e203d20, 0x746869732e657865, 0x6375746546756e63, 0x74696f6e286e616d, + 0x65735b305d2c2070, 0x6172616d65746572, 0x73293b0a20202020, 0x2020202020202020, 0x7d20636174636820, + 0x286572726f722920, 0x7b0a202020202020, 0x2020202020202020, 0x2020746869732e72, 0x65706f727443616c, + 0x6c4661696c757265, 0x2863616c6c49642c, 0x206572726f72293b, 0x0a20202020202020, 0x2020202020202020, + 0x2072657475726e3b, 0x0a20202020202020, 0x20202020207d0a20, 0x2020202020202020, 0x2020202f2f206361, + 0x6c6c49642030206d, 0x65616e7320746865, 0x2063616c6c657220, 0x6973206e6f742077, 0x616974696e672066, + 0x6f7220616e797468, 0x696e672c20736f20, 0x7468657265206973, 0x206e6f7468696e67, 0x20746f2073656e64, + 0x206261636b2e0a20, 0x2020202020202020, 0x2020206966202863, 0x616c6c496420213d, 0x3d2030290a202020, + 0x2020202020202020, 0x202020202050726f, 0x6d6973652e726573, 0x6f6c766528657865, 0x637574696f6e292e, + 0x7468656e280a2020, 0x2020202020202020, 0x2020202020202020, 0x202076616c756520, 0x3d3e20746869732e, + 0x7265706f72744361, 0x6c6c537563636573, 0x732863616c6c4964, 0x2c2076616c756529, 0x2c0a202020202020, + 0x2020202020202020, 0x2020202020206572, 0x726f72203d3e2074, 0x6869732e73656e64, 0x46756e6374696f6e, + 0x4572726f72286361, 0x6c6c49642c206572, 0x726f7229293b0a20, 0x202020202020207d, 0x0a0a202020202020, + 0x20207265706f7274, 0x43616c6c4661696c, 0x7572652863616c6c, 0x49642c206572726f, 0x7229207b0a202020, + 0x2020202020202020, 0x206966202863616c, 0x6c4964203d3d3d20, 0x30290a2020202020, 0x2020202020202020, + 0x202020636f6e736f, 0x6c652e6572726f72, 0x28225b5765624672, 0x6f6e74204a617661, 0x5363726970742063, + 0x616c6c5d222c2065, 0x72726f72293b0a20, 0x2020202020202020, 0x202020656c73650a, 0x2020202020202020, + 0x2020202020202020, 0x746869732e73656e, 0x6446756e6374696f, 0x6e4572726f722863, 0x616c6c49642c2065, + 0x72726f72293b0a20, 0x202020202020207d, 0x0a0a202020202020, 0x20207265706f7274, 0x43616c6c53756363, + 0x6573732863616c6c, 0x49642c2076616c75, 0x6529207b0a202020, 0x2020202020202020, 0x20747279207b0a20, + 0x2020202020202020, 0x2020202020202074, 0x6869732e73656e64, 0x46756e6374696f6e, 0x52657475726e2863, + 0x616c6c49642c2076, 0x616c7565293b0a20, 0x2020202020202020, 0x2020207d20636174, 0x636820286572726f, + 0x7229207b0a202020, 0x2020202020202020, 0x2020202020746869, 0x732e73656e644675, 0x6e6374696f6e4572, + 0x726f722863616c6c, 0x49642c206572726f, 0x72293b0a20202020, 0x2020202020202020, 0x7d0a202020202020, + 0x20207d0a0a202020, 0x2020202020657865, 0x6375746546756e63, 0x74696f6e286e616d, 0x652c206172677329, + 0x207b0a2020202020, 0x2020202020202063, 0x6f6e737420706174, 0x68203d206e616d65, 0x2e73706c69742822, + 0x2e22293b0a202020, 0x2020202020202020, 0x20636f6e7374206d, 0x656d626572203d20, 0x706174682e706f70, + 0x28293b0a20202020, 0x2020202020202020, 0x6c657420636f6e74, 0x657874203d20676c, 0x6f62616c3b0a2020, + 0x2020202020202020, 0x2020666f72202863, 0x6f6e737420636f6d, 0x706f6e656e74206f, 0x6620706174682920, + 0x7b0a202020202020, 0x2020202020202020, 0x202069662028636f, 0x6e74657874203d3d, 0x206e756c6c207c7c, + 0x202128636f6d706f, 0x6e656e7420696e20, 0x636f6e7465787429, 0x290a202020202020, 0x2020202020202020, + 0x2020202020207468, 0x726f77206e657720, 0x4572726f7228604a, 0x6176615363726970, 0x74206e616d657370, + 0x6163652027247b63, 0x6f6d706f6e656e74, 0x7d2720776173206e, 0x6f7420666f756e64, 0x207768696c652072, + 0x65736f6c76696e67, 0x2027247b6e616d65, 0x7d2760293b0a2020, 0x2020202020202020, 0x202020202020636f, + 0x6e74657874203d20, 0x636f6e746578745b, 0x636f6d706f6e656e, 0x745d3b0a20202020, 0x2020202020202020, + 0x7d0a202020202020, 0x2020202020206966, 0x2028636f6e746578, 0x74203d3d206e756c, 0x6c207c7c20747970, + 0x656f6620636f6e74, 0x6578745b6d656d62, 0x65725d20213d3d20, 0x2266756e6374696f, 0x6e22290a20202020, + 0x2020202020202020, 0x202020207468726f, 0x77206e6577204572, 0x726f7228604a6176, 0x6153637269707420, + 0x66756e6374696f6e, 0x2027247b6e616d65, 0x7d2720776173206e, 0x6f7420666f756e64, 0x60293b0a20202020, + 0x2020202020202020, 0x72657475726e2063, 0x6f6e746578745b6d, 0x656d6265725d282e, 0x2e2e61726773293b, + 0x0a20202020202020, 0x207d0a0a20202020, 0x2020202068616e64, 0x6c6546756e637469, 0x6f6e52657475726e, + 0x286d657373616765, 0x29207b0a20202020, 0x2020202020202020, 0x7265717569726542, 0x79746573286d6573, + 0x736167652c20302c, 0x20382c202266756e, 0x6374696f6e207265, 0x7475726e20686561, 0x64657222293b0a20, + 0x2020202020202020, 0x202020636f6e7374, 0x2063616c6c496420, 0x3d206d6573736167, 0x652e67657455696e, + 0x74313628322c2074, 0x6869732e6c697474, 0x6c65456e6469616e, 0x293b0a2020202020, 0x2020202020202063, + 0x6f6e73742070656e, 0x64696e67203d2074, 0x6869732e70656e64, 0x696e6743616c6c73, 0x2e6765742863616c, + 0x6c4964293b0a2020, 0x2020202020202020, 0x2020696620282170, 0x656e64696e67290a, 0x2020202020202020, + 0x2020202020202020, 0x7468726f77206e65, 0x77204572726f7228, 0x6046756e6374696f, 0x6e2072657475726e, + 0x2068617320756e6b, 0x6e6f776e2063616c, 0x6c20696420247b63, 0x616c6c49647d6029, 0x3b0a202020202020, + 0x2020202020207468, 0x69732e70656e6469, 0x6e6743616c6c732e, 0x64656c6574652863, 0x616c6c4964293b0a, + 0x0a20202020202020, 0x20202020202f2f20, 0x41206465636f6465, 0x206661696c757265, 0x2068617320746f20, + 0x736574746c652074, 0x68652070656e6469, 0x6e672063616c6c20, 0x7261746865722074, 0x68616e2065736361, + 0x706520696e746f20, 0x74686520736f636b, 0x65742068616e646c, 0x65722c0a20202020, 0x2020202020202020, + 0x2f2f206f74686572, 0x7769736520746865, 0x2063616c6c657227, 0x732070726f6d6973, 0x6520776f756c6420, + 0x68616e6720666f72, 0x657665722e0a2020, 0x2020202020202020, 0x2020747279207b0a, 0x2020202020202020, + 0x2020202020202020, 0x746869732e736574, 0x746c655265747572, 0x6e2870656e64696e, 0x672c206d65737361, + 0x6765293b0a202020, 0x2020202020202020, 0x207d206361746368, 0x20286572726f7229, 0x207b0a2020202020, + 0x2020202020202020, 0x20202070656e6469, 0x6e672e72656a6563, 0x74286572726f7229, 0x3b0a202020202020, + 0x2020202020207d0a, 0x2020202020202020, 0x7d0a0a2020202020, 0x202020736574746c, 0x6552657475726e28, + 0x70656e64696e672c, 0x206d657373616765, 0x29207b0a20202020, 0x2020202020202020, 0x636f6e737420636f, + 0x756e74203d206d65, 0x73736167652e6765, 0x7455696e74382831, 0x293b0a2020202020, 0x2020202020202063, + 0x6f6e737420706179, 0x6c6f616453697a65, 0x203d206d65737361, 0x67652e6765745569, 0x6e74333228342c20, + 0x746869732e6c6974, 0x746c65456e646961, 0x6e293b0a20202020, 0x2020202020202020, 0x7265717569726542, + 0x79746573286d6573, 0x736167652c20382c, 0x207061796c6f6164, 0x53697a652c202266, 0x756e6374696f6e20, + 0x72657475726e2070, 0x61796c6f61642229, 0x3b0a202020202020, 0x202020202020636f, 0x6e7374207061796c, + 0x6f6164203d206e65, 0x7720446174615669, 0x6577286d65737361, 0x67652e6275666665, 0x722c206d65737361, + 0x67652e627974654f, 0x6666736574202b20, 0x382c207061796c6f, 0x616453697a65293b, 0x0a0a202020202020, + 0x2020202020206966, 0x2028746869732e63, 0x6172726965734578, 0x63657074696f6e28, 0x636f756e742c2070, + 0x61796c6f61645369, 0x7a652c207061796c, 0x6f61642929207b0a, 0x2020202020202020, 0x2020202020202020, + 0x70656e64696e672e, 0x72656a656374286e, 0x6577204572726f72, 0x28746869732e7369, 0x6e676c6556616c75, + 0x65287061796c6f61, 0x642c207061796c6f, 0x616453697a652c20, 0x2245786365707469, 0x6f6e222929293b0a, + 0x2020202020202020, 0x2020202020202020, 0x72657475726e3b0a, 0x2020202020202020, 0x202020207d0a2020, + 0x2020202020202020, 0x202069662028636f, 0x756e74203d3d3d20, 0x3029207b0a202020, 0x2020202020202020, + 0x2020202020696620, 0x287061796c6f6164, 0x53697a6520213d3d, 0x2030290a20202020, 0x2020202020202020, + 0x2020202020202020, 0x7468726f77206e65, 0x77204572726f7228, 0x22566f6964207265, 0x7475726e20636f6e, + 0x7461696e73207061, 0x796c6f6164206461, 0x746122293b0a2020, 0x2020202020202020, 0x2020202020207065, + 0x6e64696e672e7265, 0x736f6c766528756e, 0x646566696e656429, 0x3b0a202020202020, 0x2020202020202020, + 0x202072657475726e, 0x3b0a202020202020, 0x2020202020207d0a, 0x2020202020202020, 0x2020202069662028, + 0x636f756e7420213d, 0x3d2031290a202020, 0x2020202020202020, 0x2020202020746872, 0x6f77206e65772045, + 0x72726f7228224675, 0x6e6374696f6e2072, 0x657475726e206d75, 0x737420636f6e7461, 0x696e207a65726f20, + 0x6f72206f6e652076, 0x616c756522293b0a, 0x2020202020202020, 0x2020202070656e64, 0x696e672e7265736f, + 0x6c76652874686973, 0x2e73696e676c6556, 0x616c756528706179, 0x6c6f61642c207061, 0x796c6f616453697a, + 0x652c202246756e63, 0x74696f6e2229293b, 0x0a20202020202020, 0x207d0a0a20202020, 0x2020202063617272, + 0x6965734578636570, 0x74696f6e28636f75, 0x6e742c207061796c, 0x6f616453697a652c, 0x207061796c6f6164, + 0x29207b0a20202020, 0x2020202020202020, 0x69662028636f756e, 0x7420213d3d203120, 0x7c7c207061796c6f, + 0x616453697a65203d, 0x3d3d203029207265, 0x7475726e2066616c, 0x73653b0a20202020, 0x2020202020202020, + 0x72657475726e2070, 0x61796c6f61642e67, 0x657455696e743828, 0x3029203d3d3d2050, 0x6172616d54797065, + 0x2e65786365707469, 0x6f6e3b0a20202020, 0x202020207d0a0a20, 0x202020202020202f, 0x2f2f204465636f64, + 0x6573206578616374, 0x6c79206f6e652076, 0x616c756520616e64, 0x2072656a65637473, 0x20616e7920627974, + 0x6573206c65667420, 0x6f76657220616674, 0x65722069742e0a20, 0x2020202020202073, 0x696e676c6556616c, + 0x7565287061796c6f, 0x61642c207061796c, 0x6f616453697a652c, 0x207768617429207b, 0x0a20202020202020, + 0x2020202020636f6e, 0x7374205b76616c75, 0x65732c20636f6e73, 0x756d65645d203d20, 0x746869732e646563, + 0x6f6465506172616d, 0x657465727328312c, 0x207061796c6f6164, 0x293b0a2020202020, 0x2020202020202069, + 0x662028636f6e7375, 0x6d656420213d3d20, 0x7061796c6f616453, 0x697a65290a202020, 0x2020202020202020, + 0x2020202020746872, 0x6f77206e65772045, 0x72726f722860247b, 0x776861747d207265, 0x7475726e20636f6e, + 0x7461696e73207472, 0x61696c696e672070, 0x61796c6f61642064, 0x61746160293b0a20, 0x2020202020202020, + 0x2020207265747572, 0x6e2076616c756573, 0x5b305d3b0a202020, 0x20202020207d0a0a, 0x2020202020202020, + 0x6465636f64655061, 0x72616d6574657273, 0x28636f756e742c20, 0x766965772c206f66, 0x66736574203d2030, + 0x29207b0a20202020, 0x2020202020202020, 0x636f6e7374207661, 0x6c756573203d205b, 0x5d3b0a2020202020, + 0x202020202020206c, 0x657420637572736f, 0x72203d206f666673, 0x65743b0a20202020, 0x2020202020202020, + 0x666f7220286c6574, 0x20696e646578203d, 0x20303b20696e6465, 0x78203c20636f756e, 0x743b202b2b696e64, + 0x657829207b0a2020, 0x2020202020202020, 0x2020202020207265, 0x7175697265427974, 0x657328766965772c, + 0x20637572736f722c, 0x20312c2022706172, 0x616d657465722074, 0x79706522293b0a20, 0x2020202020202020, + 0x2020202020202063, 0x6f6e7374207b7661, 0x6c75652c20627974, 0x65737d203d207468, 0x69732e6465636f64, + 0x6556616c75652876, 0x6965772e67657455, 0x696e743828637572, 0x736f72292c207669, 0x65772c2063757273, + 0x6f72293b0a202020, 0x2020202020202020, 0x202020202076616c, 0x7565732e70757368, 0x2876616c7565293b, + 0x0a20202020202020, 0x2020202020202020, 0x20637572736f7220, 0x2b3d206279746573, 0x3b0a202020202020, + 0x2020202020207d0a, 0x2020202020202020, 0x2020202072657475, 0x726e205b76616c75, 0x65732c2063757273, + 0x6f72202d206f6666, 0x7365745d3b0a2020, 0x2020202020207d0a, 0x0a20202020202020, 0x202f2f2f20446563, + 0x6f64657320746865, 0x2073696e676c6520, 0x76616c7565207374, 0x617274696e672061, 0x7420276f66667365, + 0x74272c2072657475, 0x726e696e67206974, 0x20616c6f6e677369, 0x6465207468652062, 0x79746520636f756e, + 0x7420697420636f6e, 0x73756d65642e0a20, 0x2020202020202064, 0x65636f646556616c, 0x756528747970652c, + 0x20766965772c206f, 0x666673657429207b, 0x0a20202020202020, 0x2020202020636f6e, 0x7374206465636f64, + 0x6572203d2076616c, 0x75654465636f6465, 0x72732e6765742874, 0x797065293b0a2020, 0x2020202020202020, + 0x2020696620282164, 0x65636f646572290a, 0x2020202020202020, 0x2020202020202020, 0x7468726f77206e65, + 0x7720547970654572, 0x726f722860556e73, 0x7570706f72746564, 0x20706172616d6574, 0x6572207479706520, + 0x247b747970657d60, 0x293b0a2020202020, 0x2020202020202072, 0x657475726e206465, 0x636f646572287468, + 0x69732c2074797065, 0x2c20766965772c20, 0x6f6666736574293b, 0x0a20202020202020, 0x207d0a0a20202020, + 0x202020206465636f, 0x64654e756d626572, 0x28766965772c206f, 0x666673657429207b, 0x0a20202020202020, + 0x2020202020726571, 0x7569726542797465, 0x7328766965772c20, 0x6f66667365742c20, 0x392c20226e756d62, + 0x657222293b0a2020, 0x2020202020202020, 0x202072657475726e, 0x207b76616c75653a, 0x20766965772e6765, + 0x74466c6f61743634, 0x286f666673657420, 0x2b20312c20746869, 0x732e6c6974746c65, 0x456e6469616e292c, + 0x2062797465733a20, 0x397d3b0a20202020, 0x202020207d0a0a20, 0x2020202020202064, 0x65636f6465537472, + 0x696e672874797065, 0x2c20766965772c20, 0x6f66667365742920, 0x7b0a202020202020, 0x202020202020636f, + 0x6e73742073697a65, 0x4279746573203d20, 0x74797065203d3d3d, 0x20506172616d5479, 0x70652e736d616c6c, + 0x537472696e67203f, 0x2031203a20323b0a, 0x2020202020202020, 0x2020202072657175, 0x6972654279746573, + 0x28766965772c206f, 0x6666736574202b20, 0x312c2073697a6542, 0x797465732c202273, 0x7472696e67206c65, + 0x6e67746822293b0a, 0x2020202020202020, 0x20202020636f6e73, 0x74206c656e677468, 0x203d2073697a6542, + 0x79746573203d3d3d, 0x2031203f20766965, 0x772e67657455696e, 0x7438286f66667365, 0x74202b203129203a, + 0x20766965772e6765, 0x7455696e74313628, 0x6f6666736574202b, 0x20312c2074686973, 0x2e6c6974746c6545, + 0x6e6469616e293b0a, 0x2020202020202020, 0x20202020636f6e73, 0x74207061796c6f61, 0x64203d206f666673, + 0x6574202b2031202b, 0x2073697a65427974, 0x65733b0a20202020, 0x2020202020202020, 0x7265717569726542, + 0x7974657328766965, 0x772c207061796c6f, 0x61642c206c656e67, 0x74682c2022737472, 0x696e67207061796c, + 0x6f616422293b0a20, 0x2020202020202020, 0x202020636f6e7374, 0x206279746573203d, 0x206e65772055696e, + 0x7438417272617928, 0x766965772e627566, 0x6665722c20766965, 0x772e627974654f66, 0x66736574202b2070, + 0x61796c6f61642c20, 0x6c656e677468293b, 0x0a20202020202020, 0x2020202020726574, 0x75726e207b76616c, + 0x75653a206e657720, 0x546578744465636f, 0x6465722822757466, 0x2d3822292e646563, 0x6f64652862797465, + 0x73292c2062797465, 0x733a2031202b2073, 0x697a654279746573, 0x202b206c656e6774, 0x687d3b0a20202020, + 0x202020207d0a0a20, 0x2020202020202064, 0x65636f6465547570, 0x6c6528766965772c, 0x206f666673657429, + 0x207b0a2020202020, 0x2020202020202072, 0x6571756972654279, 0x7465732876696577, 0x2c206f6666736574, + 0x2c20322c20227475, 0x706c652068656164, 0x657222293b0a2020, 0x2020202020202020, 0x2020636f6e737420, + 0x5b7475706c652c20, 0x636f6e73756d6564, 0x5d203d2074686973, 0x2e6465636f646550, 0x6172616d65746572, + 0x7328766965772e67, 0x657455696e743828, 0x6f6666736574202b, 0x2031292c20766965, 0x772c206f66667365, + 0x74202b2032293b0a, 0x2020202020202020, 0x2020202072657475, 0x726e207b76616c75, 0x653a207475706c65, + 0x2c2062797465733a, 0x2032202b20636f6e, 0x73756d65647d3b0a, 0x2020202020202020, 0x7d0a0a2020202020, + 0x2020202f2f2f2052, 0x65736f6c76657320, 0x74686520656c656d, 0x656e742073706563, 0x20616e64206c656e, + 0x6774682070726566, 0x697820666f722061, 0x2074797065642061, 0x727261792c207768, 0x6f73652068656164, + 0x6572206973203220, 0x627974657320696e, 0x207468650a202020, 0x20202020202f2f2f, 0x20636f6d70616374, + 0x20736d616c6c4172, 0x726179553820666f, 0x726d20616e642035, 0x206279746573206f, 0x7468657277697365, + 0x2e0a202020202020, 0x2020726561645479, 0x7065644172726179, 0x4865616465722874, 0x7970652c20766965, + 0x772c206f66667365, 0x7429207b0a202020, 0x2020202020202020, 0x20636f6e73742073, 0x6d616c6c203d2074, + 0x797065203d3d3d20, 0x506172616d547970, 0x652e736d616c6c41, 0x7272617955383b0a, 0x2020202020202020, + 0x20202020636f6e73, 0x742073706563203d, 0x20736d616c6c203f, 0x207b2e2e2e617272, 0x6179436f6465732e, + 0x6765742850617261, 0x6d547970652e6172, 0x7261795538292c20, 0x636f6e7374727563, 0x746f723a2055696e, + 0x743841727261797d, 0x203a206172726179, 0x436f6465732e6765, 0x742874797065293b, 0x0a20202020202020, + 0x2020202020696620, 0x282173706563290a, 0x2020202020202020, 0x2020202020202020, 0x7468726f77206e65, + 0x7720547970654572, 0x726f722860556e73, 0x7570706f72746564, 0x2074797065642061, 0x7272617920636f64, + 0x6520247b74797065, 0x7d60293b0a202020, 0x2020202020202020, 0x20636f6e73742068, 0x656164657253697a, + 0x65203d20736d616c, 0x6c203f2032203a20, 0x353b0a2020202020, 0x2020202020202072, 0x6571756972654279, + 0x7465732876696577, 0x2c206f6666736574, 0x2c20686561646572, 0x53697a652c202261, 0x7272617920686561, + 0x64657222293b0a20, 0x2020202020202020, 0x202020636f6e7374, 0x206c656e67746820, 0x3d20736d616c6c20, + 0x3f20766965772e67, 0x657455696e743828, 0x6f6666736574202b, 0x203129203a207669, 0x65772e6765745569, + 0x6e743332286f6666, 0x736574202b20312c, 0x20746869732e6c69, 0x74746c65456e6469, 0x616e293b0a202020, + 0x2020202020202020, 0x2072657475726e20, 0x7b737065632c2068, 0x656164657253697a, 0x652c206c656e6774, + 0x687d3b0a20202020, 0x202020207d0a0a20, 0x2020202020202064, 0x65636f6465547970, 0x6564417272617928, + 0x747970652c207669, 0x65772c206f666673, 0x657429207b0a2020, 0x2020202020202020, 0x2020636f6e737420, + 0x7b737065632c2068, 0x656164657253697a, 0x652c206c656e6774, 0x687d203d20746869, 0x732e726561645479, + 0x7065644172726179, 0x4865616465722874, 0x7970652c20766965, 0x772c206f66667365, 0x74293b0a20202020, + 0x2020202020202020, 0x636f6e7374206279, 0x74654c656e677468, 0x203d206c656e6774, 0x68202a2073706563, + 0x2e62797465733b0a, 0x2020202020202020, 0x2020202069662028, 0x214e756d6265722e, 0x697353616665496e, + 0x7465676572286279, 0x74654c656e677468, 0x29290a2020202020, 0x2020202020202020, 0x2020207468726f77, + 0x206e65772052616e, 0x67654572726f7228, 0x2254797065642061, 0x72726179206c656e, 0x6774682069732074, + 0x6f6f206c61726765, 0x22293b0a20202020, 0x2020202020202020, 0x7265717569726542, 0x7974657328766965, + 0x772c206f66667365, 0x74202b2068656164, 0x657253697a652c20, 0x627974654c656e67, 0x74682c2022617272, + 0x6179207061796c6f, 0x616422293b0a0a20, 0x2020202020202020, 0x202020636f6e7374, 0x20726573756c7420, + 0x3d206e6577207370, 0x65632e636f6e7374, 0x727563746f72286c, 0x656e677468293b0a, 0x2020202020202020, + 0x20202020636f6e73, 0x74207061796c6f61, 0x64203d206f666673, 0x6574202b20686561, 0x64657253697a653b, + 0x0a20202020202020, 0x2020202020666f72, 0x20286c657420696e, 0x646578203d20303b, 0x20696e646578203c, + 0x206c656e6774683b, 0x202b2b696e646578, 0x290a202020202020, 0x2020202020202020, 0x2020726573756c74, + 0x5b696e6465785d20, 0x3d20766965775b73, 0x7065632e67657474, 0x65725d287061796c, 0x6f6164202b20696e, + 0x646578202a207370, 0x65632e6279746573, 0x2c20746869732e6c, 0x6974746c65456e64, 0x69616e293b0a2020, + 0x2020202020202020, 0x202072657475726e, 0x207b76616c75653a, 0x20726573756c742c, 0x2062797465733a20, + 0x6865616465725369, 0x7a65202b20627974, 0x654c656e6774687d, 0x3b0a202020202020, 0x20207d0a0a202020, + 0x2020202020637070, 0x46756e6374696f6e, 0x286e616d6529207b, 0x0a20202020202020, 0x2020202020726574, + 0x75726e20282e2e2e, 0x6172677329203d3e, 0x20746869732e6361, 0x6c6c43707046756e, 0x6374696f6e286e61, + 0x6d652c2061726773, 0x293b0a2020202020, 0x2020207d0a0a2020, 0x2020202020206361, 0x6c6c43707046756e, + 0x6374696f6e286e61, 0x6d652c2061726773, 0x29207b0a20202020, 0x2020202020202020, 0x72657475726e206e, + 0x65772050726f6d69, 0x736528287265736f, 0x6c76652c2072656a, 0x65637429203d3e20, 0x7b0a202020202020, + 0x2020202020202020, 0x20206c6574206361, 0x6c6c4964203d2030, 0x3b0a202020202020, 0x2020202020202020, + 0x2020747279207b0a, 0x2020202020202020, 0x2020202020202020, 0x2020202069662028, 0x746869732e737461, + 0x746520213d3d2022, 0x6c696e6b65642229, 0x0a20202020202020, 0x2020202020202020, 0x2020202020202020, + 0x207468726f77206e, 0x6577204572726f72, 0x282257656246726f, 0x6e74206272696467, 0x65206973206e6f74, + 0x20636f6e6e656374, 0x656422293b0a2020, 0x2020202020202020, 0x2020202020202020, 0x2020636f6e737420, + 0x76616c756573203d, 0x205b6e616d652c20, 0x2e2e2e617267735d, 0x3b0a202020202020, 0x2020202020202020, + 0x2020202020206966, 0x202876616c756573, 0x2e6c656e67746820, 0x3e20323535290a20, 0x2020202020202020, + 0x2020202020202020, 0x2020202020202074, 0x68726f77206e6577, 0x2052616e67654572, 0x726f722822412066, + 0x756e6374696f6e20, 0x63616c6c2063616e, 0x6e6f7420636f6e74, 0x61696e206d6f7265, 0x207468616e203235, + 0x3520746f702d6c65, 0x76656c2076616c75, 0x657322293b0a2020, 0x2020202020202020, 0x2020202020202020, + 0x2020636f6e737420, 0x7061796c6f616453, 0x697a65203d207661, 0x6c7565732e726564, 0x756365282873697a, + 0x652c2076616c7565, 0x29203d3e2073697a, 0x65202b2074686973, 0x2e706172616d6574, 0x657253697a652876, + 0x616c7565292c2030, 0x293b0a2020202020, 0x2020202020202020, 0x2020202020202063, 0x6f6e737420627566, + 0x666572203d206e65, 0x7720417272617942, 0x7566666572283820, 0x2b207061796c6f61, 0x6453697a65293b0a, + 0x2020202020202020, 0x2020202020202020, 0x20202020636f6e73, 0x742076696577203d, 0x206e657720446174, + 0x6156696577286275, 0x66666572293b0a20, 0x2020202020202020, 0x2020202020202020, 0x20202063616c6c49, + 0x64203d2074686973, 0x2e616c6c6f636174, 0x6543616c6c496428, 0x293b0a2020202020, 0x2020202020202020, + 0x2020202020202076, 0x6965772e73657455, 0x696e743828302c20, 0x436f6d6d616e642e, 0x63616c6c46756e63, + 0x74696f6e293b0a20, 0x2020202020202020, 0x2020202020202020, 0x202020766965772e, 0x73657455696e7438, + 0x28312c2076616c75, 0x65732e6c656e6774, 0x68293b0a20202020, 0x2020202020202020, 0x2020202020202020, + 0x766965772e736574, 0x55696e7431362832, 0x2c2063616c6c4964, 0x2c20746869732e6c, 0x6974746c65456e64, + 0x69616e293b0a2020, 0x2020202020202020, 0x2020202020202020, 0x2020766965772e73, 0x657455696e743332, + 0x28342c207061796c, 0x6f616453697a652c, 0x20746869732e6c69, 0x74746c65456e6469, 0x616e293b0a202020, + 0x2020202020202020, 0x2020202020202020, 0x206c657420637572, 0x736f72203d20383b, 0x0a20202020202020, + 0x2020202020202020, 0x2020202020666f72, 0x2028636f6e737420, 0x76616c7565206f66, 0x2076616c75657329, + 0x0a20202020202020, 0x2020202020202020, 0x2020202020202020, 0x20637572736f7220, 0x2b3d20746869732e, + 0x656e636f64655061, 0x72616d6574657228, 0x76616c75652c2076, 0x6965772c20637572, 0x736f72293b0a2020, + 0x2020202020202020, 0x2020202020202020, 0x2020746869732e70, 0x656e64696e674361, 0x6c6c732e73657428, + 0x63616c6c49642c20, 0x7b7265736f6c7665, 0x2c2072656a656374, 0x7d293b0a20202020, 0x2020202020202020, + 0x2020202020202020, 0x746869732e736f63, 0x6b65742e73656e64, 0x2862756666657229, 0x3b0a202020202020, 0x2020202020202020, 0x20207d2063617463, 0x6820286572726f72, 0x29207b0a20202020, 0x2020202020202020, - 0x2020202070656e64, 0x696e672e72656a65, 0x6374286572726f72, 0x293b0a2020202020, 0x202020202020207d, - 0x0a20202020202020, 0x207d0a0a20202020, 0x2020202073657474, 0x6c6552657475726e, 0x2870656e64696e67, - 0x2c206d6573736167, 0x6529207b0a202020, 0x2020202020202020, 0x20636f6e73742063, 0x6f756e74203d206d, - 0x6573736167652e67, 0x657455696e743828, 0x31293b0a20202020, 0x2020202020202020, 0x636f6e7374207061, - 0x796c6f616453697a, 0x65203d206d657373, 0x6167652e67657455, 0x696e74333228342c, 0x20746869732e6c69, - 0x74746c65456e6469, 0x616e293b0a202020, 0x2020202020202020, 0x2072657175697265, 0x4279746573286d65, - 0x73736167652c2038, 0x2c207061796c6f61, 0x6453697a652c2022, 0x66756e6374696f6e, 0x2072657475726e20, - 0x7061796c6f616422, 0x293b0a2020202020, 0x2020202020202063, 0x6f6e737420706179, 0x6c6f6164203d206e, - 0x6577204461746156, 0x696577286d657373, 0x6167652e62756666, 0x65722c206d657373, 0x6167652e62797465, - 0x4f6666736574202b, 0x20382c207061796c, 0x6f616453697a6529, 0x3b0a0a2020202020, 0x2020202020202069, - 0x662028746869732e, 0x6361727269657345, 0x7863657074696f6e, 0x28636f756e742c20, 0x7061796c6f616453, - 0x697a652c20706179, 0x6c6f61642929207b, 0x0a20202020202020, 0x2020202020202020, 0x2070656e64696e67, - 0x2e72656a65637428, 0x6e6577204572726f, 0x7228746869732e73, 0x696e676c6556616c, 0x7565287061796c6f, - 0x61642c207061796c, 0x6f616453697a652c, 0x2022457863657074, 0x696f6e222929293b, 0x0a20202020202020, - 0x2020202020202020, 0x2072657475726e3b, 0x0a20202020202020, 0x20202020207d0a20, 0x2020202020202020, - 0x2020206966202863, 0x6f756e74203d3d3d, 0x203029207b0a2020, 0x2020202020202020, 0x2020202020206966, - 0x20287061796c6f61, 0x6453697a6520213d, 0x3d2030290a202020, 0x2020202020202020, 0x2020202020202020, - 0x207468726f77206e, 0x6577204572726f72, 0x2822566f69642072, 0x657475726e20636f, 0x6e7461696e732070, - 0x61796c6f61642064, 0x61746122293b0a20, 0x2020202020202020, 0x2020202020202070, 0x656e64696e672e72, - 0x65736f6c76652875, 0x6e646566696e6564, 0x293b0a2020202020, 0x2020202020202020, 0x2020207265747572, - 0x6e3b0a2020202020, 0x202020202020207d, 0x0a20202020202020, 0x2020202020696620, 0x28636f756e742021, - 0x3d3d2031290a2020, 0x2020202020202020, 0x2020202020207468, 0x726f77206e657720, 0x4572726f72282246, - 0x756e6374696f6e20, 0x72657475726e206d, 0x75737420636f6e74, 0x61696e207a65726f, 0x206f72206f6e6520, - 0x76616c756522293b, 0x0a20202020202020, 0x202020202070656e, 0x64696e672e726573, 0x6f6c766528746869, - 0x732e73696e676c65, 0x56616c7565287061, 0x796c6f61642c2070, 0x61796c6f61645369, 0x7a652c202246756e, - 0x6374696f6e222929, 0x3b0a202020202020, 0x20207d0a0a202020, 0x2020202020636172, 0x7269657345786365, - 0x7074696f6e28636f, 0x756e742c20706179, 0x6c6f616453697a65, 0x2c207061796c6f61, 0x6429207b0a202020, - 0x2020202020202020, 0x2069662028636f75, 0x6e7420213d3d2031, 0x207c7c207061796c, 0x6f616453697a6520, - 0x3d3d3d2030292072, 0x657475726e206661, 0x6c73653b0a202020, 0x2020202020202020, 0x2072657475726e20, - 0x7061796c6f61642e, 0x67657455696e7438, 0x283029203d3d3d20, 0x506172616d547970, 0x652e657863657074, - 0x696f6e3b0a202020, 0x20202020207d0a0a, 0x2020202020202020, 0x2f2f2f204465636f, 0x6465732065786163, - 0x746c79206f6e6520, 0x76616c756520616e, 0x642072656a656374, 0x7320616e79206279, 0x746573206c656674, - 0x206f766572206166, 0x7465722069742e0a, 0x2020202020202020, 0x73696e676c655661, 0x6c7565287061796c, - 0x6f61642c20706179, 0x6c6f616453697a65, 0x2c20776861742920, 0x7b0a202020202020, 0x202020202020636f, - 0x6e7374205b76616c, 0x7565732c20636f6e, 0x73756d65645d203d, 0x20746869732e6465, 0x636f646550617261, - 0x6d65746572732831, 0x2c207061796c6f61, 0x64293b0a20202020, 0x2020202020202020, 0x69662028636f6e73, - 0x756d656420213d3d, 0x207061796c6f6164, 0x53697a65290a2020, 0x2020202020202020, 0x2020202020207468, - 0x726f77206e657720, 0x4572726f72286024, 0x7b776861747d2072, 0x657475726e20636f, 0x6e7461696e732074, - 0x7261696c696e6720, 0x7061796c6f616420, 0x6461746160293b0a, 0x2020202020202020, 0x2020202072657475, - 0x726e2076616c7565, 0x735b305d3b0a2020, 0x2020202020207d0a, 0x0a20202020202020, 0x206465636f646550, - 0x6172616d65746572, 0x7328636f756e742c, 0x20766965772c206f, 0x6666736574203d20, 0x3029207b0a202020, - 0x2020202020202020, 0x20636f6e73742076, 0x616c756573203d20, 0x5b5d3b0a20202020, 0x2020202020202020, - 0x6c65742063757273, 0x6f72203d206f6666, 0x7365743b0a202020, 0x2020202020202020, 0x20666f7220286c65, - 0x7420696e64657820, 0x3d20303b20696e64, 0x6578203c20636f75, 0x6e743b202b2b696e, 0x64657829207b0a20, - 0x2020202020202020, 0x2020202020202072, 0x6571756972654279, 0x7465732876696577, 0x2c20637572736f72, - 0x2c20312c20227061, 0x72616d6574657220, 0x7479706522293b0a, 0x2020202020202020, 0x2020202020202020, - 0x636f6e7374207b76, 0x616c75652c206279, 0x7465737d203d2074, 0x6869732e6465636f, 0x646556616c756528, - 0x766965772e676574, 0x55696e7438286375, 0x72736f72292c2076, 0x6965772c20637572, 0x736f72293b0a2020, - 0x2020202020202020, 0x2020202020207661, 0x6c7565732e707573, 0x682876616c756529, 0x3b0a202020202020, - 0x2020202020202020, 0x2020637572736f72, 0x202b3d2062797465, 0x733b0a2020202020, 0x202020202020207d, - 0x0a20202020202020, 0x2020202020726574, 0x75726e205b76616c, 0x7565732c20637572, 0x736f72202d206f66, - 0x667365745d3b0a20, 0x202020202020207d, 0x0a0a202020202020, 0x20202f2f2f204465, 0x636f646573207468, - 0x652073696e676c65, 0x2076616c75652073, 0x74617274696e6720, 0x617420276f666673, 0x6574272c20726574, - 0x75726e696e672069, 0x7420616c6f6e6773, 0x6964652074686520, 0x6279746520636f75, 0x6e7420697420636f, - 0x6e73756d65642e0a, 0x2020202020202020, 0x6465636f64655661, 0x6c75652874797065, 0x2c20766965772c20, - 0x6f66667365742920, 0x7b0a202020202020, 0x202020202020636f, 0x6e7374206465636f, 0x646572203d207661, - 0x6c75654465636f64, 0x6572732e67657428, 0x74797065293b0a20, 0x2020202020202020, 0x2020206966202821, - 0x6465636f64657229, 0x0a20202020202020, 0x2020202020202020, 0x207468726f77206e, 0x6577205479706545, - 0x72726f722860556e, 0x737570706f727465, 0x6420706172616d65, 0x7465722074797065, 0x20247b747970657d, - 0x60293b0a20202020, 0x2020202020202020, 0x72657475726e2064, 0x65636f6465722874, 0x6869732c20747970, - 0x652c20766965772c, 0x206f666673657429, 0x3b0a202020202020, 0x20207d0a0a202020, 0x2020202020646563, - 0x6f64654e756d6265, 0x7228766965772c20, 0x6f66667365742920, 0x7b0a202020202020, 0x2020202020207265, - 0x7175697265427974, 0x657328766965772c, 0x206f66667365742c, 0x20392c20226e756d, 0x62657222293b0a20, - 0x2020202020202020, 0x2020207265747572, 0x6e207b76616c7565, 0x3a20766965772e67, 0x6574466c6f617436, - 0x34286f6666736574, 0x202b20312c207468, 0x69732e6c6974746c, 0x65456e6469616e29, 0x2c2062797465733a, - 0x20397d3b0a202020, 0x20202020207d0a0a, 0x2020202020202020, 0x6465636f64655374, 0x72696e6728747970, - 0x652c20766965772c, 0x206f666673657429, 0x207b0a2020202020, 0x2020202020202063, 0x6f6e73742073697a, - 0x654279746573203d, 0x2074797065203d3d, 0x3d20506172616d54, 0x7970652e736d616c, 0x6c537472696e6720, - 0x3f2031203a20323b, 0x0a20202020202020, 0x2020202020726571, 0x7569726542797465, 0x7328766965772c20, - 0x6f6666736574202b, 0x20312c2073697a65, 0x42797465732c2022, 0x737472696e67206c, 0x656e67746822293b, - 0x0a20202020202020, 0x2020202020636f6e, 0x7374206c656e6774, 0x68203d2073697a65, 0x4279746573203d3d, - 0x3d2031203f207669, 0x65772e6765745569, 0x6e7438286f666673, 0x6574202b20312920, 0x3a20766965772e67, - 0x657455696e743136, 0x286f666673657420, 0x2b20312c20746869, 0x732e6c6974746c65, 0x456e6469616e293b, - 0x0a20202020202020, 0x2020202020636f6e, 0x7374207061796c6f, 0x6164203d206f6666, 0x736574202b203120, - 0x2b2073697a654279, 0x7465733b0a202020, 0x2020202020202020, 0x2072657175697265, 0x4279746573287669, - 0x65772c207061796c, 0x6f61642c206c656e, 0x6774682c20227374, 0x72696e6720706179, 0x6c6f616422293b0a, - 0x2020202020202020, 0x20202020636f6e73, 0x7420627974657320, 0x3d206e6577205569, 0x6e74384172726179, - 0x28766965772e6275, 0x666665722c207669, 0x65772e627974654f, 0x6666736574202b20, 0x7061796c6f61642c, - 0x206c656e67746829, 0x3b0a202020202020, 0x2020202020207265, 0x7475726e207b7661, 0x6c75653a206e6577, - 0x2054657874446563, 0x6f64657228227574, 0x662d3822292e6465, 0x636f646528627974, 0x6573292c20627974, - 0x65733a2031202b20, 0x73697a6542797465, 0x73202b206c656e67, 0x74687d3b0a202020, 0x20202020207d0a0a, - 0x2020202020202020, 0x6465636f64655475, 0x706c652876696577, 0x2c206f6666736574, 0x29207b0a20202020, - 0x2020202020202020, 0x7265717569726542, 0x7974657328766965, 0x772c206f66667365, 0x742c20322c202274, - 0x75706c6520686561, 0x64657222293b0a20, 0x2020202020202020, 0x202020636f6e7374, 0x205b7475706c652c, - 0x20636f6e73756d65, 0x645d203d20746869, 0x732e6465636f6465, 0x506172616d657465, 0x727328766965772e, - 0x67657455696e7438, 0x286f666673657420, 0x2b2031292c207669, 0x65772c206f666673, 0x6574202b2032293b, - 0x0a20202020202020, 0x2020202020726574, 0x75726e207b76616c, 0x75653a207475706c, 0x652c206279746573, - 0x3a2032202b20636f, 0x6e73756d65647d3b, 0x0a20202020202020, 0x207d0a0a20202020, 0x202020202f2f2f20, - 0x5265736f6c766573, 0x2074686520656c65, 0x6d656e7420737065, 0x6320616e64206c65, 0x6e67746820707265, - 0x66697820666f7220, 0x6120747970656420, 0x61727261792c2077, 0x686f736520686561, 0x6465722069732032, - 0x2062797465732069, 0x6e207468650a2020, 0x2020202020202f2f, 0x2f20636f6d706163, 0x7420736d616c6c41, - 0x7272617955382066, 0x6f726d20616e6420, 0x3520627974657320, 0x6f74686572776973, 0x652e0a2020202020, - 0x2020207265616454, 0x7970656441727261, 0x7948656164657228, 0x747970652c207669, 0x65772c206f666673, - 0x657429207b0a2020, 0x2020202020202020, 0x2020636f6e737420, 0x736d616c6c203d20, 0x74797065203d3d3d, - 0x20506172616d5479, 0x70652e736d616c6c, 0x417272617955383b, 0x0a20202020202020, 0x2020202020636f6e, - 0x7374207370656320, 0x3d20736d616c6c20, 0x3f207b2e2e2e6172, 0x726179436f646573, 0x2e67657428506172, - 0x616d547970652e61, 0x727261795538292c, 0x20636f6e73747275, 0x63746f723a205569, 0x6e74384172726179, - 0x7d203a2061727261, 0x79436f6465732e67, 0x6574287479706529, 0x3b0a202020202020, 0x2020202020206966, - 0x2028217370656329, 0x0a20202020202020, 0x2020202020202020, 0x207468726f77206e, 0x6577205479706545, - 0x72726f722860556e, 0x737570706f727465, 0x6420747970656420, 0x617272617920636f, 0x646520247b747970, - 0x657d60293b0a2020, 0x2020202020202020, 0x2020636f6e737420, 0x6865616465725369, 0x7a65203d20736d61, - 0x6c6c203f2032203a, 0x20353b0a20202020, 0x2020202020202020, 0x7265717569726542, 0x7974657328766965, - 0x772c206f66667365, 0x742c206865616465, 0x7253697a652c2022, 0x6172726179206865, 0x6164657222293b0a, - 0x2020202020202020, 0x20202020636f6e73, 0x74206c656e677468, 0x203d20736d616c6c, 0x203f20766965772e, - 0x67657455696e7438, 0x286f666673657420, 0x2b203129203a2076, 0x6965772e67657455, 0x696e743332286f66, - 0x66736574202b2031, 0x2c20746869732e6c, 0x6974746c65456e64, 0x69616e293b0a2020, 0x2020202020202020, - 0x202072657475726e, 0x207b737065632c20, 0x6865616465725369, 0x7a652c206c656e67, 0x74687d3b0a202020, - 0x20202020207d0a0a, 0x2020202020202020, 0x6465636f64655479, 0x7065644172726179, 0x28747970652c2076, - 0x6965772c206f6666, 0x73657429207b0a20, 0x2020202020202020, 0x202020636f6e7374, 0x207b737065632c20, - 0x6865616465725369, 0x7a652c206c656e67, 0x74687d203d207468, 0x69732e7265616454, 0x7970656441727261, - 0x7948656164657228, 0x747970652c207669, 0x65772c206f666673, 0x6574293b0a202020, 0x2020202020202020, - 0x20636f6e73742062, 0x7974654c656e6774, 0x68203d206c656e67, 0x7468202a20737065, 0x632e62797465733b, - 0x0a20202020202020, 0x2020202020696620, 0x28214e756d626572, 0x2e69735361666549, 0x6e74656765722862, - 0x7974654c656e6774, 0x6829290a20202020, 0x2020202020202020, 0x202020207468726f, 0x77206e6577205261, - 0x6e67654572726f72, 0x2822547970656420, 0x6172726179206c65, 0x6e67746820697320, 0x746f6f206c617267, - 0x6522293b0a202020, 0x2020202020202020, 0x2072657175697265, 0x4279746573287669, 0x65772c206f666673, - 0x6574202b20686561, 0x64657253697a652c, 0x20627974654c656e, 0x6774682c20226172, 0x726179207061796c, - 0x6f616422293b0a0a, 0x2020202020202020, 0x20202020636f6e73, 0x7420726573756c74, 0x203d206e65772073, - 0x7065632e636f6e73, 0x74727563746f7228, 0x6c656e677468293b, 0x0a20202020202020, 0x2020202020636f6e, - 0x7374207061796c6f, 0x6164203d206f6666, 0x736574202b206865, 0x6164657253697a65, 0x3b0a202020202020, - 0x202020202020666f, 0x7220286c65742069, 0x6e646578203d2030, 0x3b20696e64657820, 0x3c206c656e677468, - 0x3b202b2b696e6465, 0x78290a2020202020, 0x2020202020202020, 0x202020726573756c, 0x745b696e6465785d, - 0x203d20766965775b, 0x737065632e676574, 0x7465725d28706179, 0x6c6f6164202b2069, 0x6e646578202a2073, - 0x7065632e62797465, 0x732c20746869732e, 0x6c6974746c65456e, 0x6469616e293b0a20, 0x2020202020202020, - 0x2020207265747572, 0x6e207b76616c7565, 0x3a20726573756c74, 0x2c2062797465733a, 0x2068656164657253, - 0x697a65202b206279, 0x74654c656e677468, 0x7d3b0a2020202020, 0x2020207d0a0a2020, 0x2020202020206370, - 0x7046756e6374696f, 0x6e286e616d652920, 0x7b0a202020202020, 0x2020202020207265, 0x7475726e20282e2e, - 0x2e6172677329203d, 0x3e20746869732e63, 0x616c6c4370704675, 0x6e6374696f6e286e, 0x616d652c20617267, - 0x73293b0a20202020, 0x202020207d0a0a20, 0x2020202020202063, 0x616c6c4370704675, 0x6e6374696f6e286e, - 0x616d652c20617267, 0x7329207b0a202020, 0x2020202020202020, 0x2072657475726e20, 0x6e65772050726f6d, - 0x6973652828726573, 0x6f6c76652c207265, 0x6a65637429203d3e, 0x207b0a2020202020, 0x2020202020202020, - 0x2020206c65742063, 0x616c6c4964203d20, 0x303b0a2020202020, 0x2020202020202020, 0x202020747279207b, - 0x0a20202020202020, 0x2020202020202020, 0x2020202020696620, 0x28746869732e7374, 0x61746520213d3d20, - 0x226c696e6b656422, 0x290a202020202020, 0x2020202020202020, 0x2020202020202020, 0x20207468726f7720, - 0x6e6577204572726f, 0x7228225765624672, 0x6f6e742062726964, 0x6765206973206e6f, 0x7420636f6e6e6563, - 0x74656422293b0a20, 0x2020202020202020, 0x2020202020202020, 0x202020636f6e7374, 0x2076616c75657320, - 0x3d205b6e616d652c, 0x202e2e2e61726773, 0x5d3b0a2020202020, 0x2020202020202020, 0x2020202020202069, - 0x66202876616c7565, 0x732e6c656e677468, 0x203e20323535290a, 0x2020202020202020, 0x2020202020202020, - 0x2020202020202020, 0x7468726f77206e65, 0x772052616e676545, 0x72726f7228224120, 0x66756e6374696f6e, - 0x2063616c6c206361, 0x6e6e6f7420636f6e, 0x7461696e206d6f72, 0x65207468616e2032, 0x353520746f702d6c, - 0x6576656c2076616c, 0x75657322293b0a20, 0x2020202020202020, 0x2020202020202020, 0x202020636f6e7374, - 0x207061796c6f6164, 0x53697a65203d2076, 0x616c7565732e7265, 0x6475636528287369, 0x7a652c2076616c75, - 0x6529203d3e207369, 0x7a65202b20746869, 0x732e706172616d65, 0x74657253697a6528, 0x76616c7565292c20, - 0x30293b0a20202020, 0x2020202020202020, 0x2020202020202020, 0x636f6e7374206275, 0x66666572203d206e, - 0x6577204172726179, 0x4275666665722838, 0x202b207061796c6f, 0x616453697a65293b, 0x0a20202020202020, - 0x2020202020202020, 0x2020202020636f6e, 0x7374207669657720, 0x3d206e6577204461, 0x7461566965772862, - 0x7566666572293b0a, 0x2020202020202020, 0x2020202020202020, 0x2020202063616c6c, 0x4964203d20746869, - 0x732e616c6c6f6361, 0x746543616c6c4964, 0x28293b0a20202020, 0x2020202020202020, 0x2020202020202020, - 0x766965772e736574, 0x55696e743828302c, 0x20436f6d6d616e64, 0x2e63616c6c46756e, 0x6374696f6e293b0a, - 0x2020202020202020, 0x2020202020202020, 0x2020202076696577, 0x2e73657455696e74, 0x3828312c2076616c, - 0x7565732e6c656e67, 0x7468293b0a202020, 0x2020202020202020, 0x2020202020202020, 0x20766965772e7365, - 0x7455696e74313628, 0x322c2063616c6c49, 0x642c20746869732e, 0x6c6974746c65456e, 0x6469616e293b0a20, - 0x2020202020202020, 0x2020202020202020, 0x202020766965772e, 0x73657455696e7433, 0x3228342c20706179, - 0x6c6f616453697a65, 0x2c20746869732e6c, 0x6974746c65456e64, 0x69616e293b0a2020, 0x2020202020202020, - 0x2020202020202020, 0x20206c6574206375, 0x72736f72203d2038, 0x3b0a202020202020, 0x2020202020202020, - 0x202020202020666f, 0x722028636f6e7374, 0x2076616c7565206f, 0x662076616c756573, 0x290a202020202020, - 0x2020202020202020, 0x2020202020202020, 0x2020637572736f72, 0x202b3d2074686973, 0x2e656e636f646550, - 0x6172616d65746572, 0x2876616c75652c20, 0x766965772c206375, 0x72736f72293b0a20, 0x2020202020202020, - 0x2020202020202020, 0x202020746869732e, 0x70656e64696e6743, 0x616c6c732e736574, 0x2863616c6c49642c, - 0x207b7265736f6c76, 0x652c2072656a6563, 0x747d293b0a202020, 0x2020202020202020, 0x2020202020202020, - 0x20746869732e736f, 0x636b65742e73656e, 0x6428627566666572, 0x293b0a2020202020, 0x2020202020202020, - 0x2020207d20636174, 0x636820286572726f, 0x7229207b0a202020, 0x2020202020202020, 0x2020202020202020, - 0x206966202863616c, 0x6c496420213d3d20, 0x30290a2020202020, 0x2020202020202020, 0x2020202020202020, - 0x202020746869732e, 0x70656e64696e6743, 0x616c6c732e64656c, 0x6574652863616c6c, 0x4964293b0a202020, - 0x2020202020202020, 0x2020202020202020, 0x2072656a65637428, 0x6572726f72293b0a, 0x2020202020202020, - 0x2020202020202020, 0x7d0a202020202020, 0x2020202020207d29, 0x3b0a202020202020, 0x20207d0a0a202020, - 0x2020202020616c6c, 0x6f6361746543616c, 0x6c49642829207b0a, 0x2020202020202020, 0x20202020666f7220, - 0x286c657420617474, 0x656d707473203d20, 0x303b20617474656d, 0x707473203c203078, 0x666666663b202b2b, - 0x617474656d707473, 0x29207b0a20202020, 0x2020202020202020, 0x20202020636f6e73, 0x742063616e646964, - 0x617465203d207468, 0x69732e6e65787443, 0x616c6c49643b0a20, 0x2020202020202020, 0x2020202020202074, - 0x6869732e6e657874, 0x43616c6c4964203d, 0x20746869732e6e65, 0x787443616c6c4964, 0x203d3d3d20307866, - 0x666666203f203120, 0x3a20746869732e6e, 0x65787443616c6c49, 0x64202b20313b0a20, 0x2020202020202020, - 0x2020202020202069, 0x6620282174686973, 0x2e70656e64696e67, 0x43616c6c732e6861, 0x732863616e646964, - 0x61746529290a2020, 0x2020202020202020, 0x2020202020202020, 0x202072657475726e, 0x2063616e64696461, - 0x74653b0a20202020, 0x2020202020202020, 0x7d0a202020202020, 0x2020202020207468, 0x726f77206e657720, - 0x4572726f72282254, 0x6f6f206d616e7920, 0x6f75747374616e64, 0x696e672057656246, 0x726f6e742063616c, - 0x6c7322293b0a2020, 0x2020202020207d0a, 0x0a20202020202020, 0x2073656e6446756e, 0x6374696f6e526574, - 0x75726e2863616c6c, 0x49642c2076616c75, 0x6529207b0a202020, 0x2020202020202020, 0x20636f6e73742076, - 0x616c756573203d20, 0x76616c7565203d3d, 0x3d20756e64656669, 0x6e6564203f205b5d, 0x203a205b76616c75, - 0x655d3b0a20202020, 0x2020202020202020, 0x636f6e7374207061, 0x796c6f616453697a, 0x65203d2076616c75, - 0x65732e7265647563, 0x65282873697a652c, 0x206974656d29203d, 0x3e2073697a65202b, 0x20746869732e7061, - 0x72616d6574657253, 0x697a65286974656d, 0x292c2030293b0a20, 0x2020202020202020, 0x202020636f6e7374, - 0x2062756666657220, 0x3d206e6577204172, 0x7261794275666665, 0x722838202b207061, 0x796c6f616453697a, - 0x65293b0a20202020, 0x2020202020202020, 0x636f6e7374207669, 0x6577203d206e6577, 0x2044617461566965, - 0x7728627566666572, 0x293b0a2020202020, 0x2020202020202076, 0x6965772e73657455, 0x696e743828302c20, - 0x436f6d6d616e642e, 0x66756e6374696f6e, 0x52657475726e293b, 0x0a20202020202020, 0x2020202020766965, - 0x772e73657455696e, 0x743828312c207661, 0x6c7565732e6c656e, 0x677468293b0a2020, 0x2020202020202020, - 0x2020766965772e73, 0x657455696e743136, 0x28322c2063616c6c, 0x49642c2074686973, 0x2e6c6974746c6545, - 0x6e6469616e293b0a, 0x2020202020202020, 0x2020202076696577, 0x2e73657455696e74, 0x333228342c207061, - 0x796c6f616453697a, 0x652c20746869732e, 0x6c6974746c65456e, 0x6469616e293b0a20, 0x2020202020202020, - 0x2020206c65742063, 0x7572736f72203d20, 0x383b0a2020202020, 0x2020202020202066, 0x6f722028636f6e73, - 0x74206974656d206f, 0x662076616c756573, 0x290a202020202020, 0x2020202020202020, 0x2020637572736f72, - 0x202b3d2074686973, 0x2e656e636f646550, 0x6172616d65746572, 0x286974656d2c2076, 0x6965772c20637572, - 0x736f72293b0a2020, 0x2020202020202020, 0x2020746869732e73, 0x6f636b65742e7365, 0x6e64286275666665, - 0x72293b0a20202020, 0x202020207d0a0a20, 0x2020202020202073, 0x656e6446756e6374, 0x696f6e4572726f72, - 0x2863616c6c49642c, 0x206572726f722920, 0x7b0a202020202020, 0x202020202020636f, 0x6e7374206d657373, - 0x616765203d206572, 0x726f7220696e7374, 0x616e63656f662045, 0x72726f72203f2065, 0x72726f722e6d6573, - 0x73616765203a2053, 0x7472696e67286572, 0x726f72293b0a2020, 0x2020202020202020, 0x2020636f6e737420, - 0x6279746573203d20, 0x6e65772054657874, 0x456e636f64657228, 0x292e656e636f6465, 0x286d657373616765, - 0x293b0a2020202020, 0x2020202020202069, 0x6620286279746573, 0x2e6c656e67746820, 0x3e3d203635353336, - 0x290a202020202020, 0x2020202020202020, 0x202072657475726e, 0x20746869732e7365, 0x6e6446756e637469, - 0x6f6e4572726f7228, 0x63616c6c49642c20, 0x224a617661536372, 0x6970742065786365, 0x7074696f6e206d65, - 0x7373616765206578, 0x6365656473203635, 0x353335205554462d, 0x3820627974657322, 0x293b0a2020202020, - 0x2020202020202063, 0x6f6e737420627566, 0x666572203d206e65, 0x7720417272617942, 0x7566666572283131, - 0x202b206279746573, 0x2e6c656e67746829, 0x3b0a202020202020, 0x202020202020636f, 0x6e73742076696577, - 0x203d206e65772044, 0x6174615669657728, 0x627566666572293b, 0x0a20202020202020, 0x2020202020766965, - 0x772e73657455696e, 0x743828302c20436f, 0x6d6d616e642e6675, 0x6e6374696f6e5265, 0x7475726e293b0a20, - 0x2020202020202020, 0x202020766965772e, 0x73657455696e7438, 0x28312c2031293b0a, 0x2020202020202020, - 0x2020202076696577, 0x2e73657455696e74, 0x313628322c206361, 0x6c6c49642c207468, 0x69732e6c6974746c, - 0x65456e6469616e29, 0x3b0a202020202020, 0x2020202020207669, 0x65772e7365745569, 0x6e74333228342c20, - 0x33202b2062797465, 0x732e6c656e677468, 0x2c20746869732e6c, 0x6974746c65456e64, 0x69616e293b0a2020, - 0x2020202020202020, 0x2020766965772e73, 0x657455696e743828, 0x382c20506172616d, 0x547970652e657863, - 0x657074696f6e293b, 0x0a20202020202020, 0x2020202020766965, 0x772e73657455696e, 0x74313628392c2062, - 0x797465732e6c656e, 0x6774682c20746869, 0x732e6c6974746c65, 0x456e6469616e293b, 0x0a20202020202020, - 0x20202020206e6577, 0x2055696e74384172, 0x7261792862756666, 0x65722c203131292e, 0x7365742862797465, - 0x73293b0a20202020, 0x2020202020202020, 0x746869732e736f63, 0x6b65742e73656e64, 0x2862756666657229, - 0x3b0a202020202020, 0x20207d0a0a202020, 0x2020202020706172, 0x616d657465725369, 0x7a652876616c7565, - 0x29207b0a20202020, 0x2020202020202020, 0x7377697463682028, 0x747970656f662076, 0x616c756529207b0a, - 0x2020202020202020, 0x2020202063617365, 0x2022626f6f6c6561, 0x6e223a0a20202020, 0x2020202020202020, - 0x2020202072657475, 0x726e20313b0a2020, 0x2020202020202020, 0x2020636173652022, 0x6e756d626572223a, - 0x0a20202020202020, 0x2020202020202020, 0x2072657475726e20, 0x393b0a2020202020, 0x2020202020202063, - 0x6173652022737472, 0x696e67223a0a2020, 0x2020202020202020, 0x2020202020207265, 0x7475726e20746869, - 0x732e737472696e67, 0x506172616d657465, 0x7253697a65287661, 0x6c7565293b0a2020, 0x2020202020202020, - 0x2020636173652022, 0x6f626a656374223a, 0x0a20202020202020, 0x2020202020202020, 0x2072657475726e20, - 0x746869732e6f626a, 0x656374506172616d, 0x6574657253697a65, 0x2876616c7565293b, 0x0a20202020202020, - 0x20202020207d0a20, 0x2020202020202020, 0x2020207468726f77, 0x206e657720547970, 0x654572726f722860, - 0x556e737570706f72, 0x7465642057656246, 0x726f6e7420706172, 0x616d657465722074, 0x7970652027247b74, - 0x7970656f66207661, 0x6c75657d2760293b, 0x0a20202020202020, 0x207d0a0a20202020, 0x2020202073747269, - 0x6e67506172616d65, 0x74657253697a6528, 0x76616c756529207b, 0x0a20202020202020, 0x2020202020636f6e, - 0x7374206c656e6774, 0x68203d206e657720, 0x54657874456e636f, 0x64657228292e656e, 0x636f64652876616c, - 0x7565292e6c656e67, 0x74683b0a20202020, 0x2020202020202020, 0x696620286c656e67, 0x7468203e3d203635, - 0x353336290a202020, 0x2020202020202020, 0x2020202020746872, 0x6f77206e65772052, 0x616e67654572726f, - 0x7228225765624672, 0x6f6e742073747269, 0x6e67732063616e6e, 0x6f74206578636565, 0x6420363535333520, - 0x5554462d38206279, 0x74657322293b0a20, 0x2020202020202020, 0x2020207265747572, 0x6e206c656e677468, - 0x202b20286c656e67, 0x7468203c20323536, 0x203f2032203a2033, 0x293b0a2020202020, 0x2020207d0a0a2020, - 0x2020202020206f62, 0x6a65637450617261, 0x6d6574657253697a, 0x652876616c756529, 0x207b0a2020202020, - 0x2020202020202069, 0x6620284172726179, 0x2e69734172726179, 0x2876616c75652929, 0x0a20202020202020, - 0x2020202020202020, 0x2072657475726e20, 0x746869732e747570, 0x6c65506172616d65, 0x74657253697a6528, - 0x76616c7565293b0a, 0x2020202020202020, 0x2020202069662028, 0x6973547970656441, 0x727261792876616c, - 0x756529290a202020, 0x2020202020202020, 0x2020202020726574, 0x75726e2074686973, 0x2e74797065644172, - 0x726179506172616d, 0x6574657253697a65, 0x2876616c7565293b, 0x0a20202020202020, 0x2020202020746872, - 0x6f77206e65772054, 0x7970654572726f72, 0x2860556e73757070, 0x6f72746564205765, 0x6246726f6e742070, - 0x6172616d65746572, 0x2074797065202724, 0x7b747970656f6620, 0x76616c75657d2760, 0x293b0a2020202020, - 0x2020207d0a0a2020, 0x2020202020207475, 0x706c65506172616d, 0x6574657253697a65, 0x2876616c75652920, - 0x7b0a202020202020, 0x2020202020206966, 0x202876616c75652e, 0x6c656e677468203e, 0x20323535290a2020, - 0x2020202020202020, 0x2020202020207468, 0x726f77206e657720, 0x52616e6765457272, 0x6f72282257656246, - 0x726f6e7420747570, 0x6c65732063616e6e, 0x6f74206578636565, 0x642032353520656c, 0x656d656e74732229, - 0x3b0a202020202020, 0x2020202020207265, 0x7475726e2032202b, 0x2076616c75652e72, 0x6564756365282873, - 0x697a652c20656c65, 0x6d656e7429203d3e, 0x2073697a65202b20, 0x746869732e706172, 0x616d657465725369, - 0x7a6528656c656d65, 0x6e74292c2030293b, 0x0a20202020202020, 0x207d0a0a20202020, 0x2020202074797065, - 0x6441727261795061, 0x72616d6574657253, 0x697a652876616c75, 0x6529207b0a202020, 0x2020202020202020, - 0x2069662028216172, 0x7261795479706573, 0x2e6861732876616c, 0x75652e636f6e7374, 0x727563746f722929, - 0x0a20202020202020, 0x2020202020202020, 0x207468726f77206e, 0x6577205479706545, 0x72726f722860556e, - 0x737570706f727465, 0x6420747970656420, 0x617272617920247b, 0x76616c75652e636f, 0x6e7374727563746f, - 0x722e6e616d657d60, 0x293b0a2020202020, 0x2020202020202069, 0x66202876616c7565, 0x2e6c656e67746820, - 0x3e20307866666666, 0x66666666290a2020, 0x2020202020202020, 0x2020202020207468, 0x726f77206e657720, - 0x52616e6765457272, 0x6f72282254797065, 0x6420617272617973, 0x2063616e6e6f7420, 0x6578636565642034, - 0x3239343936373239, 0x3520656c656d656e, 0x747322293b0a2020, 0x2020202020202020, 0x202072657475726e, - 0x2074797065644172, 0x7261794865616465, 0x7253697a65287661, 0x6c756529202b2076, 0x616c75652e627974, - 0x654c656e6774683b, 0x0a20202020202020, 0x207d0a0a20202020, 0x20202020656e636f, 0x6465506172616d65, - 0x7465722876616c75, 0x652c20766965772c, 0x206f666673657429, 0x207b0a2020202020, 0x2020202020202073, - 0x7769746368202874, 0x7970656f66207661, 0x6c756529207b0a20, 0x2020202020202020, 0x2020206361736520, - 0x22626f6f6c65616e, 0x223a0a2020202020, 0x2020202020202020, 0x202020766965772e, 0x73657455696e7438, - 0x286f66667365742c, 0x2076616c7565203f, 0x20506172616d5479, 0x70652e626f6f6c65, 0x616e54727565203a, - 0x20506172616d5479, 0x70652e626f6f6c65, 0x616e46616c736529, 0x3b0a202020202020, 0x2020202020202020, - 0x202072657475726e, 0x20313b0a20202020, 0x2020202020202020, 0x6361736520226e75, 0x6d626572223a0a20, - 0x2020202020202020, 0x2020202020202076, 0x6965772e73657455, 0x696e7438286f6666, 0x7365742c20506172, - 0x616d547970652e6e, 0x756d626572293b0a, 0x2020202020202020, 0x2020202020202020, 0x766965772e736574, - 0x466c6f6174363428, 0x6f6666736574202b, 0x20312c2076616c75, 0x652c20746869732e, 0x6c6974746c65456e, - 0x6469616e293b0a20, 0x2020202020202020, 0x2020202020202072, 0x657475726e20393b, 0x0a20202020202020, - 0x2020202020636173, 0x652022737472696e, 0x67223a0a20202020, 0x2020202020202020, 0x2020202072657475, - 0x726e20746869732e, 0x656e636f64655374, 0x72696e672876616c, 0x75652c2076696577, 0x2c206f6666736574, - 0x293b0a2020202020, 0x2020202020202063, 0x61736520226f626a, 0x656374223a0a2020, 0x2020202020202020, - 0x2020202020207265, 0x7475726e20746869, 0x732e656e636f6465, 0x4f626a6563742876, 0x616c75652c207669, - 0x65772c206f666673, 0x6574293b0a202020, 0x2020202020202020, 0x207d0a2020202020, 0x2020202020202074, - 0x68726f77206e6577, 0x2054797065457272, 0x6f722860556e7375, 0x70706f7274656420, 0x57656246726f6e74, - 0x20706172616d6574, 0x6572207479706520, 0x27247b747970656f, 0x662076616c75657d, 0x2760293b0a202020, - 0x20202020207d0a0a, 0x2020202020202020, 0x656e636f64655374, 0x72696e672876616c, 0x75652c2076696577, - 0x2c206f6666736574, 0x29207b0a20202020, 0x2020202020202020, 0x636f6e7374206279, 0x746573203d206e65, - 0x772054657874456e, 0x636f64657228292e, 0x656e636f64652876, 0x616c7565293b0a20, 0x2020202020202020, - 0x202020636f6e7374, 0x20736d616c6c203d, 0x2062797465732e6c, 0x656e677468203c20, 0x3235363b0a202020, - 0x2020202020202020, 0x20766965772e7365, 0x7455696e7438286f, 0x66667365742c2073, 0x6d616c6c203f2050, - 0x6172616d54797065, 0x2e736d616c6c5374, 0x72696e67203a2050, 0x6172616d54797065, 0x2e737472696e6729, - 0x3b0a202020202020, 0x2020202020206966, 0x2028736d616c6c29, 0x0a20202020202020, 0x2020202020202020, - 0x20766965772e7365, 0x7455696e7438286f, 0x6666736574202b20, 0x312c206279746573, 0x2e6c656e67746829, - 0x3b0a202020202020, 0x202020202020656c, 0x73650a2020202020, 0x2020202020202020, 0x202020766965772e, - 0x73657455696e7431, 0x36286f6666736574, 0x202b20312c206279, 0x7465732e6c656e67, 0x74682c2074686973, - 0x2e6c6974746c6545, 0x6e6469616e293b0a, 0x2020202020202020, 0x20202020636f6e73, 0x7420686561646572, - 0x53697a65203d2073, 0x6d616c6c203f2032, 0x203a20333b0a2020, 0x2020202020202020, 0x20206e6577205569, - 0x6e74384172726179, 0x28766965772e6275, 0x666665722c207669, 0x65772e627974654f, 0x6666736574202b20, - 0x6f6666736574202b, 0x2068656164657253, 0x697a652c20627974, 0x65732e6c656e6774, 0x68292e7365742862, - 0x79746573293b0a20, 0x2020202020202020, 0x2020207265747572, 0x6e20686561646572, 0x53697a65202b2062, - 0x797465732e6c656e, 0x6774683b0a202020, 0x20202020207d0a0a, 0x2020202020202020, 0x656e636f64654f62, - 0x6a6563742876616c, 0x75652c2076696577, 0x2c206f6666736574, 0x29207b0a20202020, 0x2020202020202020, - 0x6966202841727261, 0x792e697341727261, 0x792876616c756529, 0x290a202020202020, 0x2020202020202020, - 0x202072657475726e, 0x20746869732e656e, 0x636f64655475706c, 0x652876616c75652c, 0x20766965772c206f, - 0x6666736574293b0a, 0x2020202020202020, 0x2020202069662028, 0x6973547970656441, 0x727261792876616c, - 0x756529290a202020, 0x2020202020202020, 0x2020202020726574, 0x75726e2074686973, 0x2e656e636f646554, - 0x7970656441727261, 0x792876616c75652c, 0x20766965772c206f, 0x6666736574293b0a, 0x2020202020202020, + 0x2020202020202020, 0x6966202863616c6c, 0x496420213d3d2030, 0x290a202020202020, 0x2020202020202020, + 0x2020202020202020, 0x2020746869732e70, 0x656e64696e674361, 0x6c6c732e64656c65, 0x74652863616c6c49, + 0x64293b0a20202020, 0x2020202020202020, 0x2020202020202020, 0x72656a6563742865, 0x72726f72293b0a20, + 0x2020202020202020, 0x202020202020207d, 0x0a20202020202020, 0x20202020207d293b, 0x0a20202020202020, + 0x207d0a0a20202020, 0x20202020616c6c6f, 0x6361746543616c6c, 0x49642829207b0a20, 0x2020202020202020, + 0x202020666f722028, 0x6c65742061747465, 0x6d707473203d2030, 0x3b20617474656d70, 0x7473203c20307866, + 0x6666663b202b2b61, 0x7474656d70747329, 0x207b0a2020202020, 0x2020202020202020, 0x202020636f6e7374, + 0x2063616e64696461, 0x7465203d20746869, 0x732e6e6578744361, 0x6c6c49643b0a2020, 0x2020202020202020, + 0x2020202020207468, 0x69732e6e65787443, 0x616c6c4964203d20, 0x746869732e6e6578, 0x7443616c6c496420, + 0x3d3d3d2030786666, 0x6666203f2031203a, 0x20746869732e6e65, 0x787443616c6c4964, 0x202b20313b0a2020, + 0x2020202020202020, 0x2020202020206966, 0x202821746869732e, 0x70656e64696e6743, 0x616c6c732e686173, + 0x2863616e64696461, 0x746529290a202020, 0x2020202020202020, 0x2020202020202020, 0x2072657475726e20, + 0x63616e6469646174, 0x653b0a2020202020, 0x202020202020207d, 0x0a20202020202020, 0x2020202020746872, + 0x6f77206e65772045, 0x72726f722822546f, 0x6f206d616e79206f, 0x75747374616e6469, 0x6e67205765624672, + 0x6f6e742063616c6c, 0x7322293b0a202020, 0x20202020207d0a0a, 0x2020202020202020, 0x73656e6446756e63, + 0x74696f6e52657475, 0x726e2863616c6c49, 0x642c2076616c7565, 0x29207b0a20202020, 0x2020202020202020, + 0x636f6e7374207661, 0x6c756573203d2076, 0x616c7565203d3d3d, 0x20756e646566696e, 0x6564203f205b5d20, + 0x3a205b76616c7565, 0x5d3b0a2020202020, 0x2020202020202063, 0x6f6e737420706179, 0x6c6f616453697a65, + 0x203d2076616c7565, 0x732e726564756365, 0x282873697a652c20, 0x6974656d29203d3e, 0x2073697a65202b20, + 0x746869732e706172, 0x616d657465725369, 0x7a65286974656d29, 0x2c2030293b0a2020, 0x2020202020202020, + 0x2020636f6e737420, 0x627566666572203d, 0x206e657720417272, 0x6179427566666572, 0x2838202b20706179, + 0x6c6f616453697a65, 0x293b0a2020202020, 0x2020202020202063, 0x6f6e737420766965, 0x77203d206e657720, + 0x4461746156696577, 0x2862756666657229, 0x3b0a202020202020, 0x2020202020207669, 0x65772e7365745569, + 0x6e743828302c2043, 0x6f6d6d616e642e66, 0x756e6374696f6e52, 0x657475726e293b0a, 0x2020202020202020, + 0x2020202076696577, 0x2e73657455696e74, 0x3828312c2076616c, 0x7565732e6c656e67, 0x7468293b0a202020, + 0x2020202020202020, 0x20766965772e7365, 0x7455696e74313628, 0x322c2063616c6c49, 0x642c20746869732e, + 0x6c6974746c65456e, 0x6469616e293b0a20, 0x2020202020202020, 0x202020766965772e, 0x73657455696e7433, + 0x3228342c20706179, 0x6c6f616453697a65, 0x2c20746869732e6c, 0x6974746c65456e64, 0x69616e293b0a2020, + 0x2020202020202020, 0x20206c6574206375, 0x72736f72203d2038, 0x3b0a202020202020, 0x202020202020666f, + 0x722028636f6e7374, 0x206974656d206f66, 0x2076616c75657329, 0x0a20202020202020, 0x2020202020202020, + 0x20637572736f7220, 0x2b3d20746869732e, 0x656e636f64655061, 0x72616d6574657228, 0x6974656d2c207669, + 0x65772c2063757273, 0x6f72293b0a202020, 0x2020202020202020, 0x20746869732e736f, 0x636b65742e73656e, + 0x6428627566666572, 0x293b0a2020202020, 0x2020207d0a0a2020, 0x2020202020207365, 0x6e6446756e637469, + 0x6f6e4572726f7228, 0x63616c6c49642c20, 0x6572726f7229207b, 0x0a20202020202020, 0x2020202020636f6e, + 0x7374206d65737361, 0x6765203d20657272, 0x6f7220696e737461, 0x6e63656f66204572, 0x726f72203f206572, + 0x726f722e6d657373, 0x616765203a205374, 0x72696e6728657272, 0x6f72293b0a202020, 0x2020202020202020, + 0x20636f6e73742062, 0x79746573203d206e, 0x6577205465787445, 0x6e636f6465722829, 0x2e656e636f646528, + 0x6d65737361676529, 0x3b0a202020202020, 0x2020202020206966, 0x202862797465732e, 0x6c656e677468203e, + 0x3d20363535333629, 0x0a20202020202020, 0x2020202020202020, 0x2072657475726e20, 0x746869732e73656e, + 0x6446756e6374696f, 0x6e4572726f722863, 0x616c6c49642c2022, 0x4a61766153637269, 0x7074206578636570, + 0x74696f6e206d6573, 0x7361676520657863, 0x6565647320363535, 0x3335205554462d38, 0x2062797465732229, + 0x3b0a202020202020, 0x202020202020636f, 0x6e73742062756666, 0x6572203d206e6577, 0x2041727261794275, + 0x6666657228313120, 0x2b2062797465732e, 0x6c656e677468293b, 0x0a20202020202020, 0x2020202020636f6e, + 0x7374207669657720, 0x3d206e6577204461, 0x7461566965772862, 0x7566666572293b0a, 0x2020202020202020, + 0x2020202076696577, 0x2e73657455696e74, 0x3828302c20436f6d, 0x6d616e642e66756e, 0x6374696f6e526574, + 0x75726e293b0a2020, 0x2020202020202020, 0x2020766965772e73, 0x657455696e743828, 0x312c2031293b0a20, + 0x2020202020202020, 0x202020766965772e, 0x73657455696e7431, 0x3628322c2063616c, 0x6c49642c20746869, + 0x732e6c6974746c65, 0x456e6469616e293b, 0x0a20202020202020, 0x2020202020766965, 0x772e73657455696e, + 0x74333228342c2033, 0x202b206279746573, 0x2e6c656e6774682c, 0x20746869732e6c69, 0x74746c65456e6469, + 0x616e293b0a202020, 0x2020202020202020, 0x20766965772e7365, 0x7455696e74382838, 0x2c20506172616d54, + 0x7970652e65786365, 0x7074696f6e293b0a, 0x2020202020202020, 0x2020202076696577, 0x2e73657455696e74, + 0x313628392c206279, 0x7465732e6c656e67, 0x74682c2074686973, 0x2e6c6974746c6545, 0x6e6469616e293b0a, + 0x2020202020202020, 0x202020206e657720, 0x55696e7438417272, 0x6179286275666665, 0x722c203131292e73, + 0x6574286279746573, 0x293b0a2020202020, 0x2020202020202074, 0x6869732e736f636b, 0x65742e73656e6428, + 0x627566666572293b, 0x0a20202020202020, 0x207d0a0a20202020, 0x2020202070617261, 0x6d6574657253697a, + 0x652876616c756529, 0x207b0a2020202020, 0x2020202020202073, 0x7769746368202874, 0x7970656f66207661, + 0x6c756529207b0a20, 0x2020202020202020, 0x2020206361736520, 0x22626f6f6c65616e, 0x223a0a2020202020, + 0x2020202020202020, 0x2020207265747572, 0x6e20313b0a202020, 0x2020202020202020, 0x206361736520226e, + 0x756d626572223a0a, 0x2020202020202020, 0x2020202020202020, 0x72657475726e2039, 0x3b0a202020202020, + 0x2020202020206361, 0x7365202273747269, 0x6e67223a0a202020, 0x2020202020202020, 0x2020202020726574, + 0x75726e2074686973, 0x2e737472696e6750, 0x6172616d65746572, 0x53697a652876616c, 0x7565293b0a202020, + 0x2020202020202020, 0x206361736520226f, 0x626a656374223a0a, 0x2020202020202020, 0x2020202020202020, + 0x72657475726e2074, 0x6869732e6f626a65, 0x6374506172616d65, 0x74657253697a6528, 0x76616c7565293b0a, + 0x2020202020202020, 0x202020207d0a2020, 0x2020202020202020, 0x20207468726f7720, 0x6e65772054797065, + 0x4572726f72286055, 0x6e737570706f7274, 0x6564205765624672, 0x6f6e742070617261, 0x6d65746572207479, + 0x70652027247b7479, 0x70656f662076616c, 0x75657d2760293b0a, 0x2020202020202020, 0x7d0a0a2020202020, + 0x202020737472696e, 0x67506172616d6574, 0x657253697a652876, 0x616c756529207b0a, 0x2020202020202020, + 0x20202020636f6e73, 0x74206c656e677468, 0x203d206e65772054, 0x657874456e636f64, 0x657228292e656e63, + 0x6f64652876616c75, 0x65292e6c656e6774, 0x683b0a2020202020, 0x2020202020202069, 0x6620286c656e6774, + 0x68203e3d20363535, 0x3336290a20202020, 0x2020202020202020, 0x202020207468726f, 0x77206e6577205261, + 0x6e67654572726f72, 0x282257656246726f, 0x6e7420737472696e, 0x67732063616e6e6f, 0x7420657863656564, + 0x2036353533352055, 0x54462d3820627974, 0x657322293b0a2020, 0x2020202020202020, 0x202072657475726e, + 0x206c656e67746820, 0x2b20286c656e6774, 0x68203c2032353620, 0x3f2032203a203329, 0x3b0a202020202020, + 0x20207d0a0a202020, 0x20202020206f626a, 0x656374506172616d, 0x6574657253697a65, 0x2876616c75652920, + 0x7b0a202020202020, 0x2020202020206966, 0x202841727261792e, 0x6973417272617928, 0x76616c756529290a, + 0x2020202020202020, 0x2020202020202020, 0x72657475726e2074, 0x6869732e7475706c, 0x65506172616d6574, + 0x657253697a652876, 0x616c7565293b0a20, 0x2020202020202020, 0x2020206966202869, 0x7354797065644172, + 0x7261792876616c75, 0x6529290a20202020, 0x2020202020202020, 0x2020202072657475, 0x726e20746869732e, + 0x7479706564417272, 0x6179506172616d65, 0x74657253697a6528, 0x76616c7565293b0a, 0x2020202020202020, 0x202020207468726f, 0x77206e6577205479, 0x70654572726f7228, 0x60556e737570706f, 0x7274656420576562, 0x46726f6e74207061, 0x72616d6574657220, 0x747970652027247b, 0x747970656f662076, 0x616c75657d276029, - 0x3b0a202020202020, 0x20207d0a0a202020, 0x2020202020656e63, 0x6f64655475706c65, 0x2876616c75652c20, - 0x766965772c206f66, 0x6673657429207b0a, 0x2020202020202020, 0x2020202076696577, 0x2e73657455696e74, - 0x38286f6666736574, 0x2c20506172616d54, 0x7970652e7475706c, 0x65293b0a20202020, 0x2020202020202020, - 0x766965772e736574, 0x55696e7438286f66, 0x66736574202b2031, 0x2c2076616c75652e, 0x6c656e677468293b, - 0x0a20202020202020, 0x20202020206c6574, 0x207772697474656e, 0x203d20323b0a2020, 0x2020202020202020, - 0x2020666f72202863, 0x6f6e737420656c65, 0x6d656e74206f6620, 0x76616c7565290a20, 0x2020202020202020, - 0x2020202020202077, 0x72697474656e202b, 0x3d20746869732e65, 0x6e636f6465506172, 0x616d657465722865, - 0x6c656d656e742c20, 0x766965772c206f66, 0x66736574202b2077, 0x72697474656e293b, 0x0a20202020202020, - 0x2020202020726574, 0x75726e2077726974, 0x74656e3b0a202020, 0x20202020207d0a0a, 0x2020202020202020, - 0x656e636f64655479, 0x7065644172726179, 0x2876616c75652c20, 0x766965772c206f66, 0x6673657429207b0a, - 0x2020202020202020, 0x20202020636f6e73, 0x742073706563203d, 0x2061727261795479, 0x7065732e67657428, - 0x76616c75652e636f, 0x6e7374727563746f, 0x72293b0a20202020, 0x2020202020202020, 0x6966202821737065, - 0x63290a2020202020, 0x2020202020202020, 0x2020207468726f77, 0x206e657720547970, 0x654572726f722860, - 0x556e737570706f72, 0x7465642074797065, 0x6420617272617920, 0x247b76616c75652e, 0x636f6e7374727563, - 0x746f722e6e616d65, 0x7d60293b0a202020, 0x2020202020202020, 0x20636f6e73742068, 0x656164657253697a, - 0x65203d2074797065, 0x6441727261794865, 0x6164657253697a65, 0x2876616c7565293b, 0x0a20202020202020, - 0x2020202020766965, 0x772e73657455696e, 0x7438286f66667365, 0x742c206865616465, 0x7253697a65203d3d, - 0x3d2032203f205061, 0x72616d547970652e, 0x736d616c6c417272, 0x61795538203a2073, 0x7065632e636f6465, - 0x293b0a2020202020, 0x2020202020202069, 0x6620286865616465, 0x7253697a65203d3d, 0x3d2032290a202020, - 0x2020202020202020, 0x2020202020766965, 0x772e73657455696e, 0x7438286f66667365, 0x74202b20312c2076, - 0x616c75652e6c656e, 0x677468293b0a2020, 0x2020202020202020, 0x2020656c73650a20, 0x2020202020202020, - 0x2020202020202076, 0x6965772e73657455, 0x696e743332286f66, 0x66736574202b2031, 0x2c2076616c75652e, - 0x6c656e6774682c20, 0x746869732e6c6974, 0x746c65456e646961, 0x6e293b0a20202020, 0x2020202020202020, - 0x666f7220286c6574, 0x20696e646578203d, 0x20303b20696e6465, 0x78203c2076616c75, 0x652e6c656e677468, - 0x3b202b2b696e6465, 0x78290a2020202020, 0x2020202020202020, 0x202020766965775b, 0x737065632e736574, - 0x7465725d286f6666, 0x736574202b206865, 0x6164657253697a65, 0x202b20696e646578, 0x202a20737065632e, - 0x62797465732c2076, 0x616c75655b696e64, 0x65785d2c20746869, 0x732e6c6974746c65, 0x456e6469616e293b, - 0x0a20202020202020, 0x2020202020726574, 0x75726e2068656164, 0x657253697a65202b, 0x2076616c75652e62, - 0x7974654c656e6774, 0x683b0a2020202020, 0x2020207d0a202020, 0x207d0a0a20202020, 0x2f2f204578706f73, - 0x656420286265796f, 0x6e64207468652064, 0x656661756c742060, 0x77656246726f6e74, 0x602073696e676c65, - 0x746f6e2920736f20, 0x7465737473206361, 0x6e20636f6e737472, 0x7563742061646469, 0x74696f6e616c2062, - 0x7269646765730a20, 0x2020202f2f20706f, 0x696e746564206174, 0x2061206469666665, 0x72656e742055524c, - 0x2c20652e672e2074, 0x6f20657865726369, 0x7365207468652069, 0x6e697469616c2d63, 0x6f6e6e656374696f, - 0x6e2d6661696c7572, 0x6520706174682e0a, 0x20202020676c6f62, 0x616c2e5765624672, 0x6f6e744272696467, - 0x65203d2057656246, 0x726f6e7442726964, 0x67653b0a20202020, 0x676c6f62616c2e77, 0x656246726f6e7420, - 0x3d206e6577205765, 0x6246726f6e744272, 0x6964676528293b0a, 0x7d2928676c6f6261, 0x6c54686973293b0a + 0x3b0a202020202020, 0x20207d0a0a202020, 0x2020202020747570, 0x6c65506172616d65, 0x74657253697a6528, + 0x76616c756529207b, 0x0a20202020202020, 0x2020202020696620, 0x2876616c75652e6c, 0x656e677468203e20, + 0x323535290a202020, 0x2020202020202020, 0x2020202020746872, 0x6f77206e65772052, 0x616e67654572726f, + 0x7228225765624672, 0x6f6e74207475706c, 0x65732063616e6e6f, 0x7420657863656564, 0x2032353520656c65, + 0x6d656e747322293b, 0x0a20202020202020, 0x2020202020726574, 0x75726e2032202b20, 0x76616c75652e7265, + 0x6475636528287369, 0x7a652c20656c656d, 0x656e7429203d3e20, 0x73697a65202b2074, 0x6869732e70617261, + 0x6d6574657253697a, 0x6528656c656d656e, 0x74292c2030293b0a, 0x2020202020202020, 0x7d0a0a2020202020, + 0x2020207479706564, 0x4172726179506172, 0x616d657465725369, 0x7a652876616c7565, 0x29207b0a20202020, + 0x2020202020202020, 0x6966202821617272, 0x617954797065732e, 0x6861732876616c75, 0x652e636f6e737472, + 0x7563746f7229290a, 0x2020202020202020, 0x2020202020202020, 0x7468726f77206e65, 0x7720547970654572, + 0x726f722860556e73, 0x7570706f72746564, 0x2074797065642061, 0x7272617920247b76, 0x616c75652e636f6e, + 0x7374727563746f72, 0x2e6e616d657d6029, 0x3b0a202020202020, 0x2020202020206966, 0x202876616c75652e, + 0x6c656e677468203e, 0x2030786666666666, 0x666666290a202020, 0x2020202020202020, 0x2020202020746872, + 0x6f77206e65772052, 0x616e67654572726f, 0x7228225479706564, 0x2061727261797320, 0x63616e6e6f742065, + 0x7863656564203432, 0x3934393637323935, 0x20656c656d656e74, 0x7322293b0a202020, 0x2020202020202020, + 0x2072657475726e20, 0x7479706564417272, 0x6179486561646572, 0x53697a652876616c, 0x756529202b207661, + 0x6c75652e62797465, 0x4c656e6774683b0a, 0x2020202020202020, 0x7d0a0a2020202020, 0x202020656e636f64, + 0x65506172616d6574, 0x65722876616c7565, 0x2c20766965772c20, 0x6f66667365742920, 0x7b0a202020202020, + 0x2020202020207377, 0x6974636820287479, 0x70656f662076616c, 0x756529207b0a2020, 0x2020202020202020, + 0x2020636173652022, 0x626f6f6c65616e22, 0x3a0a202020202020, 0x2020202020202020, 0x2020766965772e73, + 0x657455696e743828, 0x6f66667365742c20, 0x76616c7565203f20, 0x506172616d547970, 0x652e626f6f6c6561, + 0x6e54727565203a20, 0x506172616d547970, 0x652e626f6f6c6561, 0x6e46616c7365293b, 0x0a20202020202020, + 0x2020202020202020, 0x2072657475726e20, 0x313b0a2020202020, 0x2020202020202063, 0x61736520226e756d, + 0x626572223a0a2020, 0x2020202020202020, 0x2020202020207669, 0x65772e7365745569, 0x6e7438286f666673, + 0x65742c2050617261, 0x6d547970652e6e75, 0x6d626572293b0a20, 0x2020202020202020, 0x2020202020202076, + 0x6965772e73657446, 0x6c6f61743634286f, 0x6666736574202b20, 0x312c2076616c7565, 0x2c20746869732e6c, + 0x6974746c65456e64, 0x69616e293b0a2020, 0x2020202020202020, 0x2020202020207265, 0x7475726e20393b0a, + 0x2020202020202020, 0x2020202063617365, 0x2022737472696e67, 0x223a0a2020202020, 0x2020202020202020, + 0x2020207265747572, 0x6e20746869732e65, 0x6e636f6465537472, 0x696e672876616c75, 0x652c20766965772c, + 0x206f666673657429, 0x3b0a202020202020, 0x2020202020206361, 0x736520226f626a65, 0x6374223a0a202020, + 0x2020202020202020, 0x2020202020726574, 0x75726e2074686973, 0x2e656e636f64654f, 0x626a656374287661, + 0x6c75652c20766965, 0x772c206f66667365, 0x74293b0a20202020, 0x2020202020202020, 0x7d0a202020202020, + 0x2020202020207468, 0x726f77206e657720, 0x547970654572726f, 0x722860556e737570, 0x706f727465642057, + 0x656246726f6e7420, 0x706172616d657465, 0x7220747970652027, 0x247b747970656f66, 0x2076616c75657d27, + 0x60293b0a20202020, 0x202020207d0a0a20, 0x2020202020202065, 0x6e636f6465537472, 0x696e672876616c75, + 0x652c20766965772c, 0x206f666673657429, 0x207b0a2020202020, 0x2020202020202063, 0x6f6e737420627974, + 0x6573203d206e6577, 0x2054657874456e63, 0x6f64657228292e65, 0x6e636f6465287661, 0x6c7565293b0a2020, + 0x2020202020202020, 0x2020636f6e737420, 0x736d616c6c203d20, 0x62797465732e6c65, 0x6e677468203c2032, + 0x35363b0a20202020, 0x2020202020202020, 0x766965772e736574, 0x55696e7438286f66, 0x667365742c20736d, + 0x616c6c203f205061, 0x72616d547970652e, 0x736d616c6c537472, 0x696e67203a205061, 0x72616d547970652e, + 0x737472696e67293b, 0x0a20202020202020, 0x2020202020696620, 0x28736d616c6c290a, 0x2020202020202020, + 0x2020202020202020, 0x766965772e736574, 0x55696e7438286f66, 0x66736574202b2031, 0x2c2062797465732e, + 0x6c656e677468293b, 0x0a20202020202020, 0x2020202020656c73, 0x650a202020202020, 0x2020202020202020, + 0x2020766965772e73, 0x657455696e743136, 0x286f666673657420, 0x2b20312c20627974, 0x65732e6c656e6774, + 0x682c20746869732e, 0x6c6974746c65456e, 0x6469616e293b0a20, 0x2020202020202020, 0x202020636f6e7374, + 0x2068656164657253, 0x697a65203d20736d, 0x616c6c203f203220, 0x3a20333b0a202020, 0x2020202020202020, + 0x206e65772055696e, 0x7438417272617928, 0x766965772e627566, 0x6665722c20766965, 0x772e627974654f66, + 0x66736574202b206f, 0x6666736574202b20, 0x6865616465725369, 0x7a652c2062797465, 0x732e6c656e677468, + 0x292e736574286279, 0x746573293b0a2020, 0x2020202020202020, 0x202072657475726e, 0x2068656164657253, + 0x697a65202b206279, 0x7465732e6c656e67, 0x74683b0a20202020, 0x202020207d0a0a20, 0x2020202020202065, + 0x6e636f64654f626a, 0x6563742876616c75, 0x652c20766965772c, 0x206f666673657429, 0x207b0a2020202020, + 0x2020202020202069, 0x6620284172726179, 0x2e69734172726179, 0x2876616c75652929, 0x0a20202020202020, + 0x2020202020202020, 0x2072657475726e20, 0x746869732e656e63, 0x6f64655475706c65, 0x2876616c75652c20, + 0x766965772c206f66, 0x66736574293b0a20, 0x2020202020202020, 0x2020206966202869, 0x7354797065644172, + 0x7261792876616c75, 0x6529290a20202020, 0x2020202020202020, 0x2020202072657475, 0x726e20746869732e, + 0x656e636f64655479, 0x7065644172726179, 0x2876616c75652c20, 0x766965772c206f66, 0x66736574293b0a20, + 0x2020202020202020, 0x2020207468726f77, 0x206e657720547970, 0x654572726f722860, 0x556e737570706f72, + 0x7465642057656246, 0x726f6e7420706172, 0x616d657465722074, 0x7970652027247b74, 0x7970656f66207661, + 0x6c75657d2760293b, 0x0a20202020202020, 0x207d0a0a20202020, 0x20202020656e636f, 0x64655475706c6528, + 0x76616c75652c2076, 0x6965772c206f6666, 0x73657429207b0a20, 0x2020202020202020, 0x202020766965772e, + 0x73657455696e7438, 0x286f66667365742c, 0x20506172616d5479, 0x70652e7475706c65, 0x293b0a2020202020, + 0x2020202020202076, 0x6965772e73657455, 0x696e7438286f6666, 0x736574202b20312c, 0x2076616c75652e6c, + 0x656e677468293b0a, 0x2020202020202020, 0x202020206c657420, 0x7772697474656e20, 0x3d20323b0a202020, + 0x2020202020202020, 0x20666f722028636f, 0x6e737420656c656d, 0x656e74206f662076, 0x616c7565290a2020, + 0x2020202020202020, 0x2020202020207772, 0x697474656e202b3d, 0x20746869732e656e, 0x636f646550617261, + 0x6d6574657228656c, 0x656d656e742c2076, 0x6965772c206f6666, 0x736574202b207772, 0x697474656e293b0a, + 0x2020202020202020, 0x2020202072657475, 0x726e207772697474, 0x656e3b0a20202020, 0x202020207d0a0a20, + 0x2020202020202065, 0x6e636f6465547970, 0x6564417272617928, 0x76616c75652c2076, 0x6965772c206f6666, + 0x73657429207b0a20, 0x2020202020202020, 0x202020636f6e7374, 0x2073706563203d20, 0x6172726179547970, + 0x65732e6765742876, 0x616c75652e636f6e, 0x7374727563746f72, 0x293b0a2020202020, 0x2020202020202069, + 0x6620282173706563, 0x290a202020202020, 0x2020202020202020, 0x20207468726f7720, 0x6e65772054797065, + 0x4572726f72286055, 0x6e737570706f7274, 0x6564207479706564, 0x2061727261792024, 0x7b76616c75652e63, + 0x6f6e737472756374, 0x6f722e6e616d657d, 0x60293b0a20202020, 0x2020202020202020, 0x636f6e7374206865, + 0x6164657253697a65, 0x203d207479706564, 0x4172726179486561, 0x64657253697a6528, 0x76616c7565293b0a, + 0x2020202020202020, 0x2020202076696577, 0x2e73657455696e74, 0x38286f6666736574, 0x2c20686561646572, + 0x53697a65203d3d3d, 0x2032203f20506172, 0x616d547970652e73, 0x6d616c6c41727261, 0x795538203a207370, + 0x65632e636f646529, 0x3b0a202020202020, 0x2020202020206966, 0x2028686561646572, 0x53697a65203d3d3d, + 0x2032290a20202020, 0x2020202020202020, 0x2020202076696577, 0x2e73657455696e74, 0x38286f6666736574, + 0x202b20312c207661, 0x6c75652e6c656e67, 0x7468293b0a202020, 0x2020202020202020, 0x20656c73650a2020, + 0x2020202020202020, 0x2020202020207669, 0x65772e7365745569, 0x6e743332286f6666, 0x736574202b20312c, + 0x2076616c75652e6c, 0x656e6774682c2074, 0x6869732e6c697474, 0x6c65456e6469616e, 0x293b0a2020202020, + 0x2020202020202066, 0x6f7220286c657420, 0x696e646578203d20, 0x303b20696e646578, 0x203c2076616c7565, + 0x2e6c656e6774683b, 0x202b2b696e646578, 0x290a202020202020, 0x2020202020202020, 0x2020766965775b73, + 0x7065632e73657474, 0x65725d286f666673, 0x6574202b20686561, 0x64657253697a6520, 0x2b20696e64657820, + 0x2a20737065632e62, 0x797465732c207661, 0x6c75655b696e6465, 0x785d2c2074686973, 0x2e6c6974746c6545, + 0x6e6469616e293b0a, 0x2020202020202020, 0x2020202072657475, 0x726e206865616465, 0x7253697a65202b20, + 0x76616c75652e6279, 0x74654c656e677468, 0x3b0a202020202020, 0x20207d0a20202020, 0x7d0a0a202020202f, + 0x2f204578706f7365, 0x6420286265796f6e, 0x6420746865206465, 0x6661756c74206077, 0x656246726f6e7460, + 0x2073696e676c6574, 0x6f6e2920736f2074, 0x657374732063616e, 0x20636f6e73747275, 0x6374206164646974, + 0x696f6e616c206272, 0x69646765730a2020, 0x20202f2f20706f69, 0x6e74656420617420, 0x6120646966666572, + 0x656e742055524c2c, 0x20652e672e20746f, 0x2065786572636973, 0x652074686520696e, 0x697469616c2d636f, + 0x6e6e656374696f6e, 0x2d6661696c757265, 0x20706174682e0a20, 0x202020676c6f6261, 0x6c2e57656246726f, + 0x6e74427269646765, 0x203d205765624672, 0x6f6e744272696467, 0x653b0a2020202067, 0x6c6f62616c2e7765, + 0x6246726f6e74203d, 0x206e657720576562, 0x46726f6e74427269, 0x64676528293b0a7d, 0x2928676c6f62616c, + 0x54686973293b0a00 }; }; diff --git a/js/core/WebFront.js b/js/core/WebFront.js index 8a8526eb..8a153b58 100644 --- a/js/core/WebFront.js +++ b/js/core/WebFront.js @@ -187,7 +187,7 @@ case TextCommand.injectScript: { const script = document.createElement("script"); script.text = text; - document.body.appendChild(script); + (document.body ?? document.head ?? document.documentElement).appendChild(script); break; } default: diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index 2a421257..2dbc5f18 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -14,9 +14,9 @@ "js/developer/environment/bootstrap.mjs": "5fa50cc9264809a6a9eb03564a60fbe3171a3ffcc781d26352ae59e2866a7090", "js/developer/environment/bootstrap-entry.mjs": "ff8084f23f5acc721f97eb1ed0a454e7bfee1894de17d54f0100fa11f7ef8b77", "js/developer/environment/packages.mjs": "37fe2a410e211264cfeaedbff3df50f7e62b02f8088130127d94f92081e2a5ad", - "js/developer/environment/starter.mjs": "f38e290e03aebe146623c2ca9b590d645fb91a51acdf7a98101bb00b5b88096c", + "js/developer/environment/starter.mjs": "89ccab43be4455ed9598c54355b4bbe5adea1afd7a0ae5d755a14317e3ca39df", "js/developer/environment/paths.mjs": "3b6114df78eb193161c5c84499dda084cb7ff91c56a4496371c30295d00880e3", - "js/developer/environment/runtime.mjs": "98ed06660333d2a90f9857b5b21da811f9d4ecda78d011dc88501679af7388da", + "js/developer/environment/runtime.mjs": "a2bf73a8e3f9775b42edc36ba3615eec9d474dd7ac7b40417c9b6a91b7b581f0", "js/developer/environment/development.mjs": "dd07bc64e12c3392223f0e7aab0ae2f5223e093930bee8abe78a0cd3e2940d85", "js/developer/environment/testing.mjs": "326e003f114bdbad68fedbceaded30717b3fc15315e6d87fa747972b681e2dce", "js/developer/environment/terminal.mjs": "7ffcf7ac6ef63c35cdf5ef70284b384525b13ba18422af069289e53b6c4f6be1", @@ -35,15 +35,13 @@ "js/developer/environment/peers.mjs": "e1d999892138682fc0134ef1f4d4b19b9a9ad8d7fb16e37fc9c6c684bd853896", "js/developer/environment/resolve.mjs": "8b96b850af215be51f5cb85cc9c69e057afa04dfb8a57e572620c07059c17fa3", "js/developer/environment/embed.mjs": "7e9c0ae9bde50b1f434c1635b90f1c3c0840cf00f8a12620727bae59096c187c", - "js/developer/tools/starters/pi/main.tsx": "d3161b35db204ba54f782f711183e8d96aeff7c92d885c33a6ec168cf461e453", - "js/developer/tools/starters/pi/style.css": "360e2c7ae6d3699b00e18cbf67efbae7a8d8863d88926b31139e102cf38e5abd", "examples/life/ui/main.tsx": "ed11a82aad1639eb6997af8b0fca4d5c5ed4c36422c22a74ac49ae73078d0a91", "examples/life/ui/style.css": "9bb55eb0f0a3287e5b7dc78af9d69608b87ff42c4d9c8a653bc83a52fe293c44", - "js/developer/tools/distribution.json": "f53e062b5e54f10c3120a89ea03916ed861b000af2df2b6e51657c4dfa9b1884", + "js/developer/tools/distribution.json": "a40253717a5a0f2107ad9b96ada3d0487ee35b27a382e19b3b8a2d20388573af", "js/developer/tools/archive.mjs": "bfe9feeb5e4d4e1b7c44c4dec4dcbeab4ae59c2bf16a1d2b32cd6910a2b84e7b", "js/developer/tools/distribution.mjs": "1108b61bc659dd945ba1417aa84337bca03039842d342c95815b5463d87a136e", - "js/developer/scripts/build.mjs": "a25e19e357480e1ddde1a425966150f6f3c6e474843ead90f5d67e0a4c704f54", - "webfront.project.json": "081bcfebac2239e44614e5df227038189ed4ebc6484d31f4ab51af0dd7e4740e", + "js/developer/scripts/build.mjs": "2ad812b102fccd76d777b85317fcc326798001bb787389665897bcac986792fd", + "webfront.project.json": "f29a7116b369ba52bc8b8922dfac603842d16605be6566aeae9a1b79689b1833", "js/core/bootstrap/bootstrap.bundle.mjs": "536831257f0fc92e31911841750e1e59247f7c64e756b0fcb878efd9860a741f", "js/developer/environment/packages.bundle.mjs": "e36d1052285a313f7db67c1f58f8332da9e97446b1e2085422ebdae379288045", "include/webfront/system/DeveloperReleaseData.hpp": "7aa74c8e31501fa8733b47767fd11cc4e316ba70634331d86d35d78bd5a4b91c" diff --git a/js/developer/environment/runtime.mjs b/js/developer/environment/runtime.mjs index 91587c6f..24d28cbc 100644 --- a/js/developer/environment/runtime.mjs +++ b/js/developer/environment/runtime.mjs @@ -206,15 +206,20 @@ async function test(args, {bridge, signal, write = () => {}, createFrame, onRepo const {timeout, pattern} = parseTestOptions(args); const deadline = runDeadline(timeout, inherited); const limit = new AbortController(); - const timer = setTimeout(() => limit.abort(), secondsLeft(deadline) * 1000); - const preparing = signal ? AbortSignal.any([signal, limit.signal]) : limit.signal; + // Forward Ctrl+C into the deadline controller: older supported WebKit lacks AbortSignal.any. + const interrupt = () => limit.abort(signal.reason); + const preparing = limit.signal; const step = promise => abortable(promise, preparing); const runId = crypto.randomUUID(); const directory = `${testDirectory}/${runId}`; let jasmineVersion = ''; let reported = false; const finished = report => { reported = true; report.jasmine = jasmineVersion; onReport?.(report); return report; }; + let timer; try { + timer = setTimeout(() => limit.abort(), secondsLeft(deadline) * 1000); + signal?.addEventListener('abort', interrupt, {once: true}); + if (signal?.aborted) interrupt(); const project = await step(loadManifest(bridge)); const specs = specFiles(project.manifest); const lock = project.lock ?? {format: 1, roots: {}, packages: {}}; @@ -223,6 +228,8 @@ async function test(args, {bridge, signal, write = () => {}, createFrame, onRepo const files = await step(buildInWorker(bridge, {type: 'tests', specs, lock}, preparing)); const jasmineBytes = await step(readProject(bridge, `${packageRoot}/${jasmine.node.key}/${jasmine.path}`)); await step(publish(bridge, directory, runnerFiles(files, jasmineBytes), {signal: preparing})); + clearTimeout(timer); + signal?.removeEventListener('abort', interrupt); write(syncNotice(project)); const report = finished(await runInFrame({pattern, timeout: Math.max(0.001, secondsLeft(deadline)), runId, signal, write, createFrame})); write('\n'); @@ -237,8 +244,13 @@ async function test(args, {bridge, signal, write = () => {}, createFrame, onRepo throw error; } finally { clearTimeout(timer); + signal?.removeEventListener('abort', interrupt); // The files of the run are not needed any more: an empty directory replaces them, for at most two seconds. - await Promise.race([publish(bridge, directory, new Map()).catch(() => {}), new Promise(resolve => setTimeout(resolve, 2000))]); + let cleanupTimer; + try { + await Promise.race([publish(bridge, directory, new Map()).catch(() => {}), + new Promise(resolve => { cleanupTimer = setTimeout(resolve, 2000); })]); + } finally { clearTimeout(cleanupTimer); } } } diff --git a/js/developer/environment/starter.mjs b/js/developer/environment/starter.mjs index 7db51385..4d20489b 100644 --- a/js/developer/environment/starter.mjs +++ b/js/developer/environment/starter.mjs @@ -38,6 +38,6 @@ export async function createStarter(bridge, config, [name, destination = 'ui'], // A starter must never overwrite an existing directory, including a symlink or partial project. await publish(bridge, destination, files, {signal, replace: false}); const install = Object.entries(recipe.dependencies).map(([pkg, version]) => `${pkg}@${version}`).join(' '); - const output = recipe.output ?? `generated/${recipe.provider ?? 'PiUI'}.hpp`; + const output = recipe.output ?? `generated/${recipe.provider ?? 'AppUI'}.hpp`; return `Created ${destination}.\nwf init\nwf install ${install}\nwf preview ${destination}/${recipe.entry}\nwf embed ${destination}/${recipe.entry} --output ${output}`; } diff --git a/js/developer/scripts/build.mjs b/js/developer/scripts/build.mjs index 743d9123..18d50173 100644 --- a/js/developer/scripts/build.mjs +++ b/js/developer/scripts/build.mjs @@ -74,10 +74,10 @@ export default async function (context) { // The starter is pinned by the environment's own trusted archive, not by unverified remote metadata. const starters = {}; - for (const [name, provider] of [['pi', 'PiUI'], ['life', 'LifeUI']]) { + for (const [name, provider] of [['life', 'LifeUI']]) { const starterFiles = new Map(); for (const file of ['main.tsx', 'style.css']) - starterFiles.set(`package/${file}`, await project.read(`${name === 'life' ? 'examples/life/ui' : 'js/developer/tools/starters/pi'}/${file}`)); + starterFiles.set(`package/${file}`, await project.read(`examples/life/ui/${file}`)); const recipe = {format: 1, name: `${name}-starter`, version, dependencies: { react: dependencies.react, 'react-dom': dependencies['react-dom']}, entries: {main: 'main.tsx'}, providers: {[provider]: {entry: 'main', output: `generated/${provider}.hpp`}}}; diff --git a/js/developer/tools/bundle-inputs.json b/js/developer/tools/bundle-inputs.json index cb263ca0..c826eef0 100644 --- a/js/developer/tools/bundle-inputs.json +++ b/js/developer/tools/bundle-inputs.json @@ -35,8 +35,6 @@ "js/developer/environment/peers.mjs", "js/developer/environment/resolve.mjs", "js/developer/environment/embed.mjs", - "js/developer/tools/starters/pi/main.tsx", - "js/developer/tools/starters/pi/style.css", "examples/life/ui/main.tsx", "examples/life/ui/style.css", "js/developer/tools/distribution.json", diff --git a/js/developer/tools/distribution.json b/js/developer/tools/distribution.json index 734e8e91..0f5fa7ba 100644 --- a/js/developer/tools/distribution.json +++ b/js/developer/tools/distribution.json @@ -1,4 +1,4 @@ { - "version": "0.6.1", + "version": "0.6.2", "baseUrl": "https://ambroise-leclerc.github.io/WebFront/" } diff --git a/js/developer/tools/starters/pi/main.tsx b/js/developer/tools/starters/pi/main.tsx deleted file mode 100644 index 310df1f9..00000000 --- a/js/developer/tools/starters/pi/main.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React, {useState} from 'react'; -import {createRoot} from 'react-dom/client'; -import './style.css'; - -declare const webFront: { - ready: Promise; - cppFunction(name: string): (digits: number) => Promise; -}; - -function Pi() { - const [digits, setDigits] = useState(50); - const [value, setValue] = useState(''); - const [error, setError] = useState(''); - async function calculate() { - try { - await webFront.ready; - setValue(await webFront.cppFunction('pi')(digits)); - setError(''); - } catch (error) { setError(String(error)); } - } - return

PI, calculated in C++

- - - {value}

{error}

-
; -} - -createRoot(document.getElementById('root')!).render(); diff --git a/js/developer/tools/starters/pi/style.css b/js/developer/tools/starters/pi/style.css deleted file mode 100644 index 24a4da9e..00000000 --- a/js/developer/tools/starters/pi/style.css +++ /dev/null @@ -1,5 +0,0 @@ -body { font: 18px system-ui; margin: 3rem; color: #193445; background: #f7fafc; } -main { max-width: 52rem; margin: auto; } -input, button { font: inherit; margin: .5rem; padding: .4rem; } -output { display: block; overflow-wrap: anywhere; margin-top: 2rem; font-family: monospace; } -[role=alert] { color: #a02828; } diff --git a/test/cmake/AssembleDeveloperFixtures.cmake b/test/cmake/AssembleDeveloperFixtures.cmake index 275bd5dc..9ced710a 100644 --- a/test/cmake/AssembleDeveloperFixtures.cmake +++ b/test/cmake/AssembleDeveloperFixtures.cmake @@ -13,5 +13,4 @@ file(COPY "${PROJECT}/build-registry/" DESTINATION "${OUTPUT}/registry") file(COPY_FILE "${SOURCE}/test/web/developer-specs.mjs" "${OUTPUT}/run.mjs") file(COPY_FILE "${SOURCE}/test/web/developer-session.html" "${OUTPUT}/session.html") file(COPY_FILE "${SOURCE}/test/web/developer-session.mjs" "${OUTPUT}/session.mjs") -file(COPY_FILE "${SOURCE}/js/developer/tools/starters/pi/main.tsx" "${OUTPUT}/main.tsx") -file(COPY_FILE "${SOURCE}/js/developer/tools/starters/pi/style.css" "${OUTPUT}/style.css") +file(COPY_FILE "${SOURCE}/test/developer/timers.mjs" "${OUTPUT}/timers.mjs") diff --git a/test/cmake/CheckCEFCopy.cmake b/test/cmake/CheckCEFCopy.cmake index 34614c67..07901032 100644 --- a/test/cmake/CheckCEFCopy.cmake +++ b/test/cmake/CheckCEFCopy.cmake @@ -54,10 +54,13 @@ list(LENGTH copies count) if(NOT count EQUAL 2) message(FATAL_ERROR "Each of the two destinations must be copied once, got ${count}: ${first}") endif() +set(copied_libraries "") foreach(destination "${work}/plan" "${work}/plan/bin") if(NOT EXISTS "${destination}/libcef.so" AND EXISTS "${destination}/Release/libcef.so") set(destination "${destination}/Release") endif() + file(RELATIVE_PATH library "${work}" "${destination}/libcef.so") + list(APPEND copied_libraries "${library}") expect_file("${destination}/libcef.so" "library 1") expect_file("${destination}/locales/en-US.pak" "locale") endforeach() @@ -65,6 +68,11 @@ build(second) if(second MATCHES "Copying CEF") message(FATAL_ERROR "A build with nothing to copy must copy nothing: ${second}") endif() +# The fixture must not depend on crossing a filesystem/make timestamp tick. Age the existing +# outputs deterministically, then change the source: no sleep and no missing-output shortcut. +file(ARCHIVE_CREATE OUTPUT "${work}/old-libraries.tar" PATHS ${copied_libraries} + WORKING_DIRECTORY "${work}" FORMAT gnutar MTIME "2000-01-01 00:00:00 UTC") +file(ARCHIVE_EXTRACT INPUT "${work}/old-libraries.tar" DESTINATION "${work}") file(WRITE "${source}/libcef.so" "library 2") build(third) if(NOT third MATCHES "Copying CEF libcef.so" OR third MATCHES "Copying CEF locales") diff --git a/test/cmake/RunWfDriver.cmake b/test/cmake/RunWfDriver.cmake index d4d2bbd8..5f4e6d3d 100644 --- a/test/cmake/RunWfDriver.cmake +++ b/test/cmake/RunWfDriver.cmake @@ -2,6 +2,8 @@ # Usage: cmake -DDRIVER= -DPROJECT= -DEXPECT_STATUS= [-DENVIRONMENT= -DINTEGRITY=] # [-DREGISTRY=] [-DTIMEOUT=] [-DEXPECT_OUTPUT=] [-DEXPECT_REPORT=] [-DFORGE=: # -DWORK=] [-DRENAME_ENTRY=] [-DFRESH_PROJECT=: an empty project instead of PROJECT] -DCOMMAND=|... -P RunWfDriver.cmake +# SLEEP_ENVIRONMENT uses a tiny compatible archive whose command records its start before sleeping; EXPECT_FILE +# requires that record after the watchdog exits. Real packaged-script execution is covered by the other driver cases. # PROVISION is the provision.json of ENVIRONMENT, from which an INTEGRITY left empty is read when the test runs. # PROFILE is a directory for the browser's own persistent state (WebKitGTK profile), emptied first: a browser reuses the # modules it loaded by URL, and the first page that loads another environment through the same profile fails with @@ -35,6 +37,21 @@ if(PROVISION AND ENVIRONMENT AND NOT INTEGRITY AND NOT FORGE) string(JSON INTEGRITY GET "${provision}" integrity) endif() +if(SLEEP_ENVIRONMENT) + # The watchdog must interrupt an active command, independently of WASM compiler startup cost. + include("${ROOT}/cmake/WebFrontBootstrap.cmake") + file(REMOVE_RECURSE "${WORK}/sleep-environment") + file(MAKE_DIRECTORY "${WORK}/sleep-environment/package") + file(COPY "${ROOT}/test/fixtures/wf-sleep-environment/" DESTINATION "${WORK}/sleep-environment/package") + set(ENVIRONMENT "${WORK}/sleep-environment.tgz") + execute_process(COMMAND "${CMAKE_COMMAND}" -E tar czf "${ENVIRONMENT}" --format=gnutar package + WORKING_DIRECTORY "${WORK}/sleep-environment" RESULT_VARIABLE packed) + if(NOT packed EQUAL 0) + message(FATAL_ERROR "Cannot pack the watchdog environment") + endif() + webfront_file_sri("${ENVIRONMENT}" INTEGRITY) +endif() + if(FRESH_PROJECT) set(PROJECT "${FRESH_PROJECT}") file(REMOVE_RECURSE "${PROJECT}") @@ -78,6 +95,9 @@ if(EXPECT_REPORT) file(REMOVE "${report}") list(APPEND arguments --report "${report}") endif() +if(EXPECT_FILE) + file(REMOVE "${PROJECT}/${EXPECT_FILE}") +endif() string(REPLACE "|" ";" command "${COMMAND}") execute_process(COMMAND "${DRIVER}" ${arguments} -- ${command} RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE errors) @@ -98,3 +118,13 @@ if(EXPECT_REPORT) message(FATAL_ERROR "The report does not match '${EXPECT_REPORT}': ${content}") endif() endif() + +if(EXPECT_FILE) + if(NOT EXISTS "${PROJECT}/${EXPECT_FILE}") + message(FATAL_ERROR "The command did not start: ${EXPECT_FILE} is missing") + endif() + file(READ "${PROJECT}/${EXPECT_FILE}" started) + if(NOT started STREQUAL "running") + message(FATAL_ERROR "The command did not record its running state") + endif() +endif() diff --git a/test/developer/specs/distribution-specs.mjs b/test/developer/specs/distribution-specs.mjs index f63c4e68..d9805c9e 100644 --- a/test/developer/specs/distribution-specs.mjs +++ b/test/developer/specs/distribution-specs.mjs @@ -10,12 +10,12 @@ describe('The developer distribution', () => { const encode = value => new TextEncoder().encode(typeof value === 'string' ? value : JSON.stringify(value)); const decode = bytes => new TextDecoder().decode(bytes); - const recipe = (fields = {}) => ({format: 1, name: 'pi-starter', version: '0.1.0', dependencies: {react: '19.3.1'}, + const recipe = (fields = {}) => ({format: 1, name: 'life-starter', version: '0.1.0', dependencies: {react: '19.3.1'}, entries: {main: 'main.tsx'}, ...fields}); function starter(overrides = {}) { return compress(tar(new Map(Object.entries({ - 'package/main.tsx': encode('export default function Pi() {}'), + 'package/main.tsx': encode('export default function Life() {}'), 'package/webfront.project.json': encode(recipe()), ...overrides, })))); @@ -25,18 +25,18 @@ describe('The developer distribution', () => { const bytes = starter(); const calls = []; const bridge = {cppFunction: name => async (...args) => { calls.push([name, ...args]); return 'transaction'; }}; - const config = {starters: {pi: {url: 'https://pages.test/developer/0.1.0/pi-starter.tgz', integrity: await integrity(bytes)}}}; + const config = {starters: {life: {url: 'https://pages.test/developer/0.1.0/life-starter.tgz', integrity: await integrity(bytes)}}}; const fetchImpl = async () => new Response(bytes); - const help = await createStarter(bridge, config, ['pi', 'ui'], {fetchImpl}); + const help = await createStarter(bridge, config, ['life', 'ui'], {fetchImpl}); expect(help).toMatch(/wf init\nwf install react@19.3.1/); expect(help).toMatch(/wf preview ui\/main.tsx/); expect(calls[0][0]).toBe('webfront.developer.beginNew'); expect(calls.at(-1)[0]).toBe('webfront.developer.commit'); calls.length = 0; - await rejects(createStarter(bridge, {starters: {pi: {...config.starters.pi, integrity: await integrity(encode('bad'))}}}, ['pi', 'ui'], {fetchImpl}), /Integrity check/); + await rejects(createStarter(bridge, {starters: {life: {...config.starters.life, integrity: await integrity(encode('bad'))}}}, ['life', 'ui'], {fetchImpl}), /Integrity check/); expect(calls.length).toBe(0); for (const bytes of [starter({'package/../escape': encode('bad')}), starter({'package/webfront.project.json': encode(recipe({dependencies: {react: 'latest'}}))})]) { - await rejects(createStarter(bridge, {starters: {pi: {...config.starters.pi, integrity: await integrity(bytes)}}}, ['pi', 'ui'], {fetchImpl: async () => new Response(bytes)})); + await rejects(createStarter(bridge, {starters: {life: {...config.starters.life, integrity: await integrity(bytes)}}}, ['life', 'ui'], {fetchImpl: async () => new Response(bytes)})); expect(calls.length).toBe(0); } }); @@ -49,7 +49,7 @@ describe('The developer distribution', () => { if (name.endsWith('.commit')) throw new Error('Starter destination already exists'); return 'transaction'; }}; - await rejects(createStarter(bridge, {starters: {pi: {url: '/starter.tgz', integrity: await integrity(bytes)}}}, ['pi', 'ui'], {fetchImpl: async () => new Response(bytes)}), /already exists/); + await rejects(createStarter(bridge, {starters: {life: {url: '/starter.tgz', integrity: await integrity(bytes)}}}, ['life', 'ui'], {fetchImpl: async () => new Response(bytes)}), /already exists/); expect(calls.at(-1)).toBe('webfront.developer.abort'); }); @@ -76,13 +76,13 @@ describe('The developer distribution', () => { it('Pages staging retains older versions and refuses different bytes under an existing version', async () => { const project = memoryProject(); const environment = encode('environment'); - const pi = encode('starter'); + const starterBytes = encode('starter'); const write = async version => { - const manifest = {version, integrity: await integrity(environment), starters: {pi: {archive: 'pi-starter.tgz', integrity: await integrity(pi)}, - ...(version !== '0.1.0' ? {life: {archive: 'life-starter.tgz', integrity: await integrity(pi)}} : {})}}; + const manifest = {version, integrity: await integrity(environment), starters: {sample: {archive: 'sample-starter.tgz', integrity: await integrity(starterBytes)}, + ...(version !== '0.1.0' ? {life: {archive: 'life-starter.tgz', integrity: await integrity(starterBytes)}} : {})}}; await project.write('distribution/environment.tgz', environment); - await project.write('distribution/pi-starter.tgz', pi); - if (version !== '0.1.0') await project.write('distribution/life-starter.tgz', pi); + await project.write('distribution/sample-starter.tgz', starterBytes); + if (version !== '0.1.0') await project.write('distribution/life-starter.tgz', starterBytes); await project.write('distribution/provision.json', JSON.stringify(manifest)); await project.write('distribution/DeveloperReleaseData.hpp', bootstrapHeader(version, 'https://owner.github.io/WebFront/', manifest.integrity)); }; diff --git a/test/developer/specs/environment-specs.mjs b/test/developer/specs/environment-specs.mjs index 0cf3a437..da1e8a26 100644 --- a/test/developer/specs/environment-specs.mjs +++ b/test/developer/specs/environment-specs.mjs @@ -106,8 +106,8 @@ describe('The environment', () => { it('generated gzip words decode to the exact resources and generation is reproducible', async () => { const files = new Map([['index.html', encode('
PI
')], ['app.js', encode('console.log("π")')]]); - const header = generateProvider(files, 'PiUI', 'MIT */ preserved'); - expect(header).toBe(generateProvider(new Map([...files].reverse()), 'PiUI', 'MIT */ preserved')); + const header = generateProvider(files, 'AppUI', 'MIT */ preserved'); + expect(header).toBe(generateProvider(new Map([...files].reverse()), 'AppUI', 'MIT */ preserved')); const blocks = [...header.matchAll(/dataSize\{(\d+)\};\s+static constexpr[\s\S]*?data\{([\s\S]*?)\n \};/g)]; expect(blocks.length).toBe(2); for (const [index, match] of blocks.entries()) { diff --git a/test/developer/specs/manifest-specs.mjs b/test/developer/specs/manifest-specs.mjs index eec7ff5e..cf4c8181 100644 --- a/test/developer/specs/manifest-specs.mjs +++ b/test/developer/specs/manifest-specs.mjs @@ -18,7 +18,7 @@ describe('The project manifest', () => { expect(manifest.entries).toEqual({}); const full = {...minimal, dependencies: {react: '^19.0.0', '@scope/lib': '>=1.2.0 <2', tool: 'latest'}, registry: 'https://registry.test/', scripts: {build: 'wf embed main'}, entries: {main: 'ui/main.tsx'}, - providers: {PiUI: {entry: 'main', output: 'generated/PiUI.hpp'}}, test: {specs: ['spec/a.mjs']}, + providers: {AppUI: {entry: 'main', output: 'generated/AppUI.hpp'}}, test: {specs: ['spec/a.mjs']}, permissions: {files: ['ui'], publish: ['generated'], fetch: ['https://registry.npmjs.org']}}; const text = serializeManifest(validateManifest(full)); expect(JSON.parse(text)).toEqual(full); @@ -72,8 +72,8 @@ describe('The project manifest', () => { }); it('wf embed names the generated class after the provider, and refuses a file name that is not a C++ name', () => { - const manifest = validateManifest({...minimal, entries: {main: 'ui/main.tsx'}, providers: {PiUI: {entry: 'main', output: 'generated/pi-ui.hpp'}}}); - expect(embedTarget(manifest, ['PiUI'])).toEqual({entry: 'ui/main.tsx', output: 'generated/pi-ui.hpp', className: 'PiUI'}); + const manifest = validateManifest({...minimal, entries: {main: 'ui/main.tsx'}, providers: {AppUI: {entry: 'main', output: 'generated/app-ui.hpp'}}}); + expect(embedTarget(manifest, ['AppUI'])).toEqual({entry: 'ui/main.tsx', output: 'generated/app-ui.hpp', className: 'AppUI'}); expect(embedTarget(manifest, ['ui/main.tsx', '--output', 'generated/LifeUI.hpp']).className).toBe('LifeUI'); throws(() => embedTarget(manifest, ['ui/main.tsx', '--output', 'generated/life-ui.hpp']), /not a C\+\+ class name/); throws(() => embedTarget(manifest, ['ui/main.tsx']), /--output/); diff --git a/test/developer/specs/testing-specs.mjs b/test/developer/specs/testing-specs.mjs index d217ac66..9b18a711 100644 --- a/test/developer/specs/testing-specs.mjs +++ b/test/developer/specs/testing-specs.mjs @@ -1,5 +1,6 @@ // 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 {execute} from '../../../js/developer/environment/runtime.mjs'; import {bundleTests} from '../../../js/developer/environment/bundler.mjs'; import {rejects, throws, esbuild} from '../support.mjs'; @@ -109,6 +110,97 @@ describe('wf test', () => { await rejects(abortable(Promise.reject(new Error('own')), new AbortController().signal), /own/); }); + it('reports cancellation and deadlines without AbortSignal.any and releases listeners and timers', async () => { + const originalAny = Object.getOwnPropertyDescriptor(AbortSignal, 'any'); + const nativeSet = globalThis.setTimeout; + const nativeClear = globalThis.clearTimeout; + const timers = new Set(); + globalThis.setTimeout = (callback, milliseconds, ...args) => { + const timer = nativeSet(() => { timers.delete(timer); callback(...args); }, milliseconds); + timers.add(timer); + return timer; + }; + globalThis.clearTimeout = timer => { timers.delete(timer); nativeClear(timer); }; + Object.defineProperty(AbortSignal, 'any', {configurable: true, value: undefined}); + try { + for (const mode of ['already interrupted', 'interrupt while reading', 'deadline', 'read failure']) { + const controller = new AbortController(); + const listeners = new Set(); + const add = controller.signal.addEventListener.bind(controller.signal); + const remove = controller.signal.removeEventListener.bind(controller.signal); + controller.signal.addEventListener = (type, listener, ...args) => { + if (type === 'abort') listeners.add(listener); + add(type, listener, ...args); + }; + controller.signal.removeEventListener = (type, listener, ...args) => { + if (type === 'abort') listeners.delete(listener); + remove(type, listener, ...args); + }; + const calls = [], reports = []; + const bridge = {cppFunction: name => async () => { + calls.push(name); + if (name === 'webfront.developer.read') { + if (mode === 'read failure') throw new Error('read failed'); + return new Promise(() => {}); + } + return 'transaction'; + }}; + if (mode === 'already interrupted') controller.abort(new Error('Interrupted')); + const running = execute(['test', 'pattern'], {bridge, signal: controller.signal, + deadline: mode === 'deadline' ? Date.now() : undefined, onReport: report => reports.push(report)}); + if (mode === 'interrupt while reading') { + await Promise.resolve(); + controller.abort(new Error('Interrupted')); + expect(calls).toContain('webfront.developer.read'); + } + await rejects(running, error => { + if (mode === 'read failure') return error.message === 'read failed' && reports.length === 0; + const code = mode === 'deadline' ? 124 : 130; + expect(error.exitCode).withContext(mode).toBe(code); + expect(error.report.status).toBe(mode === 'deadline' ? 'timeout' : 'interrupted'); + expect(error.report.exitCode).toBe(code); + expect(error.report.pattern).toBe('pattern'); + expect(reports).toEqual([error.report]); + return true; + }); + expect(listeners.size).withContext(`${mode}: cancellation listener released`).toBe(0); + expect(timers.size).withContext(`${mode}: deadline and cleanup timers released`).toBe(0); + expect(calls).toContain('webfront.developer.commit'); + } + } finally { + globalThis.setTimeout = nativeSet; + globalThis.clearTimeout = nativeClear; + timers.forEach(nativeClear); + if (originalAny) Object.defineProperty(AbortSignal, 'any', originalAny); + else delete AbortSignal.any; + } + }); + + it('bounds cleanup when the bridge never publishes the empty test directory', async () => { + const originalSet = globalThis.setTimeout; + const delays = []; + // Keep the production two-second bound, but exercise its real event-loop completion in 20 ms. + globalThis.setTimeout = (callback, milliseconds, ...args) => { + delays.push(milliseconds); + return originalSet(callback, milliseconds === 2000 ? 20 : milliseconds, ...args); + }; + let cleanupStarted = false; + const bridge = {cppFunction: name => async () => { + if (name.endsWith('.state')) return 'transaction'; + if (name.endsWith('.read')) throw new Error('read failed'); + if (name.endsWith('.begin')) { + cleanupStarted = true; + return new Promise(() => {}); + } + throw new Error(`Unexpected call: ${name}`); + }}; + try { + await rejects(execute(['test'], {bridge}), /read failed/); + expect(cleanupStarted).toBeTrue(); + expect(delays).toContain(2000); + } finally { globalThis.setTimeout = originalSet; } + }); + it('a report is bounded: what the specs post is cut, not trusted', () => { const many = Array.from({length: 300}, (_, index) => spec(`s${index}`, 'failed', {failures: Array.from({length: 20}, () => failure('m'.repeat(50000)))})); const report = buildReport({type: 'done', overall: 'failed', specs: many, global: [], durationMs: Infinity, version: 'v'.repeat(100)}); diff --git a/test/developer/specs/timers-specs.mjs b/test/developer/specs/timers-specs.mjs new file mode 100644 index 00000000..d8d831bf --- /dev/null +++ b/test/developer/specs/timers-specs.mjs @@ -0,0 +1,48 @@ +import {withTimers, untilReady} from '../timers.mjs'; +import {rejects, throws} from '../support.mjs'; + +describe('Scoped browser deadlines', () => { + it('advances selected deadlines, preserves event-loop turns and restores globals on failure', async () => { + const original = [setTimeout, clearTimeout, Date.now]; + await rejects(withTimers([2000], async clock => { + let fired = false; + const cancelled = setTimeout(() => fail('cancelled timer fired'), 2000); + clearTimeout(cancelled); + setTimeout(() => { fired = true; }, 2000); + const before = Date.now(); + await new Promise(resolve => setTimeout(resolve, 0)); + expect(Date.now()).toBe(before); + expect(fired).toBeFalse(); + clock.fire(2000); + expect(fired).toBeTrue(); + throws(() => clock.fire(2000), /No pending/); + throw new Error('scope failed'); + }), /scope failed/); + expect([setTimeout, clearTimeout, Date.now]).toEqual(original); + }); + it('freezes arbitrary deadlines and keeps real fallbacks inside and after the scope', async () => { + await withTimers([1500, 3000, 20], async clock => { + const now = Date.now(); + setTimeout(() => {}, 1500); + setTimeout(() => {}, 3000); + await new Promise(resolve => setTimeout(resolve, 20)); + expect(Date.now()).toBe(now); + expect(clock.pending()).toBe(2); + clock.fire(1500); + clock.fire(3000); + }); + let afterScope, cancelled = false; + const completed = new Promise(resolve => { afterScope = resolve; }); + let cancelledId; + await withTimers([20], async () => { + setTimeout(afterScope, 20); + cancelledId = setTimeout(() => { cancelled = true; }, 20); + }); + clearTimeout(cancelledId); + await completed; + expect(cancelled).toBeFalse(); + await rejects(untilReady(new Promise(() => {}), Promise.resolve({error: new Error('deadline elapsed')})), /ended before readiness: deadline elapsed/); + await untilReady(Promise.resolve(), new Promise(() => {})); + }); + +}); diff --git a/test/developer/timers.mjs b/test/developer/timers.mjs new file mode 100644 index 00000000..c8477639 --- /dev/null +++ b/test/developer/timers.mjs @@ -0,0 +1,38 @@ +// Advance selected deadlines while keeping a real-time fallback for every timer. +// Native timer IDs remain cancellable after the scope restores the browser globals. +export async function withTimers(delays, run) { + const originalSet = globalThis.setTimeout; + const originalClear = globalThis.clearTimeout; + const originalNow = Date.now; + const now = Date.now(); + Date.now = () => now; + const pending = new Map(); + globalThis.setTimeout = (callback, delay, ...args) => { + if (!delays.includes(delay)) return originalSet(callback, delay, ...args); + const invoke = () => { pending.delete(id); callback(...args); }; + const id = originalSet(invoke, delay); + pending.set(id, {delay, invoke}); + return id; + }; + globalThis.clearTimeout = id => { + pending.delete(id); + originalClear(id); + }; + try { + return await run({pending: () => pending.size, fire(delay) { + const entry = [...pending].find(([, timer]) => timer.delay === delay); + if (!entry) throw new Error(`No pending ${delay} ms deadline`); + originalClear(entry[0]); + entry[1].invoke(); + }}); + } finally { + Date.now = originalNow; + globalThis.setTimeout = originalSet; + globalThis.clearTimeout = originalClear; + } +} + +// A readiness handshake cannot arrive after its command has already ended. +export const untilReady = (ready, running) => Promise.race([ready, running.then(result => { + throw new Error(`The command ended before readiness: ${result?.error?.message ?? result?.message ?? 'completed'}`); +})]); diff --git a/test/driver/WfDriver.hpp b/test/driver/WfDriver.hpp index 3197554c..d1e2f590 100644 --- a/test/driver/WfDriver.hpp +++ b/test/driver/WfDriver.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include namespace webfront::testdriver { @@ -236,6 +237,30 @@ inline constexpr auto driverScript = R"JS( })(); )JS"; +// Owns the connected UI and remembers a close requested before the handshake. Connection and +// watchdog callbacks share one lock, so neither ordering can lose the close or launch a late command. +template +class DriverBrowser { +public: + void connected(UI ui) { + std::scoped_lock lock{mutex}; + browser.emplace(std::move(ui)); + browser->addScript(closing ? "window.close()" : driverScript); + } + void close() { + std::scoped_lock lock{mutex}; + if (std::exchange(closing, true)) + return; + if (browser) + browser->addScript("window.close()"); + } + +private: + std::mutex mutex; + std::optional browser; + bool closing = false; +}; + inline std::string jsonArray(const std::vector& items) { std::string json = "["; for (const auto& item : items) @@ -314,12 +339,9 @@ int run(const Options& options, Setup&& setup = {}) { .integrity = *options.integrity, .registry = options.registryDirectory ? std::optional{"/driver/registry/"} : std::nullopt}); - std::mutex uiMutex; - std::optional browser; - auto subscription = app.subscribeUIStarted([&](typename App::UI ui) { - ui.addScript(driverScript); - std::scoped_lock lock{uiMutex}; - browser.emplace(ui); + DriverBrowser browser; + auto subscription = app.subscribeUIStarted([&](typename App::UI ui) { + browser.connected(ui); }); // The time limit: ask the page to close, then end the process if the browser does not follow. std::jthread watchdog([&](std::stop_token stop) { @@ -335,14 +357,9 @@ int run(const Options& options, Setup&& setup = {}) { || stop.stop_requested()) return; outcome.timedOut(); - { - std::scoped_lock ui{uiMutex}; - if (browser) { - try { - browser->addScript("window.close()"); - } catch (const std::exception&) {} // the bridge is gone: the forced exit below still applies - } - } + try { + browser.close(); + } catch (const std::exception&) {} // the bridge is gone: the forced exit below still applies if (!stop.stop_requested() && !wake.wait_for(lock, stop, diff --git a/test/fixtures/Pi.hpp b/test/fixtures/Pi.hpp deleted file mode 100644 index 98a4fa44..00000000 --- a/test/fixtures/Pi.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace webfront::demo { - -namespace detail { -// One spigot step over the remainders: returns the next candidate digit (0..10). -inline int spigotStep(std::vector& remainder) { - int quotient = 0; - for (auto i = static_cast(remainder.size()); i > 0; --i) { - auto& cell = remainder[static_cast(i - 1)]; - const int value = 10 * cell + quotient * i; - cell = value % (2 * i - 1); - quotient = value / (2 * i - 1); - } - remainder[0] = quotient % 10; - return quotient / 10; -} - -// The digits, with a leading placeholder, holding back runs of nines until a carry settles them. -inline std::string spigotDigits(int count) { - std::vector remainder(static_cast(count * 10 / 3 + 1), 2); - std::string digits; - int previous = 0, nines = 0; - for (int digit = 0; digit < count; ++digit) { - const int quotient = spigotStep(remainder); - if (quotient == 9) { - ++nines; - continue; - } - const int carry = quotient == 10; - digits += static_cast('0' + previous + carry); - digits.append(static_cast(nines), "90"[carry]); - previous = quotient % 10; - nines = 0; - } - return digits + static_cast('0' + previous); -} -} // namespace detail - -// Decimal spigot; deliberately small and bounded so it is suitable for the introductory demo. -inline std::string pi(std::uint32_t decimals) { - if (decimals > 1000) - throw std::invalid_argument("Choose at most 1000 decimals"); - auto result = detail::spigotDigits(static_cast(decimals) + 3).substr(1, static_cast(decimals) + 1); - if (decimals != 0) - result.insert(1, "."); - return result; -} - -} // namespace webfront::demo diff --git a/test/fixtures/SignalDemo.hpp b/test/fixtures/SignalDemo.hpp deleted file mode 100644 index 84bccd47..00000000 --- a/test/fixtures/SignalDemo.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace demo { - -inline void validateSignalParameter(double value, double minimum, double maximum) { - // Ordered comparisons also reject NaN and infinities. - if (!(value >= minimum && value <= maximum)) - throw std::invalid_argument("Signal parameters are outside the supported range"); -} - -// One second of deterministic sample data for the React example, not a real acquisition device. -inline std::vector generateSignal(double frequency, double amplitude, double harmonics) { - validateSignalParameter(frequency, 1, 12); - validateSignalParameter(amplitude, 0.1, 1.5); - validateSignalParameter(harmonics, 0, 1); - - std::vector samples(256); - for (std::size_t index = 0; index < samples.size(); ++index) { - const auto phase = 2 * std::numbers::pi * frequency * static_cast(index) / 256; - samples[index] = amplitude * (std::sin(phase) + harmonics * std::sin(3 * phase) / 3); - } - return samples; -} - -} // namespace demo diff --git a/test/fixtures/wf-project/tools/sleep.mjs b/test/fixtures/wf-project/tools/sleep.mjs deleted file mode 100644 index 519e2131..00000000 --- a/test/fixtures/wf-project/tools/sleep.mjs +++ /dev/null @@ -1,2 +0,0 @@ -// A command longer than any driver time limit of the tests. -export default async () => new Promise(resolve => setTimeout(resolve, 120000)); diff --git a/test/fixtures/wf-project/webfront.project.json b/test/fixtures/wf-project/webfront.project.json index 95b3daf7..23751bb0 100644 --- a/test/fixtures/wf-project/webfront.project.json +++ b/test/fixtures/wf-project/webfront.project.json @@ -3,6 +3,12 @@ "name": "wf-driver-fixture", "version": "0.1.0", "dependencies": {}, - "scripts": {"sleep": "tools/sleep.mjs", "echo": "tools/echo.mjs"}, - "test": {"specs": ["tests/arithmetic.spec.js"]} + "scripts": { + "echo": "tools/echo.mjs" + }, + "test": { + "specs": [ + "tests/arithmetic.spec.js" + ] + } } diff --git a/test/fixtures/wf-sleep-environment/environment.json b/test/fixtures/wf-sleep-environment/environment.json new file mode 100644 index 00000000..b0af83ac --- /dev/null +++ b/test/fixtures/wf-sleep-environment/environment.json @@ -0,0 +1 @@ +{"protocol":1,"api":1,"entry":"runtime.mjs"} diff --git a/test/fixtures/wf-sleep-environment/runtime.mjs b/test/fixtures/wf-sleep-environment/runtime.mjs new file mode 100644 index 00000000..21a781aa --- /dev/null +++ b/test/fixtures/wf-sleep-environment/runtime.mjs @@ -0,0 +1,14 @@ +// Minimal compatible environment for the driver's watchdog: no compiler or package installation. +// Other driver cases run real wf scripts; this one isolates a command already waiting in the browser. +export function mount() {} + +export async function runNonInteractive(argv, {bridge}) { + if (argv.join(' ') !== 'run sleep') throw new Error('Expected the sleeping watchdog command'); + const sleeping = new Promise(resolve => setTimeout(resolve, 120000)); + const call = (name, ...args) => bridge.cppFunction(`webfront.developer.${name}`)(...args); + const id = await call('begin', 'sleep.started', false); + await call('write', id, 'output', 0, new TextEncoder().encode('running')); + await call('commit', id); + await sleeping; + throw new Error('The watchdog did not stop the sleeping command'); +} diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index a11677d1..98d49ce0 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -17,8 +17,8 @@ list(APPEND TESTS_LIST JSFunctionTests.cpp TypeErasedFunctionTests.cpp MessagesT list(APPEND TESTS_LIST FileSystemTests.cpp NativeFSTests.cpp) list(APPEND TESTS_LIST DefaultFSTests.cpp StdnetShutdownTests.cpp SafePathTests.cpp UISubscribersTests.cpp) list(APPEND TESTS_LIST WebFrontTests.cpp WebLinkTests.cpp CEFPathsTests.cpp CEFMacrosTests.cpp) -list(APPEND TESTS_LIST DeveloperTests.cpp LifeTests.cpp StructuredShutdownTests.cpp JsFunctionSenderTests.cpp ApplicationTaskTests.cpp) -list(APPEND TESTS_LIST SignalDemoTests.cpp FrontendUrlTests.cpp ApplicationUrlTests.cpp FrontendContractTests.cpp CommandsTests.cpp EmbeddedCoreAssetsTests.cpp) +list(APPEND TESTS_LIST DeveloperTests.cpp WfDriverTests.cpp LifeTests.cpp StructuredShutdownTests.cpp JsFunctionSenderTests.cpp ApplicationTaskTests.cpp) +list(APPEND TESTS_LIST FrontendUrlTests.cpp ApplicationUrlTests.cpp FrontendContractTests.cpp CommandsTests.cpp EmbeddedCoreAssetsTests.cpp) if(WEBFRONT_USE_MDDLOG) list(APPEND TESTS_LIST MddlogLoggerTests.cpp MddlogTransportTests.cpp) endif() diff --git a/test/unit/DeveloperTests.cpp b/test/unit/DeveloperTests.cpp index 0fb73423..4453b6fd 100644 --- a/test/unit/DeveloperTests.cpp +++ b/test/unit/DeveloperTests.cpp @@ -1,4 +1,3 @@ -#include "../fixtures/Pi.hpp" #include "TemporaryDirectory.hpp" #include #include @@ -36,24 +35,24 @@ SCENARIO("Developer publication preserves the installed files until commit") { TemporaryDirectory project; developer::Store store{project.path()}; GIVEN("an installed output") { - auto first = store.begin("generated/PiUI.hpp", false); + auto first = store.begin("generated/LifeUI.hpp", false); store.write(first, "output", 0, bytes("old")); store.commit(first); WHEN("the next output is interrupted") { - auto second = store.begin("generated/PiUI.hpp", false); + auto second = store.begin("generated/LifeUI.hpp", false); store.write(second, "output", 0, bytes("partial")); - REQUIRE(read(store, "generated/PiUI.hpp") == "old"); + REQUIRE(read(store, "generated/LifeUI.hpp") == "old"); store.abort(second); THEN("the installed output remains intact") { - REQUIRE(read(store, "generated/PiUI.hpp") == "old"); + REQUIRE(read(store, "generated/LifeUI.hpp") == "old"); } } WHEN("a complete replacement is committed") { - auto second = store.begin("generated/PiUI.hpp", false); + auto second = store.begin("generated/LifeUI.hpp", false); store.write(second, "output", 0, bytes("new")); store.commit(second); THEN("the new output replaces it") { - REQUIRE(read(store, "generated/PiUI.hpp") == "new"); + REQUIRE(read(store, "generated/LifeUI.hpp") == "new"); } } } @@ -128,14 +127,6 @@ SCENARIO("Developer filesystem serves only published resources and protects the } } -SCENARIO("The PI demonstration returns exact decimal strings and rejects excessive work") { - REQUIRE(demo::pi(0) == "3"); - REQUIRE(demo::pi(1) == "3.1"); - REQUIRE(demo::pi(50) == "3.14159265358979323846264338327950288419716939937510"); - REQUIRE(demo::pi(1000).size() == 1002); - REQUIRE_THROWS_AS(demo::pi(1001), std::invalid_argument); -} - SCENARIO("A downloaded starter never replaces a developer's existing project") { TemporaryDirectory project; developer::Store store{project.path()}; diff --git a/test/unit/SignalDemoTests.cpp b/test/unit/SignalDemoTests.cpp deleted file mode 100644 index 8e748764..00000000 --- a/test/unit/SignalDemoTests.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "../fixtures/SignalDemo.hpp" -#include -#include - -#include -#include - -SCENARIO("The React signal demo generates a one-second waveform in C++") { - GIVEN("A four-Hertz sine wave at 0.8 volts") { - const auto samples = demo::generateSignal(4, 0.8, 0); - THEN("The buffer has 256 samples and the expected phase and RMS") { - REQUIRE(samples.size() == 256); - REQUIRE(samples[0] == Catch::Approx(0).margin(1e-12)); - REQUIRE(samples[16] == Catch::Approx(0.8)); - REQUIRE(samples[48] == Catch::Approx(-0.8)); - const auto energy = std::inner_product(samples.begin(), samples.end(), samples.begin(), 0.0); - REQUIRE(std::sqrt(energy / 256) == Catch::Approx(0.8 / std::sqrt(2.0))); - } - WHEN("A third harmonic is mixed in") { - const auto mixed = demo::generateSignal(4, 0.8, 0.6); - THEN("The samples contain that harmonic") { - REQUIRE(mixed[16] == Catch::Approx(0.64)); - REQUIRE(mixed != samples); - } - } - } -} - -SCENARIO("The React signal demo rejects invalid parameters") { - GIVEN("Invalid frequencies, amplitudes or harmonic mixes") { - for (const auto frequency : {0.0, 13.0, std::numeric_limits::quiet_NaN()}) - REQUIRE_THROWS_AS(demo::generateSignal(frequency, 0.8, 0.3), std::invalid_argument); - for (const auto amplitude : {0.0, 1.6, std::numeric_limits::infinity()}) - REQUIRE_THROWS_AS(demo::generateSignal(4, amplitude, 0.3), std::invalid_argument); - for (const auto harmonics : {-0.1, 1.1, std::numeric_limits::quiet_NaN()}) - REQUIRE_THROWS_AS(demo::generateSignal(4, 0.8, harmonics), std::invalid_argument); - THEN("The supported boundary values still produce finite samples") { - for (const auto sample : demo::generateSignal(12, 1.5, 1)) - REQUIRE(std::isfinite(sample)); - REQUIRE(demo::generateSignal(1, 0.1, 0).size() == 256); - } - } -} diff --git a/test/unit/WfDriverTests.cpp b/test/unit/WfDriverTests.cpp new file mode 100644 index 00000000..0a6d4c99 --- /dev/null +++ b/test/unit/WfDriverTests.cpp @@ -0,0 +1,38 @@ +#include "../driver/WfDriver.hpp" +#include + +namespace { +struct DriverUI { + std::vector& scripts; + void addScript(std::string_view script) const { + scripts.emplace_back(script); + } +}; +} // namespace + +SCENARIO("The driver deadline closes both connected and late browsers without losing the request") { + std::vector scripts; + webfront::testdriver::DriverBrowser browser; + GIVEN("the browser connects before the deadline") { + browser.connected(DriverUI{scripts}); + REQUIRE(scripts == std::vector{webfront::testdriver::driverScript}); + WHEN("the watchdog closes it twice") { + browser.close(); + browser.close(); + THEN("one close follows the command runner") { + REQUIRE(scripts.size() == 2); + REQUIRE(scripts.back() == "window.close()"); + } + } + } + GIVEN("the deadline expires before a browser connects") { + browser.close(); + REQUIRE(scripts.empty()); + WHEN("the handshake arrives afterward") { + browser.connected(DriverUI{scripts}); + THEN("the page closes without starting the command runner") { + REQUIRE(scripts == std::vector{"window.close()"}); + } + } + } +} diff --git a/test/web/CMakeLists.txt b/test/web/CMakeLists.txt index e4f8dc0f..42c3a2ea 100644 --- a/test/web/CMakeLists.txt +++ b/test/web/CMakeLists.txt @@ -138,21 +138,24 @@ if(_browser_tests_available) set_tests_properties(WfDriverProject PROPERTIES FIXTURES_SETUP WfDriverProject LABELS "web-integration" TIMEOUT 30) # webfront_add_driver_test( - # [OUTPUT ] [REPORT ] [DRIVER_TIMEOUT ] [FORGE :] - # [ENVIRONMENT INTEGRITY ] [FRESH_PROJECT ] [RENAME_ENTRY ] [PINNED] [REQUIRES ] [PROVIDES ]) + # [OUTPUT ] [REPORT ] [EXPECT_FILE ] [DRIVER_TIMEOUT ] [FORGE :] + # [ENVIRONMENT INTEGRITY ] [FRESH_PROJECT ] [RENAME_ENTRY ] [PINNED] [SLEEP_ENVIRONMENT] [REQUIRES ] [PROVIDES ]) function(webfront_add_driver_test name status command) - cmake_parse_arguments(ARG "PINNED" "OUTPUT;REPORT;DRIVER_TIMEOUT;FORGE;ENVIRONMENT;INTEGRITY;FRESH_PROJECT;RENAME_ENTRY;REQUIRES;PROVIDES" "" ${ARGN}) + cmake_parse_arguments(ARG "PINNED;SLEEP_ENVIRONMENT" "OUTPUT;REPORT;EXPECT_FILE;DRIVER_TIMEOUT;FORGE;ENVIRONMENT;INTEGRITY;FRESH_PROJECT;RENAME_ENTRY;REQUIRES;PROVIDES" "" ${ARGN}) set(options -DEXPECT_STATUS=${status} "-DCOMMAND=${command}" -DPROFILE=${CMAKE_CURRENT_BINARY_DIR}/wf-profiles/${name}) foreach(option OUTPUT REPORT) if(ARG_${option}) list(APPEND options "-DEXPECT_${option}=${ARG_${option}}") endif() endforeach() - foreach(option FORGE ENVIRONMENT INTEGRITY FRESH_PROJECT RENAME_ENTRY) + foreach(option FORGE ENVIRONMENT INTEGRITY FRESH_PROJECT RENAME_ENTRY EXPECT_FILE) if(ARG_${option}) list(APPEND options "-D${option}=${ARG_${option}}") endif() endforeach() + if(ARG_SLEEP_ENVIRONMENT) + list(APPEND options -DSLEEP_ENVIRONMENT=ON) + endif() if(ARG_PINNED) # No environment passed: the driver runs the pinned bootstrap environment provisioned at configure time. list(APPEND options -DENVIRONMENT= -DINTEGRITY= -DREGISTRY=) @@ -174,7 +177,7 @@ if(_browser_tests_available) # A failing command: its status, its output and the structured report reach CTest. webfront_add_driver_test(WfDriverTestFails 1 "test|fails" OUTPUT "FAILED: 1 spec, 1 failure" REPORT "\"failed\":1" REQUIRES WfDriverInstalled) # The starters pinned by the environment are served next to its archive. - webfront_add_driver_test(WfDriverCreateStarter 0 "create|pi" OUTPUT "Created" + webfront_add_driver_test(WfDriverCreateStarter 0 "create|life" OUTPUT "Created" FRESH_PROJECT "${CMAKE_CURRENT_BINARY_DIR}/wf-driver-starter") # The entry module is the one environment.json declares, not a fixed name. webfront_add_driver_test(WfDriverRenamedEntry 0 "list" RENAME_ENTRY runner.mjs) @@ -183,7 +186,8 @@ if(_browser_tests_available) webfront_add_driver_test(WfDriverUnknownCommand 1 "nosuchcommand" OUTPUT "nosuchcommand") # What a script writes to its console before it ends reaches the result of the command. webfront_add_driver_test(WfDriverScriptOutput 0 "run|echo|one|two" OUTPUT "echo says one two") - webfront_add_driver_test(WfDriverTimeout 71 "run|sleep" OUTPUT "time limit of the driver" DRIVER_TIMEOUT 4) + # Isolate the driver's deadline from compiler startup, and prove the command actually began. + webfront_add_driver_test(WfDriverTimeout 71 "run|sleep" OUTPUT "time limit of the driver" DRIVER_TIMEOUT 4 EXPECT_FILE sleep.started SLEEP_ENVIRONMENT) webfront_add_driver_test(WfDriverWrongIntegrity 70 "list" OUTPUT "Integrity check failed" INTEGRITY "sha512-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==") webfront_add_driver_test(WfDriverMissingArchive 70 "list" OUTPUT "archive not found" @@ -260,29 +264,28 @@ if(_browser_tests_available) REQUIRES SelfBuildProject TestRegistry PROVIDES SelfBuildInstalled) webfront_add_self_build_test(SelfBuild 0 "run|build|build-distribution" OUTPUT "Script build completed" REQUIRES SelfBuildInstalled PROVIDES SelfBuilt) - # The specs of the developer environment (packages, manifest, restore, scripts, wf dev, wf test, distribution): the - # project's own `wf test`, in the browser, under the jasmine-core of its lock. They read the sources of the copy. + # Developer specs migrated by #344 remain in the browser under the repository's locked Jasmine. webfront_add_self_build_test(DeveloperSpecs 0 "test|--timeout|240" OUTPUT "PASSED: [0-9]+ specs" TIMEOUT 300 REQUIRES SelfBuildInstalled) webfront_add_self_build_test(SelfBuildRepeat 0 "run|build|build-distribution-repeat" OUTPUT "Script build completed" REQUIRES SelfBuilt PROVIDES SelfBuiltTwice) - # The permissions of webfront.project.json frame where a script writes. + # The packaged environment must enforce the actual project's publication permissions. webfront_add_self_build_test(SelfBuildOutsidePermissions 1 "run|build|elsewhere" OUTPUT "Permission denied: writing elsewhere" REQUIRES SelfBuilt) # Reproducible: two builds give the very same bytes. set(_self_outputs environment.tgz environment.json provision.json DeveloperReleaseData.hpp runtime.mjs compiler.mjs - script-worker.mjs typecheck-worker.mjs esbuild.wasm xterm.css LICENSES.txt package.json pi-starter.tgz life-starter.tgz) + script-worker.mjs typecheck-worker.mjs esbuild.wasm xterm.css LICENSES.txt package.json life-starter.tgz) webfront_add_self_build_check(SelfBuildReproducible CompareFiles.cmake SelfBuiltTwice -DLEFT=${_self_project}/build-distribution -DRIGHT=${_self_project}/build-distribution-repeat "-DFILES=${_self_outputs}") - # The fixtures of the tests that run the environment under test: its outputs, the registry and the pages of the tests. + set_tests_properties(SelfBuildReproducible PROPERTIES FIXTURES_SETUP SelfReproducible) + # Assemble fixtures from the self-built environment, retaining #344's dependency chain. add_test(NAME DeveloperFixtures COMMAND ${CMAKE_COMMAND} -DSOURCE=${PROJECT_SOURCE_DIR} -DPROJECT=${_self_project} -DOUTPUT=${_fixtures} -P ${PROJECT_SOURCE_DIR}/test/cmake/AssembleDeveloperFixtures.cmake) set_tests_properties(DeveloperFixtures PROPERTIES FIXTURES_REQUIRED SelfBuilt FIXTURES_SETUP DeveloperFixtures RESOURCE_LOCK self-build-project LABELS "web-integration" TIMEOUT 60) - # The checked-in bootstrap bundles and checksums are rebuilt from the sources by wf, and the core headers that embed - # them by CMake: all of them are the checked-in ones. + # Refresh is validated separately from the two identical reproducibility builds. webfront_add_self_build_test(SelfBuildRefresh 0 "run|build|build-distribution|--refresh-bootstrap" OUTPUT "Script build completed" - REQUIRES SelfBuilt PROVIDES SelfRefreshed) + REQUIRES SelfReproducible PROVIDES SelfRefreshed) webfront_add_self_build_check(SelfBuildRefreshMatchesSources CheckSelfBuildRefresh.cmake SelfRefreshed -DSOURCE=${PROJECT_SOURCE_DIR} -DPROJECT=${_self_project} -DOUTPUT=build-distribution) # The Pages site keeps every version and refuses to change a published one. @@ -296,26 +299,7 @@ if(_browser_tests_available) webfront_add_self_build_test(SelfBuildSiteRefusesChange 1 "run|site|build-distribution|build-site" OUTPUT "differs; increment the distribution version" REQUIRES SelfTampered) endif() - # Build the actual browser-generated header only after the setup test has produced it. - add_executable(developer_embedded EXCLUDE_FROM_ALL DeveloperEmbeddedTest.cpp) - target_link_libraries(developer_embedded PRIVATE WebFront_test_hardening WebFront WebFront_warnings WebFront_options) - target_compile_definitions(developer_embedded PRIVATE WEBFRONT_TEST_FRONTEND=${WEBFRONT_WEBTEST_FRONTEND_TYPE} - WEBFRONT_PI_ASSETS_HEADER="${CMAKE_CURRENT_BINARY_DIR}/developer-generated/PiUI.hpp") - webfront_setup_frontends_for_target(developer_embedded) - add_test(NAME DeveloperEmbeddedBuild COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}" - --config $ --target developer_embedded --parallel 2) - # A nested build can regenerate CMake or relink shared outputs. Exclude every - # running test in this tree, not only the other nested build (Windows locks executables). - set_tests_properties(DeveloperEmbeddedBuild PROPERTIES FIXTURES_REQUIRED DeveloperGenerated - FIXTURES_SETUP DeveloperEmbedded LABELS "web-integration" TIMEOUT 180 - RUN_SERIAL TRUE PROCESSORS 2) - set(_embedded_command "$") - if(_developer_xvfb) - set(_embedded_command "${_developer_xvfb}" -a ${_embedded_command}) - endif() - add_test(NAME DeveloperEmbeddedIntegration COMMAND ${_embedded_command}) - webfront_set_browser_test_properties(DeveloperEmbeddedIntegration "${CMAKE_CURRENT_SOURCE_DIR}" 60) - set_tests_properties(DeveloperEmbeddedIntegration PROPERTIES FIXTURES_REQUIRED DeveloperEmbedded) + # Compile the maintained application's actual browser-generated header, then run it without a project root. add_executable(life_embedded EXCLUDE_FROM_ALL LifeEmbeddedTest.cpp) target_link_libraries(life_embedded PRIVATE WebFront_test_hardening WebFront WebFront_warnings WebFront_options) target_compile_definitions(life_embedded PRIVATE WEBFRONT_TEST_FRONTEND=${WEBFRONT_WEBTEST_FRONTEND_TYPE} @@ -323,7 +307,7 @@ if(_browser_tests_available) webfront_setup_frontends_for_target(life_embedded) add_test(NAME LifeEmbeddedBuild COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}" --config $ --target life_embedded --parallel 2) - # Keep the same whole-tree exclusion as DeveloperEmbeddedBuild. + # The nested build must exclude other tests, especially on Windows where running executables are locked. set_tests_properties(LifeEmbeddedBuild PROPERTIES FIXTURES_REQUIRED DeveloperGenerated FIXTURES_SETUP LifeEmbedded LABELS "web-integration" TIMEOUT 180 RUN_SERIAL TRUE PROCESSORS 2) @@ -336,7 +320,7 @@ if(_browser_tests_available) set_tests_properties(LifeEmbeddedIntegration PROPERTIES FIXTURES_REQUIRED LifeEmbedded) if(WEBFRONT_WEBTEST_FRONTEND STREQUAL "WKWebView") get_filename_component(_developer_wk_plist "${PROJECT_SOURCE_DIR}/test/cmake/WKWebViewTestInfo.plist.in" ABSOLUTE) - foreach(target developer_integration developer_embedded life_embedded) + foreach(target developer_integration life_embedded) string(REPLACE "_" "-" identifier "${target}") set_target_properties(${target} PROPERTIES MACOSX_BUNDLE TRUE diff --git a/test/web/DeveloperEmbeddedTest.cpp b/test/web/DeveloperEmbeddedTest.cpp deleted file mode 100644 index f69d85f2..00000000 --- a/test/web/DeveloperEmbeddedTest.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include WEBFRONT_PI_ASSETS_HEADER -#include "../fixtures/Pi.hpp" -#include "../unit/TemporaryDirectory.hpp" - -#include -#include - -namespace { -constexpr auto uiScript = R"JS( -(async () => { - try { - const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); - for (let attempt = 0; !document.querySelector('button'); ++attempt) { - if (attempt === 100) throw new Error('Embedded React interface did not mount'); - await delay(50); - } - document.querySelector('button').click(); - for (let attempt = 0; !document.querySelector('output').textContent.startsWith('3.14159265358979323846264338327950288419716939937510'); ++attempt) { - if (attempt === 100) throw new Error('Embedded interface did not display PI'); - await delay(50); - } - const developmentDisabled = await webFront.cppFunction('webfront.developer.config')().then(() => false, () => true); - if (!developmentDisabled) throw new Error('Distribution enabled developer callbacks'); - await webFront.cppFunction('test.report')(true, 'Embedded React + PI passed with an empty working directory'); - } catch (error) { - await webFront.cppFunction('test.report')(false, String(error.stack || error)); - } finally { setTimeout(() => globalThis.close(), 0); } -})().catch(error => { console.error(error); globalThis.close(); }); -)JS"; -} // namespace - -int main() { - try { - webfront::detail::ensureFrontendInitialized(); - webfront::test::TemporaryDirectory empty; - const auto original = std::filesystem::current_path(); - std::filesystem::current_path(empty.path()); - using App = webfront:: - BasicWF, webfront::http::DefaultBuffersPolicy, WEBFRONT_TEST_FRONTEND>; - App app; - std::atomic passed{false}; - app.cppFunction("pi", &webfront::demo::pi); - app.cppFunction("test.report", [&](bool success, std::string message) { - std::cout << message << std::endl; - passed.store(success); - }); - auto subscription = app.subscribeUIStarted([](App::UI ui) { - ui.addScript(uiScript); - }); - app.show(); - std::filesystem::current_path(original); - return passed.load() ? 0 : 1; - } catch (const std::exception& error) { - std::cerr << error.what() << '\n'; - return 1; - } -} diff --git a/test/web/DeveloperTest.cpp b/test/web/DeveloperTest.cpp index 2ac19b52..2e60f8c5 100644 --- a/test/web/DeveloperTest.cpp +++ b/test/web/DeveloperTest.cpp @@ -1,5 +1,4 @@ #include "../../examples/life/Life.hpp" -#include "../fixtures/Pi.hpp" #include "../unit/TemporaryDirectory.hpp" #include #include @@ -10,6 +9,7 @@ #include #include #include +#include #include namespace { @@ -28,7 +28,7 @@ std::string readFixtureText(const std::filesystem::path& path) { class FixturesFS { public: - explicit FixturesFS(std::filesystem::path projectRoot) : root(std::filesystem::canonical(projectRoot)) { } + explicit FixturesFS(std::filesystem::path projectRoot) : root(std::filesystem::canonical(projectRoot)) {} std::optional open(std::filesystem::path path) const { const auto relative = path.relative_path().generic_string(); if (!relative.starts_with("fixtures/")) @@ -58,10 +58,9 @@ std::string readIntegrity(const std::filesystem::path& config) { template void registerCallbacks(App& app, const std::filesystem::path& project, std::atomic& passed) { - app.cppFunction("pi", &webfront::demo::pi); app.cppFunction("life.step", &webfront::demo::nextLife); app.cppFunction("test.header", [project](std::string name) { - if (name != "PiUI" && name != "LifeUI") + if (name != "LifeUI") throw std::invalid_argument("Unknown generated fixture"); const auto header = readFixtureText(project / "generated" / (name + ".hpp")); // The generated header is larger than a bridge string: return a stable small digest. @@ -81,6 +80,9 @@ void registerCallbacks(App& app, const std::filesystem::path& project, std::atom std::scoped_lock lock{result->mutex}; return result->json; }); + app.cppFunction("test.progress", [](std::string message) { + std::cout << "Developer integration: " << message << std::endl; + }); app.cppFunction("test.report", [&passed](bool success, std::string message) { std::cout << message << std::endl; passed.store(success); @@ -94,6 +96,18 @@ class CommandStates { std::scoped_lock lock{mutex}; states[tag] = std::move(state); } + void release(const std::string& tag) { + std::scoped_lock lock{mutex}; + releasedTags.insert(tag); + } + void releaseAll() { + std::scoped_lock lock{mutex}; + allReleased = true; + } + bool released(const std::string& tag) const { + std::scoped_lock lock{mutex}; + return allReleased || releasedTags.contains(tag); + } std::string get(const std::string& tag) const { std::scoped_lock lock{mutex}; const auto found = states.find(tag); @@ -103,6 +117,8 @@ class CommandStates { private: mutable std::mutex mutex; std::map states; + std::set releasedTags; + bool allReleased = false; }; namespace ex = webfront::networking::ex; @@ -127,7 +143,7 @@ webfront::Task waitUntilStopped(Context context, std::shared_ptr co_await context.ui().resumeAfter(20ms); } -// After Ctrl+C, keeps running for a while, deaf to the stop request, before it ends. +// After Ctrl+C, remains deaf to the stop request until the test releases it. template webfront::Task lingerAfterStop(Context context, std::shared_ptr states) { const auto tag = context.args().at(0); @@ -139,7 +155,7 @@ webfront::Task lingerAfterStop(Context context, std::shared_ptr s while (!context.stopRequested()) co_await deafPause(); states->set(tag, "stopping"); - for (int i = 0; i < 40; ++i) + while (!states->released(tag)) co_await deafPause(); } @@ -199,8 +215,7 @@ void bootstrapApp(App& app, std::string_view mode, const std::string& integrity) void copyHeaders(const std::filesystem::path& project, const std::filesystem::path& output) { std::filesystem::create_directories(output); - for (const auto* name : {"PiUI.hpp", "LifeUI.hpp"}) - std::filesystem::copy_file(project / "generated" / name, output / name, std::filesystem::copy_options::overwrite_existing); + std::filesystem::copy_file(project / "generated/LifeUI.hpp", output / "LifeUI.hpp", std::filesystem::copy_options::overwrite_existing); } constexpr auto runScript = @@ -220,12 +235,15 @@ int main(int argc, char** argv) { App app{project.path()}; std::atomic passed{false}; registerCallbacks(app, project.path(), passed); - auto states = std::make_shared(); - webfront::Commands commands{app}; + auto states = std::make_shared(); + webfront::Commands commands{app}; registerCommands(commands, states); app.cppFunction("test.command", [states](std::string tag) { return states->get(tag); }); + app.cppFunction("test.release", [states](std::string tag) { + states->release(tag); + }); app.cppFunction("test.browsers", [&app] { return static_cast(app.connectedBrowsers()); }); @@ -234,8 +252,14 @@ int main(int argc, char** argv) { if (!std::exchange(injected, true)) ui.addScript(runScript); }); - app.show(); + try { + app.show(); + } catch (...) { + states->releaseAll(); + throw; + } // The test ends while the "final" command runs: shutdown drains it. + states->releaseAll(); app.shutdown(); if (!passed.load()) return 1; diff --git a/test/web/JasmineTest.cpp b/test/web/JasmineTest.cpp index dc1304b5..d863a2a2 100644 --- a/test/web/JasmineTest.cpp +++ b/test/web/JasmineTest.cpp @@ -7,7 +7,6 @@ #include #include "../driver/WfDriver.hpp" -#include "../fixtures/SignalDemo.hpp" #include "RejectedWebSocketServer.hpp" #include @@ -271,7 +270,6 @@ class BrowserIntegrationTest { return state.senderCancellationObserved.load(); }); webFront->cppFunction("plusPageUrl", [] { return frontend::detail::applicationUrl("9002", "a+b.html"); }); - webFront->cppFunction("signal.generate", &demo::generateSignal); webFront->cppFunction("rejectedWebSocketUrl", [this] { return rejectedWebSocket->url(); }); uiSubscription = webFront->subscribeUIStarted([this](TestWF::UI) { state.subscriberNotified = true; @@ -421,7 +419,7 @@ class BrowserIntegrationTest { } // namespace int main(int argc, char** argv) { - log::setLogLevel(log::Debug); + log::setLogLevel(log::Warn); const auto consoleSink = log::addSinks(log::clogSink); BrowserIntegrationTest test; diff --git a/test/web/developer-specs.mjs b/test/web/developer-specs.mjs index 8b23abf8..75eb1e47 100644 --- a/test/web/developer-specs.mjs +++ b/test/web/developer-specs.mjs @@ -1,4 +1,5 @@ -// Autonomous real-engine test: compiled WASM, npm graph, PI bridge, preview, cache and embedding. +import {withTimers, untilReady} from './timers.mjs'; +// Autonomous real-engine test: compiled WASM, npm graph, Life bridge, preview, cache and embedding. const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); const assert = (condition, message) => { if (!condition) throw new Error(message); }; const call = (name, ...args) => webFront.cppFunction(`webfront.developer.${name}`)(...args); @@ -30,11 +31,15 @@ try { const runtime = await import('/webfront/developer/environment/runtime.mjs'); const config = JSON.parse(await webFront.cppFunction('webfront.developer.config')()); const environment = await (await fetch('/webfront/developer/environment/environment.json')).json(); + const currentDistribution = !config.environment.startsWith('https:'); + if (currentDistribution) assert(JSON.stringify(Object.keys(environment.starters)) === JSON.stringify(['life']), 'Only the Life starter must be shipped'); config.starters = Object.fromEntries(Object.entries(environment.starters).map(([name, value]) => [name, {url: new URL(value.archive, new URL(config.environment, location.href)).href, integrity: value.integrity}])); const context = {bridge: webFront, config, preview: document.getElementById('preview'), signal: new AbortController().signal, write: text => console.log(text)}; - await runtime.execute(['create', 'pi'], context); - const overwriteRefused = await runtime.execute(['create', 'pi'], context).then(() => false, () => true); + if (currentDistribution) assert(await runtime.execute(['create', 'pi'], context).then(() => false, error => /Unknown pinned starter/.test(error.message)), + 'The retired PI starter must not be offered'); + await runtime.execute(['create', 'life'], context); + const overwriteRefused = await runtime.execute(['create', 'life'], context).then(() => false, () => true); assert(overwriteRefused, 'A starter must not replace an existing project'); const noManifest = await runtime.execute(['install', 'react@19.3.1'], context).then(() => false, error => /run wf init/.test(error.message)); assert(noManifest, 'wf install must ask for a manifest first'); @@ -42,32 +47,20 @@ try { const initRefused = await runtime.execute(['init'], context).then(() => false, () => true); assert(initRefused, 'wf init must not replace an existing manifest'); await runtime.execute(['install', 'react@19.3.1', 'react-dom@19.3.1'], context); - const lock = await runtime.readLock(webFront); + let lock = await runtime.readLock(webFront); assert(lock.manifestDigest?.length === 64, 'The lock must record the digest of the manifest dependencies'); const manifest = JSON.parse(new TextDecoder().decode(await readFile('webfront.project.json'))); assert(manifest.dependencies.react === '19.3.1' && manifest.dependencies['react-dom'] === '19.3.1', 'The manifest must record the requested ranges'); // Entries and providers declared in the manifest drive wf preview and wf embed. manifest.entries = {main: 'ui/main.tsx'}; - manifest.providers = {PiUI: {entry: 'main', output: 'generated/PiUI.hpp'}}; + manifest.providers = {LifeUI: {entry: 'main', output: 'generated/LifeUI.hpp'}}; await writeFile('webfront.project.json', JSON.stringify(manifest, null, 2)); assert(!(await runtime.execute(['list'], context)).includes('Warning'), 'Editing entries must not desynchronize the lock'); assert(Object.keys(lock.packages).length === 3, 'React, React DOM and scheduler must be resolved'); const listed = await runtime.execute(['list'], context); assert(listed.split('\n').length === 3 && listed.includes('react@19.3.1'), 'wf list must name the installed packages'); const historyLength = history.length; - await runtime.execute(['preview'], context); const frame = context.preview; - for (let attempt = 0; attempt < 300; ++attempt) { - if (frame.contentDocument?.querySelector('button')) break; - if (attempt === 299) throw new Error('React preview did not mount'); - await delay(50); - } - frame.contentDocument.querySelector('button').click(); - for (let attempt = 0; attempt < 100; ++attempt) { - if (frame.contentDocument.querySelector('output')?.textContent.startsWith('3.14159265358979323846264338327950288419716939937510')) break; - if (attempt === 99) throw new Error('React preview did not display C++ PI'); - await delay(50); - } // wf build does not navigate; wf dev keeps one WASM context, reloads only committed output and recovers. assert((await runtime.complete('wf d', context)).candidates.includes('dev'), 'Completion must list wf dev'); assert((await runtime.complete('wf build m', context)).candidates.includes('main') && @@ -89,34 +82,45 @@ try { await writeFile('watch/value.ts', "export const value: string = 'watch-one';\n"); let devOutput = ''; const devStop = new AbortController(); - const devResult = runtime.execute(['dev', 'watch/main.ts'], {...context, signal: devStop.signal, - write: text => { devOutput += text; }}).then(() => null, error => error); - try { - await waitDev(() => frame.contentDocument?.getElementById('root')?.textContent === 'watch-one', 'Initial dev preview did not mount'); - await writeFile('watch/value.ts', "export const value: string = 'watch-two';\n"); - await waitDev(() => frame.contentDocument?.getElementById('root')?.textContent === 'watch-two', 'Changed dependency was not rebuilt'); - const lastGoodDocument = frame.contentDocument; - const lastGoodJS = new TextDecoder().decode(await readFile('.webfront/developer/preview/app.js')); - await writeFile('watch/value.ts', 'export const value = ;\n'); - await waitDev(() => frame.contentDocument?.getElementById('webfront-build-diagnostics'), 'Syntax error was not overlaid'); - assert(frame.contentDocument === lastGoodDocument && frame.contentDocument.getElementById('root').textContent === 'watch-two', 'A syntax error must preserve the running preview'); - assert(new TextDecoder().decode(await readFile('.webfront/developer/preview/app.js')) === lastGoodJS, 'A syntax error must preserve published output'); - assert(/watch\/value.ts:1:/.test(devOutput) && /watch\/value.ts:1:/.test(frame.contentDocument.getElementById('webfront-build-diagnostics').textContent), 'Terminal and overlay must locate the syntax error'); - await writeFile('watch/value.ts', "export const value: string = 'watch-three';\n"); - await waitDev(() => frame.contentDocument?.getElementById('root')?.textContent === 'watch-three', 'Corrected source did not recover'); - assert(!frame.contentDocument.getElementById('webfront-build-diagnostics'), 'Successful build must clear the overlay'); - await writeFile('watch/main.ts', "import {value} from './created'; document.getElementById('root').textContent = value;\n"); - await waitDev(() => frame.contentDocument?.getElementById('webfront-build-diagnostics'), 'Missing import was not reported'); - await writeFile('watch/created.ts', "export const value = 'watch-created';\n"); - await waitDev(() => frame.contentDocument?.getElementById('root')?.textContent === 'watch-created', 'Creating a missing import must recover'); - assert(history.length === historyLength, 'Dev reloads must replace session history'); - } finally { devStop.abort(); } - assert((await devResult)?.exitCode === 130, 'Ctrl+C must stop dev with exit code 130'); - const afterStop = frame.contentDocument; - await writeFile('watch/created.ts', "export const value = 'must-not-rebuild';\n"); - await delay(1600); - assert(frame.contentDocument === afterStop && frame.contentDocument.getElementById('root').textContent === 'watch-created', 'Stopped dev must not rebuild or reload'); - assert(JSON.parse(new TextDecoder().decode(await call('list', '.webfront/developer/staging'))).length === 0, 'Stopped dev must leave no staging'); + await withTimers([750], async clock => { + const poll = async () => { + await waitDev(() => clock.pending() > 0, 'Dev polling deadline was not armed'); + clock.fire(750); + }; + const devResult = runtime.execute(['dev', 'watch/main.ts'], {...context, signal: devStop.signal, + write: text => { devOutput += text; }}).then(() => null, error => error); + try { + await waitDev(() => frame.contentDocument?.getElementById('root')?.textContent === 'watch-one', 'Initial dev preview did not mount'); + await writeFile('watch/value.ts', "export const value: string = 'watch-two';\n"); + await poll(); + await waitDev(() => frame.contentDocument?.getElementById('root')?.textContent === 'watch-two', 'Changed dependency was not rebuilt'); + const lastGoodDocument = frame.contentDocument; + const lastGoodJS = new TextDecoder().decode(await readFile('.webfront/developer/preview/app.js')); + await writeFile('watch/value.ts', 'export const value = ;\n'); + await poll(); + await waitDev(() => frame.contentDocument?.getElementById('webfront-build-diagnostics'), 'Syntax error was not overlaid'); + assert(frame.contentDocument === lastGoodDocument && frame.contentDocument.getElementById('root').textContent === 'watch-two', 'A syntax error must preserve the running preview'); + assert(new TextDecoder().decode(await readFile('.webfront/developer/preview/app.js')) === lastGoodJS, 'A syntax error must preserve published output'); + assert(/watch\/value.ts:1:/.test(devOutput) && /watch\/value.ts:1:/.test(frame.contentDocument.getElementById('webfront-build-diagnostics').textContent), 'Terminal and overlay must locate the syntax error'); + await writeFile('watch/value.ts', "export const value: string = 'watch-three';\n"); + await poll(); + await waitDev(() => frame.contentDocument?.getElementById('root')?.textContent === 'watch-three', 'Corrected source did not recover'); + assert(!frame.contentDocument.getElementById('webfront-build-diagnostics'), 'Successful build must clear the overlay'); + await writeFile('watch/main.ts', "import {value} from './created'; document.getElementById('root').textContent = value;\n"); + await poll(); + await waitDev(() => frame.contentDocument?.getElementById('webfront-build-diagnostics'), 'Missing import was not reported'); + await writeFile('watch/created.ts', "export const value = 'watch-created';\n"); + await poll(); + await waitDev(() => frame.contentDocument?.getElementById('root')?.textContent === 'watch-created', 'Creating a missing import must recover'); + assert(history.length === historyLength, 'Dev reloads must replace session history'); + } finally { devStop.abort(); } + assert((await devResult)?.exitCode === 130, 'Ctrl+C must stop dev with exit code 130'); + const afterStop = frame.contentDocument; + await writeFile('watch/created.ts', "export const value = 'must-not-rebuild';\n"); + assert(clock.pending() === 0, 'Stopped dev must remove its polling timer'); + assert(frame.contentDocument === afterStop && frame.contentDocument.getElementById('root').textContent === 'watch-created', 'Stopped dev must not rebuild or reload'); + assert(JSON.parse(new TextDecoder().decode(await call('list', '.webfront/developer/staging'))).length === 0, 'Stopped dev must leave no staging'); + }); // Each named entry gets its own relative HTML/assets when building all manifest entries. await writeFile('webfront.project.json', JSON.stringify({...manifest, entries: {one: 'watch/value.ts', two: 'watch/created.ts'}})); await runtime.execute(['build'], context); @@ -129,14 +133,8 @@ try { new TextDecoder().decode(await readFile('.webfront/developer/build/two/app.js')) === secondEntryBuild, 'Failure in a later entry must preserve the entire previous build'); await writeFile('watch/created.ts', "export const value = 'must-not-rebuild';\n"); await writeFile('webfront.project.json', JSON.stringify(manifest)); - await runtime.execute(['embed', 'PiUI'], context); - // Repeat the browser build to prove reproducibility, including licenses and packed gzip bytes. - const first = await webFront.cppFunction('test.header')('PiUI'); - await runtime.execute(['embed', 'ui/main.tsx', '--output', 'generated/PiUI.hpp'], context); - assert(await webFront.cppFunction('test.header')('PiUI') === first, 'Header generation must be deterministic'); - // Keep the original PI regression and exercise the new primary starter in the same engine. - await runtime.execute(['create', 'life', 'life-ui'], context); - await runtime.execute(['preview', 'life-ui/main.tsx'], context); + // Exercise the maintained public application rather than the retired PI demo. + await runtime.execute(['preview'], context); for (let attempt = 0; !frame.contentDocument?.querySelector('[data-testid="pattern-blinker"]'); ++attempt) { if (attempt === 200) throw new Error('Life preview did not mount'); await delay(50); @@ -203,11 +201,18 @@ try { } assert(button('population').textContent === '5', 'C++ glider survives four steps'); assert(life.querySelector('canvas').width > 0 && !life.querySelector('[role="alert"]').textContent, 'Life canvas rendered without errors'); - await runtime.execute(['embed', 'life-ui/main.tsx', '--output', 'generated/LifeUI.hpp'], context); + await runtime.execute(['embed', 'LifeUI'], context); const lifeHeader = await webFront.cppFunction('test.header')('LifeUI'); - await runtime.execute(['embed', 'life-ui/main.tsx', '--output', 'generated/LifeUI.hpp'], context); + await runtime.execute(['embed', 'ui/main.tsx', '--output', 'generated/LifeUI.hpp'], context); assert(await webFront.cppFunction('test.header')('LifeUI') === lifeHeader, 'Life header must be deterministic'); if (!config.registryExplicit) throw new PublicSmokeDone(); + // The application path above needs React DOM. Cache/command regressions do not: keep a small + // real graph instead of repeatedly transferring React DOM's server/development files through the bridge. + manifest.dependencies = {react: '19.3.1', 'webfront-fixture-lib': '1.0.0'}; + await writeFile('webfront.project.json', JSON.stringify(manifest, null, 2)); + await runtime.execute(['install', '--update'], context); + lock = await runtime.readLock(webFront); + assert(Object.keys(lock.packages).length === 2 && !lock.roots['react-dom'], 'Command fixtures must not retain the application dependency graph'); // A dependency added by hand desynchronizes the lock: commands say so and nothing is resolved implicitly. manifest.dependencies.scheduler = '*'; await writeFile('webfront.project.json', JSON.stringify(manifest, null, 2)); @@ -216,7 +221,7 @@ try { assert(refused, 'wf install must not resolve a desynchronized manifest'); delete manifest.dependencies.scheduler; await writeFile('webfront.project.json', JSON.stringify(manifest, null, 2)); - assert(/Installed 3 packages/.test(await runtime.execute(['install'], context)), 'A consistent lock must install its exact graph'); + assert(/Installed 2 packages/.test(await runtime.execute(['install'], context)), 'A consistent lock must install its exact graph'); // wf restore rebuilds an emptied cache from the lock alone, from the application's local registry although the // manifest names another one; --offline only checks the cache, without any request. const requests = []; @@ -232,18 +237,19 @@ try { assert(/react@19\.3\.1 \(missing\)/.test(missing) && requests.length === 0, 'An offline check must list missing packages without any request'); await writeFile('webfront.project.json', JSON.stringify({...manifest, registry: 'https://registry.invalid/'}, null, 2)); const restored = await runtime.execute(['restore'], context); - assert(/Restored 3 of 3 packages/.test(restored) && restored.includes('Registry: /fixtures/registry/ (application option)'), `wf restore must use and name the application registry: ${restored}`); + assert(/Restored 2 of 2 packages/.test(restored) && restored.includes('Registry: /fixtures/registry/ (application option)'), `wf restore must use and name the application registry: ${restored}`); assert(requests.length > 0 && requests.every(url => url.startsWith(`${location.origin}/fixtures/registry/`)), 'wf restore must contact the application registry only'); requests.length = 0; - assert(/Cache verified offline: 3 packages/.test(await runtime.execute(['restore', '--offline'], context)) && requests.length === 0, 'A complete cache must verify offline'); + assert(/Cache verified offline: 2 packages/.test(await runtime.execute(['restore', '--offline'], context)) && requests.length === 0, 'A complete cache must verify offline'); } finally { globalThis.fetch = pageFetch; } await writeFile('webfront.project.json', JSON.stringify(manifest, null, 2)); const previous = frame.contentWindow.location.href; - await runtime.execute(['preview'], context); - const piMounted = () => frame.contentDocument?.querySelector('output') && !frame.contentDocument.querySelector('[data-testid]'); - for (let attempt = 0; frame.contentWindow.location.href === previous || !piMounted(); ++attempt) { + await writeFile('restore/main.js', "import value from 'webfront-fixture-lib'; document.getElementById('root').textContent = value;\n"); + await runtime.execute(['preview', 'restore/main.js'], context); + const restoredMounted = () => frame.contentDocument?.getElementById('root')?.textContent === 'webfront-fixture-lib@1.0.0'; + for (let attempt = 0; frame.contentWindow.location.href === previous || !restoredMounted(); ++attempt) { if (attempt === 300) throw new Error('The preview did not build from the restored cache'); await delay(50); } @@ -277,7 +283,7 @@ try { for (const [path, text] of Object.entries(scripts)) await writeFile(path, text); const mainBefore = await readFile('ui/main.tsx'); const scriptManifest = {...manifest, permissions: {files: ['tools'], publish: ['generated/script']}, - scripts: Object.fromEntries([...Object.keys(scripts).map(path => [path.split('/')[1].split('.')[0], path]), ['listing', 'wf list'], ['nested', 'wf run loop']])}; + scripts: Object.fromEntries([...Object.keys(scripts).map(path => [path.split('/')[1].split('.')[0], path]), ['listing', 'wf list'], ['nested', 'wf run --timeout 120 loop']])}; await writeFile('webfront.project.json', JSON.stringify(scriptManifest, null, 2)); assert(/Script gen completed/.test(await runtime.execute(['run', 'gen', 'a', 'b'], runContext())), 'A TypeScript script must run'); assert(new TextDecoder().decode(await readFile('generated/script/out.txt')) === 'a+b' && scriptOutput.includes('wrote a+b\r\n'), 'The script must write an allowed file and stream its console'); @@ -296,16 +302,26 @@ try { const stopped = await waiting; assert(stopped?.exitCode === 130 && !/grace period/.test(stopped.message), `Ctrl+C must stop a cooperative script: ${stopped}`); const interrupt = new AbortController(); - const started = performance.now(); const looping = failure(runtime.execute(['run', 'loop'], runContext(interrupt.signal))); await printed('looping'); - interrupt.abort(new Error('Interrupted')); - const killed = await looping; - assert(killed?.exitCode === 130 && /terminated after the 2 s grace period/.test(killed.message) && performance.now() - started < 15000, `A busy script must be terminated after Ctrl+C: ${killed}`); - const timedOut = await failure(runtime.execute(['run', '--timeout', '1', 'loop'], runContext())); - assert(timedOut?.exitCode === 124 && /stopped at its time limit/.test(timedOut.message), `The time limit must stop a busy script: ${timedOut}`); - const nested = await failure(runtime.execute(['run', '--timeout', '1', 'nested'], runContext())); - assert(nested?.exitCode === 124, `The time limit must cover a script run through a wf command: ${nested}`); + await withTimers([2000], async clock => { + interrupt.abort(new Error('Interrupted')); + clock.fire(2000); + const killed = await looping; + assert(killed?.exitCode === 130 && /terminated after the 2 s grace period/.test(killed.message), `A busy script must be terminated after Ctrl+C: ${killed}`); + }); + // Real Worker/bridge preparation gets a generous bound; only the deadline under test is advanced. + for (const target of ['loop', 'nested']) { + scriptOutput.length = 0; + await withTimers([60000, 2000], async clock => { + const running = failure(runtime.execute(['run', '--timeout', '60', target], runContext())); + await printed('looping'); + clock.fire(60000); + clock.fire(2000); + const timedOut = await running; + assert(timedOut?.exitCode === 124 && /stopped at its time limit/.test(timedOut.message), `The inherited time limit must stop ${target}: ${timedOut}`); + }); + } assert(/react@19\.3\.1/.test(await runtime.execute(['list'], context)), 'The terminal must stay usable after a termination'); assert(/completed/.test(await runtime.execute(['run', 'unawaited'], runContext())), 'A script that does not await its write must complete'); assert(new TextDecoder().decode(await readFile('generated/script/unawaited.txt')) === 'done', 'A write the script did not await must be applied'); @@ -343,9 +359,28 @@ try { 'check/util.ts': 'export const twice = (value: number): number => 2 * value;\n', }; for (const [path, text] of Object.entries(checkFiles)) await writeFile(path, text); + const packageReads = new Map(); + const checkBridge = {socket: webFront.socket, cppFunction: name => name !== 'webfront.developer.read' ? webFront.cppFunction(name) : + (path, offset) => { + if (!path.startsWith('.webfront/developer/packages/')) return webFront.cppFunction(name)(path, offset); + const key = `${path}:${offset}`; + if (!packageReads.has(key)) { + const reading = webFront.cppFunction(name)(path, offset).catch(error => { + packageReads.delete(key); + throw error; + }); + packageReads.set(key, reading); + } + return packageReads.get(key); + }}; + const retryFile = '.webfront/developer/packages/cache-retry-fixture/probe.txt'; + const retryRead = checkBridge.cppFunction('webfront.developer.read'); + assert(await retryRead(retryFile, 0).then(() => false, () => true), 'The first missing package read must fail'); + await writeFile(retryFile, 'recovered'); + assert(new TextDecoder().decode(await retryRead(retryFile, 0)) === 'recovered', 'A rejected package read must be retried'); const checked = async (args = [], extra = {}) => { scriptOutput.length = 0; - const result = await runtime.execute(['check', ...args], {...runContext(), ...extra}).then(text => ({text}), error => ({error})); + const result = await runtime.execute(['check', ...args], {...runContext(), bridge: checkBridge, ...extra}).then(text => ({text}), error => ({error})); return {...result, output: scriptOutput.join('')}; }; try { @@ -389,23 +424,29 @@ try { const before = [await listing(''), await listing('check')]; const stopCheck = new AbortController(); scriptOutput.length = 0; - const checkStarted = performance.now(); - const longCheck = failure(runtime.execute(['check'], runContext(stopCheck.signal))); + const longCheck = failure(runtime.execute(['check'], {...runContext(stopCheck.signal), bridge: checkBridge})); await printed('Checking 3 root files'); - stopCheck.abort(new Error('Interrupted')); - const checkStopped = await longCheck; - assert(checkStopped?.exitCode === 130 && /Type check stopped by Ctrl\+C \(terminated after the 2 s grace period\)/.test(checkStopped.message) && - performance.now() - checkStarted < 30000, `Ctrl+C must terminate a long check after the grace period: ${checkStopped}`); + await withTimers([2000], async clock => { + stopCheck.abort(new Error('Interrupted')); + clock.fire(2000); + const checkStopped = await longCheck; + assert(checkStopped?.exitCode === 130 && /Type check stopped by Ctrl\+C \(terminated after the 2 s grace period\)/.test(checkStopped.message), + `Ctrl+C must terminate a long check after the grace period: ${checkStopped}`); + }); assert(JSON.stringify([await listing(''), await listing('check')]) === JSON.stringify(before), 'A check must not write any project file'); assert(JSON.parse(await listing('.webfront/developer/staging')).length === 0, 'A check must leave no staged files'); assert(/typescript@6\.0\.3/.test(await runtime.execute(['list'], context)), 'The terminal must stay usable after a stopped check'); // wf test: the specs of the manifest under the locked jasmine-core, in a frame of this page. const testOutput = []; + let testRun = 0; const tested = async (args = [], extra = {}) => { + const label = `wf test #${++testRun} ${args.join(' ')}`; + await webFront.cppFunction('test.progress')(`${label}: starting`); testOutput.length = 0; let report = null; const result = await runtime.execute(['test', ...args], {...runContext(), write: text => testOutput.push(text), onReport: value => { report = value; }, ...extra}) .then(text => ({text}), error => ({error})); + await webFront.cppFunction('test.progress')(`${label}: ${report?.status ?? result.error?.message ?? 'done'}`); return {...result, report, output: testOutput.join('')}; }; const readManifest = async () => JSON.parse(new TextDecoder().decode(await readFile('webfront.project.json'))); @@ -471,46 +512,120 @@ try { const unloaded = await tested(); assert(unloaded.error?.exitCode === 1 && unloaded.report?.status !== 'passed' && /loading boom/.test(unloaded.error.message), `A spec that throws while loading must fail: ${unloaded.error}\n${JSON.stringify(unloaded.report)}`); // A time limit and Ctrl+C end a run that does not return, remove the frame and report it. - await writeFile('tests/hang.spec.js', "describe('hanging', () => {\n it('never ends', () => new Promise(() => {}), 600000);\n});\n"); + const hangingToken = crypto.randomUUID(); + await writeFile('tests/hang.spec.js', `describe('hanging', () => {\n it('never ends', () => {\n` + + ` parent.postMessage({hangingSpec: ${JSON.stringify(hangingToken)}}, location.origin);\n` + + " return new Promise(() => {});\n }, 600000);\n});\n"); await specsOf(['tests/hang.spec.js']); - const hung = await tested(['--timeout', '2']); - 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}`); - assert(!document.querySelector('iframe[title="WebFront tests"]'), 'A timed out run must remove its frame'); + const hangingStarted = () => { + let receive; + const ready = new Promise(resolve => { + receive = event => { + const frame = document.querySelector('iframe[title="WebFront tests"]'); + if (event.origin === location.origin && event.source === frame?.contentWindow && event.data?.hangingSpec === hangingToken) + resolve(); + }; + window.addEventListener('message', receive); + }); + return {ready, dispose: () => window.removeEventListener('message', receive)}; + }; + // Wait for the spec itself: removing a merely inserted frame can interrupt its navigation instead of its run. + await withTimers([60000], async clock => { + const started = hangingStarted(); + try { + const hanging = tested(['--timeout', '60']); + await untilReady(started.ready, hanging); + assert(clock.pending() === 1, 'Only the frame deadline must remain after preparation'); + 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}`); + assert(!document.querySelector('iframe[title="WebFront tests"]'), 'A timed out run must remove its frame'); + } finally { started.dispose(); } + }); const stopTests = new AbortController(); - const interrupted = tested([], {signal: stopTests.signal}); - for (let attempt = 0; !document.querySelector('iframe[title="WebFront tests"]'); ++attempt) { - if (attempt === 300) throw new Error('The runner frame did not appear'); - await delay(30); - } - await delay(300); - stopTests.abort(new Error('Interrupted')); - const interruptedRun = await interrupted; - assert(interruptedRun.error?.exitCode === 130 && interruptedRun.report?.status === 'interrupted' && !document.querySelector('iframe[title="WebFront tests"]'), `Ctrl+C must stop a run: ${interruptedRun.error}`); - // --timeout covers the preparation too: slow project reads cannot hold a run past its limit. - const slowBridge = {socket: webFront.socket, cppFunction: name => name === 'webfront.developer.read' ? - async (...parameters) => { await delay(700); return webFront.cppFunction(name)(...parameters); } : webFront.cppFunction(name)}; + const started = hangingStarted(); + try { + const interrupted = tested([], {signal: stopTests.signal}); + await untilReady(started.ready, interrupted); + stopTests.abort(new Error('Interrupted')); + const interruptedRun = await interrupted; + assert(interruptedRun.error?.exitCode === 130 && interruptedRun.report?.status === 'interrupted' && !document.querySelector('iframe[title="WebFront tests"]'), `Ctrl+C must stop a run: ${interruptedRun.error}`); + } finally { started.dispose(); } + // The command must stop even when the bridge read never settles. Wait for the read, not wall time. + const blockedRead = () => { + let started; + const ready = new Promise(resolve => { started = resolve; }); + const bridge = {socket: webFront.socket, cppFunction: name => name === 'webfront.developer.read' ? + () => { started(); return new Promise(() => {}); } : webFront.cppFunction(name)}; + return {bridge, ready}; + }; await specsOf(['tests/pass.spec.js']); - const slowStarted = performance.now(); - const slowRun = await tested(['--timeout', '1'], {bridge: slowBridge}); - assert(slowRun.error?.exitCode === 124 && slowRun.report?.status === 'timeout' && performance.now() - slowStarted < 20000 && !document.querySelector('iframe[title="WebFront tests"]'), - `The time limit must cover the preparation of a run: ${slowRun.error}`); - // A bridge operation that never returns, Ctrl+C during the build, and a script's deadline: each ends the command. - const stuckBridge = {socket: webFront.socket, cppFunction: name => name === 'webfront.developer.read' ? () => new Promise(() => {}) : webFront.cppFunction(name)}; - const stuckStarted = performance.now(); - const stuck = await tested(['--timeout', '1'], {bridge: stuckBridge}); - assert(stuck.error?.exitCode === 124 && stuck.report?.status === 'timeout' && performance.now() - stuckStarted < 8000, `A blocked bridge operation must not hold the command past its limit: ${stuck.error}`); + await withTimers([60000], async clock => { + const blocked = blockedRead(); + const running = tested(['--timeout', '60'], {bridge: blocked.bridge}); + await untilReady(blocked.ready, running); + clock.fire(60000); + const result = await running; + assert(result.error?.exitCode === 124 && result.report?.status === 'timeout', `A blocked bridge must report the preparation timeout: ${result.error}`); + }); + const blocked = blockedRead(); const interruptPreparing = new AbortController(); - const preparingRun = tested([], {bridge: slowBridge, signal: interruptPreparing.signal}); - await delay(300); + const preparingRun = tested([], {bridge: blocked.bridge, signal: interruptPreparing.signal}); + await untilReady(blocked.ready, preparingRun); interruptPreparing.abort(new Error('Interrupted')); const preparingResult = await preparingRun; - assert(preparingResult.error?.exitCode === 130 && preparingResult.report?.status === 'interrupted', `Ctrl+C during the preparation must end with 130 and a report: ${preparingResult.error}`); + assert(preparingResult.error?.exitCode === 130 && preparingResult.report?.status === 'interrupted', `Ctrl+C during preparation must end with 130 and a report: ${preparingResult.error}`); + // macOS 13.3 supports WKWebView, but its WebKit need not provide AbortSignal.any (Safari 17.4). + const signalAny = Object.getOwnPropertyDescriptor(AbortSignal, 'any'); + Object.defineProperty(AbortSignal, 'any', {configurable: true, value: undefined}); + try { + const legacyPassing = await tested([], {signal: new AbortController().signal}); + assert(legacyPassing.report?.status === 'passed' && legacyPassing.report.exitCode === 0, + `A terminal run must work without AbortSignal.any: ${legacyPassing.error}`); + const alreadyStopped = new AbortController(); + alreadyStopped.abort(new Error('Interrupted')); + const legacyStopped = await tested([], {signal: alreadyStopped.signal}); + assert(legacyStopped.error?.exitCode === 130 && legacyStopped.report?.status === 'interrupted', + `An already aborted signal must report interruption without AbortSignal.any: ${legacyStopped.error}`); + await withTimers([60000], async clock => { + const blocked = blockedRead(); + const running = tested(['--timeout', '60'], {bridge: blocked.bridge, signal: new AbortController().signal}); + await untilReady(blocked.ready, running); + clock.fire(60000); + const result = await running; + assert(result.error?.exitCode === 124 && result.report?.status === 'timeout', + `The preparation deadline must report timeout without AbortSignal.any: ${result.error}`); + }); + const legacyStop = new AbortController(); + const blocked = blockedRead(); + const legacyPreparing = tested([], {bridge: blocked.bridge, signal: legacyStop.signal}); + await untilReady(blocked.ready, legacyPreparing); + legacyStop.abort(new Error('Interrupted')); + const legacyInterrupted = await legacyPreparing; + assert(legacyInterrupted.error?.exitCode === 130 && legacyInterrupted.report?.status === 'interrupted', + `Ctrl+C during preparation must report interruption without AbortSignal.any: ${legacyInterrupted.error}`); + } finally { + if (signalAny) Object.defineProperty(AbortSignal, 'any', signalAny); + else delete AbortSignal.any; + } const withScript = await readManifest(); - await writeFile('webfront.project.json', JSON.stringify({...withScript, scripts: {...withScript.scripts, specs: 'wf test'}}, null, 2)); - const quickBridge = {socket: webFront.socket, cppFunction: name => name === 'webfront.developer.read' ? - async (...parameters) => { await delay(400); return webFront.cppFunction(name)(...parameters); } : webFront.cppFunction(name)}; - const inherited = await runtime.execute(['run', '--timeout', '1', 'specs'], {...runContext(), bridge: quickBridge, onReport: () => {}}).then(() => null, error => error); - assert(inherited?.exitCode === 124, `wf test must keep the deadline of the script that runs it: ${inherited}`); + await writeFile('webfront.project.json', JSON.stringify({...withScript, scripts: {...withScript.scripts, specs: 'wf test --timeout 120'}}, null, 2)); + await withTimers([60000], async clock => { + let started; + const ready = new Promise(resolve => { started = resolve; }); + let reads = 0; + const bridge = {socket: webFront.socket, cppFunction: name => name === 'webfront.developer.read' ? + (...args) => { + // The first manifest/lock pair belongs to wf run; block preparation of its nested wf test. + if (++reads > 2) { started(); return new Promise(() => {}); } + return webFront.cppFunction(name)(...args); + } : webFront.cppFunction(name)}; + const running = runtime.execute(['run', '--timeout', '60', 'specs'], {...runContext(), bridge, onReport: () => {}}).then(() => null, error => error); + await untilReady(ready, running); + clock.fire(60000); + const inherited = await running; + assert(inherited?.exitCode === 124, `wf test must keep the deadline of the script that runs it: ${inherited}`); + }); // Each run publishes its own directory, emptied at the end: runs of two sessions never share files. const runDirectories = JSON.parse(new TextDecoder().decode(await call('list', '.webfront/developer/test'))); assert(runDirectories.length > 1 && runDirectories.every(name => /^[0-9a-f-]{36}\/?$/.test(name)), `Each run must have its own directory: ${runDirectories}`); @@ -575,6 +690,7 @@ try { assert(echoed.join('') === 'after Ctrl+C\r\n', `The next command must run normally: ${echoed}`); assert(['running', 'stopping'].includes(await commandState('first')), 'The second command must answer before the first one ends'); await waitState('first', 'stopping'); + await webFront.cppFunction('test.release')('first'); await waitState('first', 'cancelled'); // Sessions: a second browser has its own commands; a long command there does not delay this one, Ctrl+C here does // not stop it, and its disconnection does. @@ -701,6 +817,7 @@ try { const lingerState = await commandState('terminal'); assert(editor.status === 0 && lastRows(2)[0] === 'next' && ['running', 'stopping'].includes(lingerState), `Ctrl+C must interrupt a C++ command: ${lastRows(3)} ${editor.status} ${lingerState}`); await waitState('terminal', 'stopping'); + await webFront.cppFunction('test.release')('terminal'); // Pasted lines run one after the other; the last one, without a line break, waits on the prompt. // Keys typed one by one while a command runs are applied after it, Enter included. terminal.input('sleep 300\r'); @@ -769,6 +886,7 @@ try { terminal.input('\r'); terminal.input('\x03'); await waitState('replay', 'stopping'); + await webFront.cppFunction('test.release')('replay'); for (let attempt = 0; editor.busy; ++attempt) { if (attempt === 100) throw new Error(`Ctrl+C typed during a completion must interrupt the replayed command: ${lastRows(3)}`); await delay(20); @@ -840,13 +958,13 @@ try { // The application stops while this command runs: its shutdown must drain it (checked in C++). void failure(runtime.runLine('wait final', lineContext())); await waitState('final', 'running'); - await webFront.cppFunction('test.report')(true, 'WASM + npm + TSX + PI + Life animation + deterministic headers + scripts + type check + terminal passed'); + await webFront.cppFunction('test.report')(true, 'WASM + npm + TSX + Life animation + deterministic headers + scripts + type check + terminal passed'); } catch (error) { if (error instanceof PublicSmokeDone) - await webFront.cppFunction('test.report')(true, 'Public distribution: WASM + npm + TSX + PI + Life animation + deterministic headers passed'); + await webFront.cppFunction('test.report')(true, 'Public distribution: WASM + npm + TSX + Life animation + deterministic headers passed'); else { console.error(error); - await webFront.cppFunction('test.report')(false, String(error.stack ?? error)); + await webFront.cppFunction('test.report')(false, `${error.message ?? error}\n${error.stack ?? ''}`); } } finally { setTimeout(() => globalThis.close(), 0); diff --git a/test/web/suite/react-demo/SignalStudio.jsx b/test/web/suite/react-demo/SignalStudio.jsx deleted file mode 100644 index 90058303..00000000 --- a/test/web/suite/react-demo/SignalStudio.jsx +++ /dev/null @@ -1,100 +0,0 @@ -// The Signal Studio example page as a module: the spec renders it with the React of its lock. -import { useState, useEffect } from "react"; -import { flushSync } from "react-dom"; -import { createRoot } from "react-dom/client"; - -function Control({ id, label, value, min, max, step, unit, onChange, disabled }) { - return
- - onChange(Number(event.target.value))} /> -
{min} {unit}{max} {unit}
-
; -} - -function App({ bridge }) { - const [frequency, setFrequency] = useState(4); - const [amplitude, setAmplitude] = useState(0.8); - const [harmonics, setHarmonics] = useState(0.35); - const [samples, setSamples] = useState([]); - const [busy, setBusy] = useState(true); - const [error, setError] = useState(''); - - async function generate() { - setBusy(true); - setError(''); - try { - await bridge.ready; - const values = await bridge.cppFunction('signal.generate')(frequency, amplitude, harmonics); - setSamples(Array.from(values)); - } catch (failure) { - setError(`Could not generate signal: ${failure.message}`); - } finally { - setBusy(false); - } - } - - useEffect(() => { generate(); }, []); - - const peak = samples.reduce((maximum, value) => Math.max(maximum, Math.abs(value)), 0); - const rms = samples.length ? Math.sqrt(samples.reduce((sum, value) => sum + value * value, 0) / samples.length) : 0; - const plotRange = Math.max(1, peak * 1.2); - const path = samples.map((value, index) => `${index ? 'L' : 'M'}${(index / (samples.length - 1) * 640).toFixed(2)},${(120 - value / plotRange * 100).toFixed(2)}`).join(' '); - - return
- -
-
-

The C++ workbench

Signal Studio

Shape a waveform. Let C++ do the maths.

- {samples.length ? 'C++ engine connected' : 'Connecting to C++…'} -
-
-
-
-

Waveform

Generated signal
-
- - - - - - -
0 ms250 ms500 ms750 ms1,000 ms
-
-
Time domain / 1 second{samples.length} samples · Float64
-
-
-
Peak amplitude
{peak.toFixed(3)}V
-
RMS level
{rms.toFixed(3)}V
-
Sample buffer
{samples.length}points
-
-
-
-

Make it your own

Adjust the parameters, then send
them to the C++ engine.

- - - - -

Ordinary C++ functions. Real results.

-
-
- {error &&

{error}

} -
</>

Your application stays C++.

The waveform comes from a C++ callback as a typed array. React takes care of the view.
app.cppFunction("signal.generate", &demo::generateSignal);

-
WEBFRONT / REACT EXAMPLELocal computation · No CDN · No build step for JavaScript
-
-
; -} - -/** Renders the page into `container`; render(bridge) of the result shows it again with another bridge. */ -export function mountSignalStudio(container, bridge) { - const root = createRoot(container); - // Synchronous: the next click already uses the new bridge. - const render = current => flushSync(() => root.render()); - render(bridge); - return { render, unmount: () => root.unmount() }; -} diff --git a/test/web/suite/react-demo/style.css b/test/web/suite/react-demo/style.css deleted file mode 100644 index a0b16c0e..00000000 --- a/test/web/suite/react-demo/style.css +++ /dev/null @@ -1,59 +0,0 @@ -:root { color-scheme: light; font-family: "Segoe UI", system-ui, sans-serif; color: #26352e; background: #f5f4ef; } -* { box-sizing: border-box; } -body { margin: 0; } -button, input { font: inherit; } -button { cursor: pointer; } -button:disabled { cursor: wait; opacity: .6; } -button:focus-visible, input:focus-visible { outline: 3px solid #cc643f; outline-offset: 4px; } -.app { min-height: 100vh; display: grid; grid-template-columns: 174px 1fr; } -aside { padding: 32px 20px 22px; background: #203c32; color: #e7ede6; display: flex; flex-direction: column; } -.brand { font-weight: 650; font-size: 21px; letter-spacing: -.7px; display: flex; align-items: center; gap: 9px; } -.brand-mark { width: 23px; height: 23px; border: 2px solid #b7c9a1; border-radius: 7px 2px 7px 2px; transform: rotate(-8deg); } -.aside-label, .eyebrow { text-transform: uppercase; font-size: 10px; font-weight: 650; letter-spacing: 1.8px; } -.aside-label { margin: 49px 12px 15px; color: #a6b9ad; } -.nav-current { padding: 12px; border-radius: 6px; background: #345044; font-size: 13px; display: flex; gap: 10px; align-items: center; } -.nav-current span { color: #dbab7a; font-size: 20px; } -.aside-bottom { margin-top: auto; padding-top: 40px; font-size: 11px; line-height: 1.9; color: #aec0b3; } -.aside-bottom strong { color: #e4ecdf; font-weight: 500; } -main { padding: 24px 34px 18px; min-width: 0; } -header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; } -.eyebrow { color: #788278; margin: 0 0 8px; } -h1 { font-size: 31px; font-weight: 550; letter-spacing: -1.2px; margin: 0; } -.intro { margin: 8px 0 0; font-size: 12px; color: #748075; } -.connection { font-size: 11px; border: 1px solid #d8dfcf; background: #edf1e7; padding: 8px 12px; border-radius: 20px; white-space: nowrap; } -.dot { display: inline-block; width: 6px; height: 6px; background: #608251; border-radius: 50%; margin-right: 7px; } -.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 238px; gap: 20px; } -.plot-card { background: #fffefa; border: 1px solid #dedfd5; border-radius: 9px; overflow: hidden; } -.panel-heading { padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; } -h2 { margin: 0; font-size: 13px; font-weight: 600; } -.small { font-size: 10px; color: #7a857b; } -.legend { display: flex; align-items: center; gap: 6px; font-size: 10px; color: #798379; } -.legend i { width: 14px; height: 2px; background: #db8b5b; } -.plot { padding: 17px 14px 5px; background: #172d27; } -.plot svg { width: 100%; height: 210px; display: block; overflow: visible; } -.axis { display: flex; justify-content: space-between; padding: 7px 13px 14px; color: #99aca0; font: 9px Consolas, monospace; } -.plot-footer { display: flex; justify-content: space-between; padding: 13px 20px; font-size: 10px; color: #748075; } -.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; } -.metric { background: #fffefa; border: 1px solid #dedfd5; border-radius: 7px; padding: 15px 16px; } -.metric-label { color: #758075; font-size: 10px; margin-bottom: 9px; } -.metric-value { font-size: 25px; font-weight: 500; letter-spacing: -.7px; font-variant-numeric: tabular-nums; } -.metric-value small { font-size: 11px; color: #829080; margin-left: 4px; letter-spacing: 0; } -.settings { background: #eaece2; border: 1px solid #dce0d1; border-radius: 9px; padding: 20px; display: flex; flex-direction: column; } -.settings .small { margin: 8px 0 26px; line-height: 1.6; } -.control { margin-bottom: 22px; } -.control label { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 12px; } -output { color: #455c43; font-variant-numeric: tabular-nums; } -input[type="range"] { width: 100%; margin: 0; accent-color: #60754c; height: 4px; cursor: pointer; } -.range-limits { display: flex; justify-content: space-between; font-size: 9px; color: #8a9382; margin-top: 9px; } -.run { margin-top: auto; width: 100%; background: #284b3a; color: #f3f4e8; border: 0; border-radius: 5px; padding: 12px; font-size: 11px; font-weight: 600; } -.run:hover { background: #365e46; } -.settings-foot { font-size: 9px; color: #7d8876; text-align: center; margin: 11px 0 0; } -.note { margin-top: 20px; border-top: 1px solid #dcdfd2; padding-top: 17px; display: flex; gap: 18px; align-items: center; } -.note-icon { width: 35px; height: 35px; flex-shrink: 0; border: 1px solid #d8ddcf; border-radius: 7px; display: grid; place-items: center; color: #65765b; font: 12px Consolas, monospace; } -.note h2 { font-size: 11px; margin-bottom: 5px; } -.note p { font-size: 10px; color: #7b8577; margin: 0; line-height: 1.7; } -code { font-family: Consolas, monospace; } -footer { display: flex; justify-content: space-between; font-size: 9px; color: #8a9384; margin-top: 24px; gap: 10px; } -.error { color: #a53b27; font-size: 12px; } -@media (max-width: 1050px) { .app { grid-template-columns: 142px 1fr; } main { padding: 24px; } .workspace { grid-template-columns: minmax(0, 1fr) 210px; gap: 14px; } aside { padding: 28px 14px 20px; } } -@media (max-width: 780px) { .app { display: block; } aside { display: none; } .workspace { grid-template-columns: 1fr; } .plot svg { height: 220px; } .settings .small { margin-bottom: 16px; } } diff --git a/test/web/suite/specs/react-demo-specs.mjs b/test/web/suite/specs/react-demo-specs.mjs deleted file mode 100644 index daac6149..00000000 --- a/test/web/suite/specs/react-demo-specs.mjs +++ /dev/null @@ -1,72 +0,0 @@ -import * as React from 'react'; -import { mountSignalStudio } from '../react-demo/SignalStudio.jsx'; -import '../react-demo/style.css'; - -// The page of the Signal Studio example, built by esbuild-wasm with the React of the lock, rendered with the real bridge. -describe('The React signal example', () => { - let container; - let page; - - async function waitFor(predicate) { - const deadline = Date.now() + 4000; - while (!predicate()) { - if (Date.now() > deadline) - throw new Error('React example did not reach the expected state'); - await new Promise(resolve => setTimeout(resolve, 10)); - } - } - - beforeEach(async () => { - container = document.createElement('div'); - document.body.appendChild(container); - page = mountSignalStudio(container, webFront); - await waitFor(() => container.querySelector('.app')?.dataset.state === 'ready'); - }); - - afterEach(() => { - page?.unmount(); - container?.remove(); - }); - - it('renders real C++ samples using the React of the lock', () => { - expect(React.version).toBe('19.3.1'); - expect(container.querySelector('h1').textContent).toBe('Signal Studio'); - expect(container.querySelector('.connection').textContent).toContain('C++ engine connected'); - expect(container.querySelector('.plot-footer').textContent).toContain('256 samples'); - expect(Number.parseFloat(container.querySelector('#rms').textContent)).toBeCloseTo(0.570, 3); - expect(container.querySelector('#signal-path').getAttribute('d').match(/L/g).length).toBe(255); - }); - - it('regenerates the waveform when a parameter changes', async () => { - const initial = container.querySelector('#signal-path').getAttribute('d'); - const frequency = container.querySelector('#frequency'); - // Use the native setter, allowing React to observe the change rather than its value tracker. - Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(frequency, '7'); - frequency.dispatchEvent(new Event('input', {bubbles: true})); - await waitFor(() => container.querySelector('output[for="frequency"]').textContent.includes('7 Hz')); - container.querySelector('.run').click(); - await waitFor(() => container.querySelector('#signal-path').getAttribute('d') !== initial); - expect(container.querySelector('#signal-path').getAttribute('d')).not.toBe(initial); - expect(container.querySelector('.app').dataset.state).toBe('ready'); - }); - - it('handles a rejected call and allows another attempt', async () => { - const initial = container.querySelector('#signal-path').getAttribute('d'); - page.render({ - ready: webFront.ready, - // Deliberately pass an invalid frequency to the real C++ callback. - cppFunction: name => (_frequency, amplitude, harmonics) => webFront.cppFunction(name)(0, amplitude, harmonics), - }); - await waitFor(() => container.querySelector('.run') !== null); - container.querySelector('.run').click(); - await waitFor(() => container.querySelector('.app').dataset.state === 'error'); - expect(container.querySelector('[role="alert"]').textContent).toContain('outside the supported range'); - expect(container.querySelector('.run').disabled).toBeFalse(); - expect(container.querySelector('#signal-path').getAttribute('d')).toBe(initial); - page.render(webFront); - await waitFor(() => container.querySelector('.run') !== null); - container.querySelector('.run').click(); - await waitFor(() => container.querySelector('.app').dataset.state === 'ready'); - expect(container.querySelector('[role="alert"]')).toBeNull(); - }); -}); diff --git a/test/web/suite/specs/webfront-specs.mjs b/test/web/suite/specs/webfront-specs.mjs index 638d784a..39f7770b 100644 --- a/test/web/suite/specs/webfront-specs.mjs +++ b/test/web/suite/specs/webfront-specs.mjs @@ -1,6 +1,5 @@ import './content-policy-specs.mjs'; import { importedValue } from './module-fixture.mjs'; -import './react-demo-specs.mjs'; // The page of the application is covered by the lifecycle cases (path-encoding): these specs run in the frame of wf test. describe('Frontend page URL', () => { @@ -11,6 +10,24 @@ describe('Frontend page URL', () => { expect(response.ok).toBeTrue(); expect(await response.text()).toContain('Plus in a path'); }); + it('injects a C++ script when the handshake completes before the body exists', () => { + const body = document.body; + const text = new TextEncoder().encode('globalThis.earlyInjectedScript = true;'); + const packet = new DataView(new ArrayBuffer(4 + text.length)); + packet.setUint8(0, 2); // TextCommand + packet.setUint8(1, 1); // injectScript + packet.setUint16(2, text.length); + new Uint8Array(packet.buffer, 4).set(text); + try { + body.remove(); + expect(document.body).toBeNull(); + expect(() => webFront.handleTextCommand(packet)).not.toThrow(); + expect(globalThis.earlyInjectedScript).toBeTrue(); + } finally { + document.documentElement.append(body); + delete globalThis.earlyInjectedScript; + } + }); it('runs in the frame of the test runner, served from the origin of the application', () => { expect(location.hostname).toBe('127.0.0.1'); expect(window.parent).not.toBe(window); diff --git a/test/web/suite/webfront.project.json b/test/web/suite/webfront.project.json index f4daa61b..9a1a45ac 100644 --- a/test/web/suite/webfront.project.json +++ b/test/web/suite/webfront.project.json @@ -2,6 +2,6 @@ "format": 1, "name": "webfront-browser-tests", "version": "0.1.0", - "dependencies": {"jasmine-core": "7.0.2", "react": "19.3.1", "react-dom": "19.3.1"}, + "dependencies": {"jasmine-core": "7.0.2"}, "test": {"specs": ["specs/webfront-specs.mjs"]} } diff --git a/webfront.project.json b/webfront.project.json index cc77c8c1..c095bd8f 100644 --- a/webfront.project.json +++ b/webfront.project.json @@ -25,6 +25,7 @@ "test/developer/specs/scripts-specs.mjs", "test/developer/specs/development-specs.mjs", "test/developer/specs/testing-specs.mjs", + "test/developer/specs/timers-specs.mjs", "test/developer/specs/distribution-specs.mjs" ] },