From ec6e6b534c2e44201e6437d448d891b6305f760a Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 19 Dec 2024 18:11:19 +0100 Subject: [PATCH] test: make `test-permission-sqlite-load-extension` more robust MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/56295 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca Reviewed-By: Michaƫl Zasso Reviewed-By: Xuguang Mei --- .../test-permission-sqlite-load-extension.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-permission-sqlite-load-extension.js b/test/parallel/test-permission-sqlite-load-extension.js index 28d750d0cd0..1e6f7426ed9 100644 --- a/test/parallel/test-permission-sqlite-load-extension.js +++ b/test/parallel/test-permission-sqlite-load-extension.js @@ -1,18 +1,16 @@ 'use strict'; const common = require('../common'); const assert = require('node:assert'); -const childProcess = require('child_process'); const code = `const sqlite = require('node:sqlite'); const db = new sqlite.DatabaseSync(':memory:', { allowExtension: true }); db.loadExtension('nonexistent');`.replace(/\n/g, ' '); -childProcess.exec( - `${process.execPath} --permission -e "${code}"`, - {}, - common.mustCall((err, _, stderr) => { - assert.strictEqual(err.code, 1); - assert.match(stderr, /Error: Cannot load SQLite extensions when the permission model is enabled/); - assert.match(stderr, /code: 'ERR_LOAD_SQLITE_EXTENSION'/); - }) -); +common.spawnPromisified( + process.execPath, + ['--permission', '--eval', code], +).then(common.mustCall(({ code, stderr }) => { + assert.match(stderr, /Error: Cannot load SQLite extensions when the permission model is enabled/); + assert.match(stderr, /code: 'ERR_LOAD_SQLITE_EXTENSION'/); + assert.strictEqual(code, 1); +}));