A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
test(physics): three smokes nobody scheduled
esenginee00ab484e5f2
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 1db0ea11d..69018b697 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -219,6 +219,11 @@ jobs:ESTELLA_REQUIRE_WASM: '1'run: node tools/check-physics3d.mjs+ - name: Check the 2D physics module+ env:+ ESTELLA_REQUIRE_WASM: '1'+ run: node tools/check-physics2d.mjs+- name: Check performance snapshotenv:ESENGINE_WASM_DIR: ${{ github.workspace }}/build/wasm/webdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex c14dea19e..9788dc26d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -193,6 +193,16 @@ published separately; it ships inside the editor.### Fixed+- **Three physics smokes had nothing to run them.** The 2D character mover+ (resting height, skin width, floor snap, ceiling), the joint and mouse-drag+ features, and sensor overlap each had a headless smoke sitting in `sdk/tests`+ that no gate, script or workflow scheduled — 30 assertions against the real+ wasm, none of them ever asked. They all pass, which is the point: nothing was+ checking, so the day they stopped passing would have been a day nobody noticed.+ New gate `check-physics2d` runs them, in CI where the binary is. It also+ refuses a smoke that no gate names, so the same hole cannot reopen by someone+ adding a fourth file.+- **2D shadows had no pixel criterion at all.** Four fixture scenes exercise`ShadowCaster2D` — a hard point-light shadow, a soft one, a directional one —and nothing drove any of them: the criteria that once did are gone, and thediff --git a/tools/check-physics2d.mjs b/tools/check-physics2d.mjsnew file mode 100644index 000000000..9518f45b6--- /dev/null+++ b/tools/check-physics2d.mjs@@ -0,0 +1,73 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file check-physics2d.mjs — the 2D physics module does what a world should.+ *+ * Three smokes sat in sdk/tests with nothing to schedule them: the character+ * mover (resting height, skin width, floor snap, ceiling), the joint and mouse+ * features, and sensor overlap. They pass — which is the point. Nothing was+ * checking, so the day they stop passing would have been a day nobody noticed.+ *+ * The last check here is on the SET: a smoke this file does not name, and no+ * other gate runs, fails — the hole this gate exists to close cannot reopen by+ * someone adding a fourth file.+ *+ * node tools/check-physics2d.mjs+ */+import { spawnSync } from 'node:child_process';+import { existsSync, readdirSync, readFileSync } from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');+const TESTS = path.join(ROOT, 'sdk', 'tests');+const WASM = path.join(ROOT, 'build', 'wasm', 'web', 'physics.wasm');++/** The smokes this gate schedules, and the module each needs. */+const SMOKES = ['mover-smoke.mjs', 'physics-features-smoke.mjs', 'sensor-smoke.mjs'];++// Every smoke has to be scheduled by SOMEONE. Others run elsewhere (the 3D one+// is check-physics3d's), so a file is only orphaned when no gate names it.+const gateText = readdirSync(path.join(ROOT, 'tools'))+ .filter((f) => f.startsWith('check-') && f.endsWith('.mjs') && f !== 'check-physics2d.mjs')+ .map((f) => readFileSync(path.join(ROOT, 'tools', f), 'utf8'))+ .join('\n');+const orphans = readdirSync(TESTS)+ .filter((f) => f.endsWith('-smoke.mjs'))+ .filter((f) => !SMOKES.includes(f) && !gateText.includes(f));+if (orphans.length > 0) {+ console.error('Smoke tests nothing schedules:\n');+ for (const o of orphans) console.error(` sdk/tests/${o}`);+ console.error('\nAdd it to SMOKES here, or to the gate that owns its module. A smoke'+ + ' nobody runs passes until the day it matters.');+ process.exit(1);+}++// An unbuilt module is not a failed behaviour. The job that HAS the binary sets+// ESTELLA_REQUIRE_WASM, so a build that stops arriving there fails rather than+// skipping quietly.+if (!existsSync(WASM)) {+ if (process.env.ESTELLA_REQUIRE_WASM) {+ console.error('check-physics2d: ESTELLA_REQUIRE_WASM is set but build/wasm/web/physics.wasm is absent.\n');+ console.error(' node build-tools/cli.js build -t physics');+ process.exit(1);+ }+ console.log('check-physics2d: build/wasm/web/physics.wasm is not built — skipped'+ + ' (build it with `node build-tools/cli.js build -t physics`; CI sets ESTELLA_REQUIRE_WASM).');+ process.exit(0);+}++let total = 0;+for (const smoke of SMOKES) {+ const run = spawnSync(process.execPath, [path.join(TESTS, smoke)], { cwd: ROOT, encoding: 'utf8' });+ if (run.status !== 0) {+ console.error(run.stdout ?? '');+ console.error(run.stderr ?? '');+ console.error(`\ncheck-physics2d: ${smoke} — the 2D world did not behave as it says.`);+ process.exit(1);+ }+ total += (run.stdout.match(/^PASS/gm) ?? []).length;+}++console.log(`check-physics2d: ${total} behaviour(s) hold across ${SMOKES.length} smoke(s)`+ + ' — mover rest/skin/snap/ceiling, joints and the mouse drag, sensor overlap.');diff --git a/tools/gates.mjs b/tools/gates.mjsindex 5c51c65fb..57b98932a 100644--- a/tools/gates.mjs+++ b/tools/gates.mjs@@ -119,6 +119,12 @@ export const GATES = [{ id: 'release-metadata', run: 'node tools/check-release-metadata.mjs' },{ id: 'shipped-resources', run: 'node tools/check-shipped-resources.mjs', needs: 'editor' },{ id: 'golden', run: 'node tools/check-golden.mjs' },+ {+ id: 'physics2d',+ run: 'node tools/check-physics2d.mjs',+ where: 'local',+ why: 'it runs the built 2D physics wasm and skips a machine without one; the engine-coupled CI job runs it where the binary is, under ESTELLA_REQUIRE_WASM',+ },{id: 'physics3d',run: 'node tools/check-physics3d.mjs',