Repository navigation
test(v18): state the depth every exported function handles #217
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 7 commits into
main
from
feat/release-diff-reference-release
Nov 26, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
235e11b
ci(release-diff): compare with the 18.1.5 reference release and every…
pyramation c9cfe05
Merge main
pyramation d658ff3
ci(release-diff): upload reports from the hidden report directory
pyramation 0fe6c43
ci(release-diff): name every difference from 18.1.5 and the async res…
pyramation cb115ae
ci(release-diff): name each changed fingerprint and PL/pgSQL fixture …
pyramation 86ca2b7
test(v18): state the depth every exported function handles; keep the …
pyramation d1b28f3
ci: run v18 on Node 22 as an extra job, keeping the Node 20 one
pyramation 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
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,88 @@ | ||
| const { describe, it, before } = require('node:test'); | ||
| const assert = require('node:assert/strict'); | ||
| const lib = require('../wasm/index.cjs'); | ||
|
|
||
| const nest = (open, inner, close) => (n) => open.repeat(n) + inner + close.repeat(n); | ||
| const list = (item, separator) => (n) => Array.from({ length: n }, (_, i) => item(i)).join(separator); | ||
|
|
||
| // The depth each function must handle for each shape of SQL: about half of | ||
| // what 18.1.5 and this build handle on Linux, so a build that loses depth | ||
| // fails here whatever the last release did. Raise a number when the build | ||
| // gains depth; lower one only for a change the release notes describe. | ||
| const SQL = { | ||
| 'chained +': [(n) => 'SELECT 1' + '+1'.repeat(n), { parse: 4000, fingerprint: 5000, normalize: 500 }], | ||
| 'chained ||': [(n) => "SELECT 'a'" + " || 'a'".repeat(n), { parse: 2500, fingerprint: 5000, normalize: 500 }], | ||
| 'chained AND': [(n) => 'SELECT 1 WHERE ' + list(() => 'a = 1', ' AND ')(n), { parse: 5000, fingerprint: 5000, normalize: 5000 }], | ||
| 'chained OR': [(n) => 'SELECT 1 WHERE ' + list(() => 'a = 1', ' OR ')(n), { parse: 5000, fingerprint: 5000, normalize: 5000 }], | ||
| 'chained casts': [(n) => 'SELECT 1' + '::int'.repeat(n), { parse: 2500, fingerprint: 5000, normalize: 1000 }], | ||
| 'chained ->': [(n) => 'SELECT j' + " -> 'a'".repeat(n), { parse: 2500, fingerprint: 5000, normalize: 1000 }], | ||
| 'chained unary minus': [(n) => 'SELECT ' + '- '.repeat(n) + 'a', { parse: 2500, fingerprint: 4000, normalize: 1000 }], | ||
| 'chained NOT': [(n) => 'SELECT ' + 'NOT '.repeat(n) + 'true', { parse: 2500, fingerprint: 4000, normalize: 500 }], | ||
| 'nested parentheses': [(n) => 'SELECT ' + nest('(', '1', ')')(n), { parse: 4000, fingerprint: 4000, normalize: 4000 }], | ||
| 'nested function calls': [(n) => 'SELECT ' + nest('f(', '1', ')')(n), { parse: 2000, fingerprint: 2000, normalize: 500 }], | ||
| 'nested COALESCE': [(n) => 'SELECT ' + nest('COALESCE(', '1', ')')(n), { parse: 2000, fingerprint: 2000, normalize: 500 }], | ||
| 'nested ROW': [(n) => 'SELECT ' + nest('ROW(', '1', ')')(n), { parse: 2000, fingerprint: 2000, normalize: 500 }], | ||
| 'nested arrays': [(n) => 'SELECT ' + nest('ARRAY[', '1', ']')(n), { parse: 2000, fingerprint: 2000, normalize: 500 }], | ||
| 'nested CASE': [(n) => 'SELECT ' + nest('CASE WHEN a THEN ', '1', ' END')(n), { parse: 1000, fingerprint: 1000, normalize: 1000 }], | ||
| 'nested subqueries': [(n) => 'SELECT ' + nest('(SELECT ', '1', ')')(n), { parse: 1000, fingerprint: 1500, normalize: 250 }], | ||
| 'nested FROM subqueries': [(n) => 'SELECT * FROM ' + nest('(SELECT * FROM ', 't', ') s')(n), { parse: 750, fingerprint: 750, normalize: 250 }], | ||
| 'nested CTEs': [(n) => nest('WITH c AS (', 'SELECT 1', ') SELECT * FROM c')(n), { parse: 750, fingerprint: 750, normalize: 250 }], | ||
| 'joins': [(n) => 'SELECT 1 FROM t0' + list((i) => ` JOIN t${i + 1} ON true`, '')(n), { parse: 2500, fingerprint: 5000, normalize: 1000 }], | ||
| 'UNION ALL': [list(() => 'SELECT 1', ' UNION ALL '), { parse: 4000, fingerprint: 5000, normalize: 1000 }], | ||
| 'CTE list': [(n) => 'WITH ' + list((i) => `c${i} AS (SELECT 1)`, ', ')(n) + ' SELECT 1', { parse: 5000, fingerprint: 5000, normalize: 5000 }], | ||
| }; | ||
|
|
||
| const PLPGSQL = { | ||
| 'nested IF blocks': [nest('IF true THEN ', 'NULL;', ' END IF;'), 2000], | ||
| 'nested BEGIN blocks': [nest('BEGIN ', 'NULL;', ' END;'), 2000], | ||
| 'nested loops': [nest('LOOP ', 'EXIT;', ' END LOOP;'), 2000], | ||
| 'nested CASE blocks': [nest('CASE WHEN true THEN ', 'NULL;', ' END CASE;'), 1000], | ||
| 'chained + in an assignment': [(n) => 'x := 1' + '+1'.repeat(n) + ';', 5000], | ||
| }; | ||
| const plpgsql = (body) => | ||
| `CREATE FUNCTION f() RETURNS void LANGUAGE plpgsql AS $$ DECLARE x int; BEGIN ${body} END $$`; | ||
|
|
||
| // Node 20 runs out of stack in fingerprint and normalize at a few dozen | ||
| // levels once V8 has optimized them, on every release including 18.1.5. | ||
| const node20 = Number(process.versions.node.split('.')[0]) < 22 && | ||
| 'Node 20 overflows its stack in optimized fingerprint and normalize code'; | ||
|
|
||
| describe('Depth every exported function handles', { timeout: 300000 }, () => { | ||
| before(async () => { | ||
| await lib.loadModule(); | ||
| }); | ||
|
|
||
| for (const [shape, [make, depth]] of Object.entries(SQL)) { | ||
| it(`parse and parseSync: ${shape}, ${depth.parse} deep`, async () => { | ||
| const sql = make(depth.parse); | ||
| assert.equal(lib.parseSync(sql).stmts.length, 1); | ||
| assert.equal((await lib.parse(sql)).stmts.length, 1); | ||
| }); | ||
|
|
||
| it(`fingerprint and fingerprintSync: ${shape}, ${depth.fingerprint} deep`, { skip: node20 }, async () => { | ||
| const sql = make(depth.fingerprint); | ||
| assert.match(lib.fingerprintSync(sql), /^[0-9a-f]{16}$/); | ||
| assert.match(await lib.fingerprint(sql), /^[0-9a-f]{16}$/); | ||
| }); | ||
|
|
||
| it(`normalize and normalizeSync: ${shape}, ${depth.normalize} deep`, { skip: node20 }, async () => { | ||
| const sql = make(depth.normalize); | ||
| assert.ok(lib.normalizeSync(sql).length > 0); | ||
| assert.ok((await lib.normalize(sql)).length > 0); | ||
| }); | ||
|
|
||
| it(`scan and scanSync: ${shape}, 10000 deep`, async () => { | ||
| const sql = make(10000); | ||
| assert.ok(lib.scanSync(sql).tokens.length > 10000); | ||
| assert.ok((await lib.scan(sql)).tokens.length > 10000); | ||
| }); | ||
| } | ||
|
|
||
| for (const [shape, [make, depth]] of Object.entries(PLPGSQL)) { | ||
| it(`parsePlPgSQL and parsePlPgSQLSync: ${shape}, ${depth} deep`, async () => { | ||
| const sql = plpgsql(make(depth)); | ||
| assert.equal(lib.parsePlPgSQLSync(sql).plpgsql_funcs.length, 1); | ||
| assert.equal((await lib.parsePlPgSQL(sql)).plpgsql_funcs.length, 1); | ||
| }); | ||
| } | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.