mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 16:22:29 +00:00

Adds a new `../common/fixtures' module to begin normalizing `test/fixtures` use. Our test code is a bit inconsistent with regards to use of the fixtures directory. Some code uses `path.join()`, some code uses string concats, some other code uses template strings, etc. In mnay cases, significant duplication of code is seen when accessing fixture files, etc. This updates many (but by no means all) of the tests in the test suite to use the new consistent API. There are still many more to update, which would make an excelent Code-n-Learn exercise. PR-URL: https://github.com/nodejs/node/pull/14332 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const execFile = require('child_process').execFile;
|
|
const uv = process.binding('uv');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const fixture = fixtures.path('exit.js');
|
|
|
|
{
|
|
execFile(
|
|
process.execPath,
|
|
[fixture, 42],
|
|
common.mustCall((e) => {
|
|
// Check that arguments are included in message
|
|
assert.strictEqual(e.message.trim(),
|
|
`Command failed: ${process.execPath} ${fixture} 42`);
|
|
assert.strictEqual(e.code, 42);
|
|
})
|
|
);
|
|
}
|
|
|
|
{
|
|
// Verify that negative exit codes can be translated to UV error names.
|
|
const errorString = `Error: Command failed: ${process.execPath}`;
|
|
const code = -1;
|
|
const callback = common.mustCall((err, stdout, stderr) => {
|
|
assert.strictEqual(err.toString().trim(), errorString);
|
|
assert.strictEqual(err.code, uv.errname(code));
|
|
assert.strictEqual(err.killed, true);
|
|
assert.strictEqual(err.signal, null);
|
|
assert.strictEqual(err.cmd, process.execPath);
|
|
assert.strictEqual(stdout.trim(), '');
|
|
assert.strictEqual(stderr.trim(), '');
|
|
});
|
|
const child = execFile(process.execPath, callback);
|
|
|
|
child.kill();
|
|
child.emit('close', code, null);
|
|
}
|