Repository navigation
test: cover deep WASM parses in CI #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
devin-ai-integration
merged 1 commit into
18-constructive
from
devin/1795664405-wasm-depth-ci
Nov 26, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #include <pg_query.h> | ||
|
|
||
| #include <stdbool.h> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
|
|
||
| static bool check_depth(const char *name, const char *open, int depth, | ||
| bool nested, bool expect_error) | ||
| { | ||
| const char prefix[] = "SELECT "; | ||
| size_t open_len = strlen(open); | ||
| char *query = malloc(sizeof(prefix) + depth * (open_len + nested) + 1); | ||
| if (query == NULL) | ||
| { | ||
| fprintf(stderr, "FAIL %s: could not allocate query\n", name); | ||
| return false; | ||
| } | ||
|
|
||
| char *p = query; | ||
| memcpy(p, prefix, sizeof(prefix) - 1); | ||
| p += sizeof(prefix) - 1; | ||
| for (int i = 0; i < depth; i++) | ||
| { | ||
| memcpy(p, open, open_len); | ||
| p += open_len; | ||
| } | ||
| *p++ = '1'; | ||
| if (nested) | ||
| { | ||
| memset(p, ')', depth); | ||
| p += depth; | ||
| } | ||
| *p = '\0'; | ||
|
|
||
| PgQueryParseResult result = pg_query_parse(query); | ||
| const char *error = result.error ? result.error->message : NULL; | ||
| bool ok = expect_error ? error && strcmp(error, "stack depth limit exceeded") == 0 | ||
| : result.error == NULL && result.parse_tree != NULL; | ||
| if (ok) | ||
| printf("PASS %s: %s\n", name, expect_error ? error : "parsed successfully"); | ||
| else | ||
| fprintf(stderr, "FAIL %s: expected %s, got %s\n", name, | ||
| expect_error ? "stack depth limit exceeded" : "a parse tree", | ||
| error ? error : result.parse_tree ? "a parse tree" : "no parse tree"); | ||
|
|
||
| pg_query_free_parse_result(result); | ||
| free(query); | ||
| return ok; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| int status = EXIT_SUCCESS; | ||
| if (!check_depth("2000 chained terms", "1+", 1999, false, false)) | ||
| status = EXIT_FAILURE; | ||
| if (!check_depth("1000 nested subqueries", "(SELECT ", 1000, true, false)) | ||
| status = EXIT_FAILURE; | ||
| if (!check_depth("2000 nested function calls", "f(", 2000, true, false)) | ||
| status = EXIT_FAILURE; | ||
| if (!check_depth("100000 chained terms", "1+", 99999, false, true)) | ||
| status = EXIT_FAILURE; | ||
| return status; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 bug · high
Add
-sEXIT_RUNTIME=1so WASM test exit status propagatesThe
emcclink command for the WASM depth test omits-sEXIT_RUNTIME=1(.github/workflows/ci.yml:97). With Emscripten's defaultEXIT_RUNTIME=0, the runtime does not callexit()aftermain()returns, so theEXIT_FAILUREreturned bytest/wasm_depth.cis 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=1to 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.