@@ -7,11 +7,10 @@ if (process.config.variables.node_builtin_modules_path)
77
88const fixtures = require ( '../common/fixtures' ) ;
99const tmpdir = require ( '../common/tmpdir' ) ;
10- const assert = require ( 'assert' ) ;
11- const child_process = require ( 'child_process' ) ;
1210const path = require ( 'path' ) ;
1311const fs = require ( 'fs' ) ;
1412const os = require ( 'os' ) ;
13+ const { spawnSyncAndExitWithoutError } = require ( '../common/child_process' ) ;
1514
1615const nodeBinary = process . execPath ;
1716
@@ -42,30 +41,26 @@ fs.copyFileSync(
4241 nodeBinary ,
4342 appExecutablePath ) ;
4443
45-
4644// 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+ ] ) ;
5553
5654// 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+ ] ) ;
6260
6361if ( process . stdin . isTTY ) {
6462 // 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+ } ) ;
7166}
0 commit comments