test: use spawn and spawnPromisified instead of exec

PR-URL: https://github.com/nodejs/node/pull/48991
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This commit is contained in:
Antoine du Hamel 2023-08-05 09:29:53 +02:00 committed by GitHub
parent 556b1ca900
commit a973446b91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 101 additions and 128 deletions

View file

@ -20,8 +20,8 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
require('../common');
const { fixturesDir } = require('../common/fixtures');
const common = require('../common');
const fixtures = require('../common/fixtures');
// Check that the calls to Integer::New() and Date::New() succeed and bail out
// if they don't.
@ -31,11 +31,13 @@ const { fixturesDir } = require('../common/fixtures');
// https://github.com/nodejs/node-v0.x-archive/issues/4015
const assert = require('assert');
const { exec } = require('child_process');
const { spawn } = require('child_process');
const cmd =
`"${process.execPath}" "${fixturesDir}/test-fs-stat-sync-overflow.js"`;
const cp = spawn(process.execPath, [fixtures.path('test-fs-stat-sync-overflow.js')]);
exec(cmd, function(err, stdout, stderr) {
assert.match(stderr, /RangeError: Maximum call stack size exceeded/);
});
const stderr = [];
cp.stderr.on('data', (chunk) => stderr.push(chunk));
cp.on('exit', common.mustCall(() => {
assert.match(Buffer.concat(stderr).toString('utf8'), /RangeError: Maximum call stack size exceeded/);
}));