summaryrefslogtreecommitdiff
path: root/test/common
diff options
context:
space:
mode:
authorRefael Ackermann <refack@gmail.com>2018-08-25 12:23:53 -0400
committerRefael Ackermann <refack@gmail.com>2018-08-29 17:32:13 -0400
commit8569f4a4178d1a114a95aabcb27cb30cb265e621 (patch)
tree7593ce9d3e386b79f5e64f800211b90ffa977fee /test/common
parent6a689c8aa3ef3bf517cc86807406b9a8958d4ffb (diff)
downloadnode-new-8569f4a4178d1a114a95aabcb27cb30cb265e621.tar.gz
test: refacor spawn[Sync]Pwd
* extract the gist into common.pwdCommand * Merge test-child-process-buffering.js into test-child-process-stdio.js PR-URL: https://github.com/nodejs/node/pull/22522 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test/common')
-rw-r--r--test/common/README.md23
-rw-r--r--test/common/index.js20
2 files changed, 15 insertions, 28 deletions
diff --git a/test/common/README.md b/test/common/README.md
index 36f3afb5c9..28d9bd04f0 100644
--- a/test/common/README.md
+++ b/test/common/README.md
@@ -317,6 +317,17 @@ A port number for tests to use if one is needed.
Logs '1..0 # Skipped: ' + `msg`
+### pwdCommand
+* [&lt;array>] First two argument for the `spawn`/`exec` functions.
+
+Platform normalized `pwd` command options. Usage example:
+```js
+const common = require('../common');
+const { spawn } = require('child_process');
+
+spawn(...common.pwdCommand, { stdio: ['pipe'] });
+```
+
### rootDir
* [&lt;string>]
@@ -350,18 +361,6 @@ was disabled at compile time.
Skip the rest of the tests in the current file when the Node.js executable
was compiled with a pointer size smaller than 64 bits.
-### spawnPwd(options)
-* `options` [&lt;Object>]
-* return [&lt;Object>]
-
-Platform normalizes the `pwd` command.
-
-### spawnSyncPwd(options)
-* `options` [&lt;Object>]
-* return [&lt;Object>]
-
-Synchronous version of `spawnPwd`.
-
## ArrayStream Module
The `ArrayStream` module provides a simple `Stream` that pushes elements from
diff --git a/test/common/index.js b/test/common/index.js
index 18f102c5c3..6f37cb734a 100644
--- a/test/common/index.js
+++ b/test/common/index.js
@@ -26,7 +26,7 @@ const path = require('path');
const fs = require('fs');
const assert = require('assert');
const os = require('os');
-const { exec, execSync, spawn, spawnSync } = require('child_process');
+const { exec, execSync, spawnSync } = require('child_process');
const util = require('util');
const { fixturesDir } = require('./fixtures');
const tmpdir = require('./tmpdir');
@@ -268,22 +268,10 @@ exports.ddCommand = function(filename, kilobytes) {
};
-exports.spawnPwd = function(options) {
- if (exports.isWindows) {
- return spawn('cmd.exe', ['/d', '/c', 'cd'], options);
- } else {
- return spawn('pwd', [], options);
- }
-};
-
+exports.pwdCommand = exports.isWindows ?
+ ['cmd.exe', ['/d', '/c', 'cd']] :
+ ['pwd', []];
-exports.spawnSyncPwd = function(options) {
- if (exports.isWindows) {
- return spawnSync('cmd.exe', ['/d', '/c', 'cd'], options);
- } else {
- return spawnSync('pwd', [], options);
- }
-};
exports.platformTimeout = function(ms) {
if (process.features.debug)