Skip to content

Commit c1627e9

Browse files
committed
test: make test-permission-sqlite-load-extension more robust
PR-URL: #56295 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Xuguang Mei <[email protected]>
1 parent 4c978b4 commit c1627e9

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
'use strict';
22
const common = require('../common');
33
const assert = require('node:assert');
4-
const childProcess = require('child_process');
54

65
const code = `const sqlite = require('node:sqlite');
76
const db = new sqlite.DatabaseSync(':memory:', { allowExtension: true });
87
db.loadExtension('nonexistent');`.replace(/\n/g, ' ');
98

10-
childProcess.exec(
11-
`${process.execPath} --permission -e "${code}"`,
12-
{},
13-
common.mustCall((err, _, stderr) => {
14-
assert.strictEqual(err.code, 1);
15-
assert.match(stderr, /Error: Cannot load SQLite extensions when the permission model is enabled/);
16-
assert.match(stderr, /code: 'ERR_LOAD_SQLITE_EXTENSION'/);
17-
})
18-
);
9+
common.spawnPromisified(
10+
process.execPath,
11+
['--permission', '--eval', code],
12+
).then(common.mustCall(({ code, stderr }) => {
13+
assert.match(stderr, /Error: Cannot load SQLite extensions when the permission model is enabled/);
14+
assert.match(stderr, /code: 'ERR_LOAD_SQLITE_EXTENSION'/);
15+
assert.strictEqual(code, 1);
16+
}));

0 commit comments

Comments
 (0)