mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 14:56:19 +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>
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const spawn = require('child_process').spawn;
|
|
const fs = require('fs');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
if (common.isWindows) {
|
|
if (process.argv[2] === 'child') {
|
|
process.stdin;
|
|
process.stdout;
|
|
process.stderr;
|
|
return;
|
|
}
|
|
const python = process.env.PYTHON || 'python';
|
|
const script = fixtures.path('spawn_closed_stdio.py');
|
|
const proc = spawn(python, [script, process.execPath, __filename, 'child']);
|
|
proc.on('exit', common.mustCall(function(exitCode) {
|
|
assert.strictEqual(exitCode, 0);
|
|
}));
|
|
return;
|
|
}
|
|
|
|
if (process.argv[2] === 'child') {
|
|
[0, 1, 2].forEach((i) => assert.doesNotThrow(() => fs.fstatSync(i)));
|
|
return;
|
|
}
|
|
|
|
// Run the script in a shell but close stdout and stderr.
|
|
const cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`;
|
|
const proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' });
|
|
|
|
proc.on('exit', common.mustCall(function(exitCode) {
|
|
assert.strictEqual(exitCode, 0);
|
|
}));
|