This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for getting spawn args
- Loading branch information
Showing
3 changed files
with
154 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* IMPORTANT | ||
* This snapshot file is auto-generated, but designed for humans. | ||
* It should be checked into source control and tracked carefully. | ||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests. | ||
* Make sure to inspect the output below. Do not ignore changes! | ||
*/ | ||
'use strict' | ||
exports[`test/get-spawn-args.js TAP > custom windows script shell 1`] = ` | ||
[ | ||
'flerbbyderb', | ||
[ '-c', 'cmd' ], | ||
{ | ||
cwd: '/working/dir', | ||
env: { env: 'iron', men: 'tal' }, | ||
stdio: [ 0, 1, 2 ], | ||
uid: 123, | ||
gid: 432 | ||
} | ||
] | ||
` | ||
|
||
exports[`test/get-spawn-args.js TAP > just basics 1`] = ` | ||
[ | ||
'sh', | ||
[ '-c', 'cmd' ], | ||
{ | ||
cwd: '/working/dir', | ||
env: { env: 'iron', men: 'tal' }, | ||
stdio: [ 0, 1, 2 ], | ||
uid: 123, | ||
gid: 432 | ||
} | ||
] | ||
` | ||
|
||
exports[`test/get-spawn-args.js TAP > stdio and numeric string uid 1`] = ` | ||
[ | ||
'sh', | ||
[ '-c', 'cmd' ], | ||
{ | ||
cwd: '/working/dir', | ||
env: { env: 'iron', men: 'tal' }, | ||
stdio: [ 3, 2, 1 ], | ||
uid: 123, | ||
gid: 432 | ||
} | ||
] | ||
` | ||
|
||
exports[`test/get-spawn-args.js TAP > unsafe numeric string uid 1`] = ` | ||
[ | ||
'sh', | ||
[ '-c', 'cmd' ], | ||
{ | ||
cwd: '/working/dir', | ||
env: { env: 'iron', men: 'tal' }, | ||
stdio: [ 3, 2, 1 ] | ||
} | ||
] | ||
` | ||
|
||
exports[`test/get-spawn-args.js TAP > weird comspec 1`] = ` | ||
[ | ||
'flerbbyderb', | ||
[ '-c', 'cmd' ], | ||
{ | ||
cwd: '/working/dir', | ||
env: { env: 'iron', men: 'tal' }, | ||
stdio: [ 0, 1, 2 ], | ||
uid: 123, | ||
gid: 432 | ||
} | ||
] | ||
` | ||
|
||
exports[`test/get-spawn-args.js TAP > windows 1`] = ` | ||
[ | ||
'CMD.exe', | ||
[ '/d /s /c', 'cmd' ], | ||
{ | ||
cwd: '/working/dir', | ||
env: { env: 'iron', men: 'tal' }, | ||
stdio: [ 0, 1, 2 ], | ||
uid: 123, | ||
gid: 432, | ||
windowsVerbatimArguments: true | ||
} | ||
] | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const t = require('tap') | ||
const getSpawnArgs = require('../')._getSpawnArgs | ||
|
||
// these show up in the result, but aren't forked on | ||
// just set the same for every case. | ||
const cmd = 'cmd' | ||
const wd = '/working/dir' | ||
const env = { env: 'iron', men: 'tal' } | ||
const b = { cmd, wd, env, uid: 123, gid: 432, opts: {} } | ||
|
||
t.matchSnapshot(getSpawnArgs(b), 'just basics') | ||
|
||
t.matchSnapshot(getSpawnArgs(Object.assign({}, b, { | ||
opts: { stdio: [3,2,1] }, | ||
uid: '123' | ||
})), 'stdio and numeric string uid') | ||
|
||
t.matchSnapshot(getSpawnArgs(Object.assign({}, b, { | ||
opts: { stdio: [3,2,1] }, | ||
uid: '123', | ||
unsafe: true | ||
})), 'unsafe numeric string uid') | ||
|
||
process.env.comspec = 'CMD.exe' | ||
t.matchSnapshot(getSpawnArgs(Object.assign({}, b, { | ||
opts: { | ||
_TESTING_FAKE_WINDOWS_: true | ||
} | ||
})), 'windows') | ||
|
||
t.matchSnapshot(getSpawnArgs(Object.assign({}, b, { | ||
opts: { | ||
_TESTING_FAKE_WINDOWS_: true, | ||
scriptShell: 'flerbbyderb' | ||
} | ||
})), 'custom windows script shell') | ||
|
||
process.env.comspec = 'flerbbyderb' | ||
t.matchSnapshot(getSpawnArgs(Object.assign({}, b, { | ||
opts: { | ||
_TESTING_FAKE_WINDOWS_: true | ||
} | ||
})), 'weird comspec') |