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(text): a harness that had never once been compiled
esengine375fe7fba669
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 69018b697..a03044027 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -31,6 +31,7 @@ env:test_compressed_format test_batch_builder test_boundary_span test_webgpu_devicetest_clip_depth test_shadow_atlastest_text_edit test_render_graph test_device_loss test_physics_interpolation+ test_bitmap_fontjobs:build-emscripten:diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9788dc26d..1b9207479 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -193,6 +193,16 @@ published separately; it ships inside the editor.### Fixed+- **A C++ harness that had never been compiled.** `test_bitmap_font` asserts the+ guard on `BitmapFont::createLabelAtlas` against degenerate dimensions — a+ divide-by-zero that traps on wasm and fills the atlas with garbage where it does+ not — and its own header explained it was left out of CMake because the+ BitmapFont TU references the resource stack. It references exactly two symbols+ from it, through a loader this never calls; the harness stubs them, and it+ builds, runs and passes with the rest. `check-cpp-tests` now also compares the+ harness SOURCES against what CMake declares: it used to compare CI's list with+ CMake's list, and a file neither mentions is invisible to both.+- **Three physics smokes had nothing to run them.** The 2D character mover(resting height, skin width, floor snap, ceiling), the joint and mouse-dragfeatures, and sensor overlap each had a headless smoke sitting in `sdk/tests`diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txtindex 251f310aa..42a554e3c 100644--- a/tests/CMakeLists.txt+++ b/tests/CMakeLists.txt@@ -327,6 +327,20 @@ if(ES_ENABLE_BOX2D)add_test(NAME test_physics_interpolation COMMAND test_physics_interpolation)endif()+# The bitmap-font atlas guard. Compiled in rather than linked, like the shader+# harnesses: BitmapFont's only tie to the resource stack is a loader this never+# calls, and the harness stubs those two symbols itself.+add_executable(test_bitmap_font+ text/test_bitmap_font.cpp+ ${CMAKE_SOURCE_DIR}/src/esengine/text/BitmapFont.cpp+ ${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp+)+target_include_directories(test_bitmap_font PRIVATE+ ${CMAKE_SOURCE_DIR}/src+ ${CMAKE_SOURCE_DIR}/third_party/glm+)+add_test(NAME test_bitmap_font COMMAND test_bitmap_font)+# The desktop text-editing model. It lives in the native host rather than in the# engine, and it is compiled in directly (not linked) because the host is not a# library — which is fine, since the model is pure by construction: no SDL, nodiff --git a/tests/text/test_bitmap_font.cpp b/tests/text/test_bitmap_font.cppindex e7c5b8edf..4e1f35a61 100644--- a/tests/text/test_bitmap_font.cpp+++ b/tests/text/test_bitmap_font.cpp@@ -10,16 +10,19 @@// empty atlas distinguishes fixed-from-unfixed WITHOUT depending on a trap — which// the earlier "did not crash" version did not.//-// Not wired into CMake/CTest: the BitmapFont TU references ResourceManager-// (loadFromFntText), which would drag in the whole resource stack. Run standalone:-// clang++ -std=c++20 -I src -I third_party/glm -Wl,-undefined,dynamic_lookup \-// tests/text/test_bitmap_font.cpp src/esengine/text/BitmapFont.cpp \-// src/esengine/core/Log.cpp -o /tmp/test_bf && /tmp/test_bf-#include "esengine/text/BitmapFont.hpp"+#include "esengine/resource/ResourceManager.hpp"#include <cstdio>+// loadFromFntText is the BitmapFont TU's only tie to the resource stack, and the+// atlas guard under test never calls it. These stubs close the link without+// dragging that stack in.+namespace esengine::resource {+TextureHandle ResourceManager::loadTexture(const std::string&) { return {}; }+Texture* ResourceManager::getTexture(TextureHandle) { return nullptr; }+} // namespace esengine::resource+static int g_failures = 0;#define CHECK(cond, msg) \do { \diff --git a/tools/check-cpp-tests.mjs b/tools/check-cpp-tests.mjsindex b509ba698..eed13df42 100644--- a/tools/check-cpp-tests.mjs+++ b/tools/check-cpp-tests.mjs@@ -20,7 +20,7 @@* shift-left convenience, not a claim about the machine it did not run on.*/import { execFileSync, spawnSync } from 'node:child_process';-import { existsSync, mkdirSync, readFileSync } from 'node:fs';+import { existsSync, mkdirSync, readdirSync, readFileSync } from 'node:fs';import path from 'node:path';import { fileURLToPath } from 'node:url';@@ -44,6 +44,27 @@ function declaredHarnesses() {return [...cmake.matchAll(/add_test\(NAME\s+(\w+)/g)].map((m) => m[1]);}+/**+ * Harnesses compiled on purpose and never run — a link is the whole claim.+ * Anything else on disk with no `add_test` is a harness nobody schedules, which+ * is what both lists above are blind to: they compare two DECLARATIONS.+ */+const COMPILE_ONLY = new Set(['webgpu_bringup', 'webgpu_engine_bringup']);++/** Harness sources on disk, by the name their target would carry. */+function harnessSources() {+ const out = [];+ const walk = (dir) => {+ for (const e of readdirSync(dir, { withFileTypes: true })) {+ const p = path.join(dir, e.name);+ if (e.isDirectory()) walk(p);+ else if (e.name.endsWith('.cpp')) out.push(e.name.replace(/\.cpp$/, ''));+ }+ };+ walk(path.join(ROOT, 'tests'));+ return out;+}+/*** Which cmake options each harness sits behind, from the test tree's own `if()`s.*@@ -95,7 +116,21 @@ const targets = harnessTargets();// The other direction: a harness the test tree declares and CI's list omits is// built by nobody and run by nobody — the failure that list exists to end,// from the side it never looks at. No compiler needed, so this half always runs.-const uncovered = declaredHarnesses().filter((t) => !targets.includes(t));+// A source with no add_test is invisible to both lists — that is how+// test_bitmap_font sat unbuilt for as long as it did.+const declared = declaredHarnesses();+const unscheduled = harnessSources()+ .filter((n) => !declared.includes(n) && !COMPILE_ONLY.has(n))+ // `add_executable(test_ecs ecs/test_registry.cpp)`: a target may be named+ // for what it covers rather than for its file.+ .filter((n) => !readFileSync(path.join(ROOT, 'tests', 'CMakeLists.txt'), 'utf8').includes(`${n}.cpp`));+if (unscheduled.length) {+ console.error(`check-cpp-tests: ${unscheduled.join(', ')} — harness source(s) tests/CMakeLists.txt`+ + ' never builds, so nothing runs them and neither list can see it.');+ process.exit(1);+}++const uncovered = declared.filter((t) => !targets.includes(t));if (uncovered.length) {console.error(`check-cpp-tests: tests/CMakeLists.txt declares ${uncovered.join(', ')},`+ " which build.yml's CPP_TESTS does not name — CI builds and runs neither.");