test: refactor spawnSync() cwd test
This commit refactors test-child-process-spawnsync.js to use the reusable common.spawnSyncPwd(). PR-URL: https://github.com/nodejs/node/pull/6939 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
dc76afffb6
commit
6bad85c4fd
@ -18,21 +18,13 @@ assert.strictEqual(ret_err.syscall, 'spawnSync command_does_not_exist');
|
|||||||
assert.strictEqual(ret_err.path, 'command_does_not_exist');
|
assert.strictEqual(ret_err.path, 'command_does_not_exist');
|
||||||
assert.deepStrictEqual(ret_err.spawnargs, ['bar']);
|
assert.deepStrictEqual(ret_err.spawnargs, ['bar']);
|
||||||
|
|
||||||
// Verify that the cwd option works - GH #7824
|
{
|
||||||
(function() {
|
// Test the cwd option
|
||||||
var response;
|
const cwd = common.isWindows ? 'c:\\' : '/';
|
||||||
var cwd;
|
const response = common.spawnSyncPwd({cwd});
|
||||||
|
|
||||||
if (common.isWindows) {
|
|
||||||
cwd = 'c:\\';
|
|
||||||
response = spawnSync('cmd.exe', ['/c', 'cd'], {cwd: cwd});
|
|
||||||
} else {
|
|
||||||
cwd = '/';
|
|
||||||
response = spawnSync('pwd', [], {cwd: cwd});
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.strictEqual(response.stdout.toString().trim(), cwd);
|
assert.strictEqual(response.stdout.toString().trim(), cwd);
|
||||||
})();
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Test the encoding option
|
// Test the encoding option
|
||||||
|
Loading…
x
Reference in New Issue
Block a user