@@ -7,11 +7,13 @@ if (process.config.variables.node_builtin_modules_path)
7
7
8
8
const fixtures = require ( '../common/fixtures' ) ;
9
9
const tmpdir = require ( '../common/tmpdir' ) ;
10
- const assert = require ( 'assert' ) ;
11
- const child_process = require ( 'child_process' ) ;
12
10
const path = require ( 'path' ) ;
13
11
const fs = require ( 'fs' ) ;
14
12
const os = require ( 'os' ) ;
13
+ const {
14
+ spawnSyncAndExit,
15
+ spawnSyncAndExitWithoutError
16
+ } = require ( '../common/child_process' ) ;
15
17
16
18
const nodeBinary = process . execPath ;
17
19
@@ -42,30 +44,29 @@ fs.copyFileSync(
42
44
nodeBinary ,
43
45
appExecutablePath ) ;
44
46
45
-
46
47
// Sign the app bundle with sandbox entitlements:
47
- assert . strictEqual (
48
- child_process . spawnSync ( '/usr/bin/codesign' , [
49
- '--entitlements ', fixtures . path (
50
- 'macos-app-sandbox' , 'node_sandboxed.entitlements' ) ,
51
- '--force' , '-s' , '- ',
52
- appBundlePath ,
53
- ] ) . status ,
54
- 0 ) ;
48
+ spawnSyncAndExitWithoutError ( 'codesign' , [
49
+ '--entitlements' ,
50
+ fixtures . path ( 'macos-app-sandbox ', 'node_sandboxed.entitlements' ) ,
51
+ '--force' ,
52
+ '-s ',
53
+ '-' ,
54
+ appBundlePath ,
55
+ ] ) ;
55
56
56
57
// Sandboxed app shouldn't be able to read the home dir
57
- assert . notStrictEqual (
58
- child_process . spawnSync ( appExecutablePath , [
59
- '-e' , 'fs.readdirSync(process.argv[1])' , os . homedir ( ) ,
60
- ] ) . status ,
61
- 0 ) ;
58
+ spawnSyncAndExit (
59
+ appExecutablePath ,
60
+ [ '-e' , 'fs.readdirSync(process.argv[1])' , os . homedir ( ) ] ,
61
+ {
62
+ status : 1 ,
63
+ signal : null ,
64
+ } ,
65
+ ) ;
62
66
63
67
if ( process . stdin . isTTY ) {
64
68
// Run the sandboxed node instance with inherited tty stdin
65
- const spawnResult = child_process . spawnSync (
66
- appExecutablePath , [ '-e' , '' ] ,
67
- { stdio : 'inherit' }
68
- ) ;
69
-
70
- assert . strictEqual ( spawnResult . signal , null ) ;
69
+ spawnSyncAndExitWithoutError ( appExecutablePath , [ '-e' , '' ] , {
70
+ stdio : 'inherit' ,
71
+ } ) ;
71
72
}
0 commit comments