Skip to content

Commit ecf5c1c

Browse files
cjihrigMyles Borins
authored andcommitted
test: refactor spawnSync() cwd test
This commit refactors test-child-process-spawnsync.js to use the reusable common.spawnSyncPwd(). PR-URL: #6939 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 4ee863d commit ecf5c1c

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

‎test/parallel/test-child-process-spawnsync.js‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,13 @@ assert.strictEqual(ret_err.syscall, 'spawnSync command_does_not_exist');
1818
assert.strictEqual(ret_err.path,'command_does_not_exist');
1919
assert.deepEqual(ret_err.spawnargs,['bar']);
2020

21-
// Verify that the cwd option works - GH #7824
22-
(function(){
23-
varresponse;
24-
varcwd;
25-
26-
if(common.isWindows){
27-
cwd='c:\\';
28-
response=spawnSync('cmd.exe',['/c','cd'],{cwd: cwd});
29-
}else{
30-
cwd='/';
31-
response=spawnSync('pwd',[],{cwd: cwd});
32-
}
21+
{
22+
// Test the cwd option
23+
constcwd=common.isWindows ? 'c:\\' : '/';
24+
constresponse=common.spawnSyncPwd({cwd});
3325

3426
assert.strictEqual(response.stdout.toString().trim(),cwd);
35-
})();
27+
}
3628

3729
{
3830
// Test the encoding option

0 commit comments

Comments
(0)