Repository navigation
test: cover deep WASM parses in CI - #19
Conversation
|
Review complete. 🟠 1 high 💬 Inline comments (1)
🧹 Nitpicks (1) — 🟢 1 low
This change introduces a WebAssembly build-and-test workflow on top of the existing CI, plus a C harness that builds a 2000-level nested query and asserts the parser reports its stack-depth limit rather than crashing.
Reviewed commit: e445ed3 |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
This PR adds a CI job compiling the parser to WebAssembly with emsdk and a new test/wasm_depth.c stress test that parses deeply nested queries to validate stack-depth handling.
Key findings
- 🟠 Add
-sEXIT_RUNTIME=1so WASM test exit status propagates — ci.yml:97
| emcc -O3 -sENVIRONMENT=node -sSTACK_SIZE=33554432 -sINITIAL_MEMORY=41943040 \ | ||
| -sALLOW_MEMORY_GROWTH=1 -I. test/wasm_depth.c libpg_query.a -o test/wasm_depth.js | ||
| node test/wasm_depth.js |
There was a problem hiding this comment.
🟠 bug · high
Add -sEXIT_RUNTIME=1 so WASM test exit status propagates
The emcc link command for the WASM depth test omits -sEXIT_RUNTIME=1 (.github/workflows/ci.yml:97). With Emscripten's default EXIT_RUNTIME=0, the runtime does not call exit() after main() returns, so the EXIT_FAILURE returned by test/wasm_depth.c is discarded and the Node process exits with code 0. The new CI job therefore always reports success, even when every depth case fails — the check can never catch a regression.
📋 Prompt for AI Agents
In .github/workflows/ci.yml in the build_wasm job's emcc command (lines 97-99), add -sEXIT_RUNTIME=1 to the flag list. Without it, Emscripten's default EXIT_RUNTIME=0 discards the return value of main() and the Node process exits 0 even when test/wasm_depth.c returns EXIT_FAILURE, so the CI check can never fail.
Add a push and pull-request CI job that builds libpg_query with Emscripten 6.0.3 and runs the generated test under Node. The test requires successful parsing of 2000 chained terms, 1000 nested subqueries, and 2000 nested function calls, and requires a clean stack depth limit error for 100000 chained terms.
Local evidence before opening this PR: