mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
test: refactor common.ddCommand()
* Remove different paths for Windows and POSIX. * Remove fixtures file. Simply run the command immediately/directly. * Since it is never called with more than one value for kilobytes, eliminate that argument. * Update/simplify tests that use this function. (They no longer need to use child_process to run the command.) * Update documentation. PR-URL: https://github.com/nodejs/node/pull/23411 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: George Adams <george.adams@uk.ibm.com>
This commit is contained in:
parent
bcbb9370dd
commit
f897843359
7 changed files with 30 additions and 73 deletions
|
@ -63,34 +63,31 @@ function executeRequest(cb) {
|
|||
|
||||
tmpdir.refresh();
|
||||
|
||||
const ddcmd = common.ddCommand(filename, 10240);
|
||||
common.ddCommand(filename);
|
||||
|
||||
cp.exec(ddcmd, function(err, stdout, stderr) {
|
||||
assert.ifError(err);
|
||||
server = http.createServer(function(req, res) {
|
||||
res.writeHead(200);
|
||||
server = http.createServer(function(req, res) {
|
||||
res.writeHead(200);
|
||||
|
||||
// Create the subprocess
|
||||
const cat = cp.spawn('cat', [filename]);
|
||||
|
||||
// Stream the data through to the response as binary chunks
|
||||
cat.stdout.on('data', (data) => {
|
||||
res.write(data);
|
||||
});
|
||||
|
||||
cat.stdout.on('end', () => res.end());
|
||||
|
||||
// End the response on exit (and log errors)
|
||||
cat.on('exit', (code) => {
|
||||
if (code !== 0) {
|
||||
console.error(`subprocess exited with code ${code}`);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
// Create the subprocess
|
||||
const cat = cp.spawn('cat', [filename]);
|
||||
|
||||
// Stream the data through to the response as binary chunks
|
||||
cat.stdout.on('data', (data) => {
|
||||
res.write(data);
|
||||
});
|
||||
|
||||
server.listen(0, () => {
|
||||
executeRequest(() => server.close());
|
||||
cat.stdout.on('end', () => res.end());
|
||||
|
||||
// End the response on exit (and log errors)
|
||||
cat.on('exit', (code) => {
|
||||
if (code !== 0) {
|
||||
console.error(`subprocess exited with code ${code}`);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
server.listen(0, () => {
|
||||
executeRequest(() => server.close());
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue