@@ -7,11 +7,10 @@ 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 { spawnSyncAndExitWithoutError } = require ( '../common/child_process' ) ;
15
14
16
15
const nodeBinary = process . execPath ;
17
16
@@ -42,30 +41,26 @@ fs.copyFileSync(
42
41
nodeBinary ,
43
42
appExecutablePath ) ;
44
43
45
-
46
44
// 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 ) ;
45
+ spawnSyncAndExitWithoutError ( '/usr/bin/codesign' , [
46
+ '--entitlements' ,
47
+ fixtures . path ( 'macos-app-sandbox ', 'node_sandboxed.entitlements' ) ,
48
+ '--force' ,
49
+ '-s ',
50
+ '-' ,
51
+ appBundlePath ,
52
+ ] ) ;
55
53
56
54
// 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 ) ;
55
+ spawnSyncAndExitWithoutError ( appExecutablePath , [
56
+ '-e' ,
57
+ ' fs.readdirSync(process.argv[1])',
58
+ os . homedir ( ) ,
59
+ ] ) ;
62
60
63
61
if ( process . stdin . isTTY ) {
64
62
// 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 ) ;
63
+ spawnSyncAndExitWithoutError ( appExecutablePath , [ '-e' , '' ] , {
64
+ stdio : 'inherit' ,
65
+ } ) ;
71
66
}
0 commit comments