Skip to content

Commit 3871b83

Browse files
committed
test: use spawnSyncAndExitWithoutError()
Use `spawnSyncAndExitWithoutError()` in `test/parallel/test-macos-app-sandbox.js`. Refs: #54802 (comment)
1 parent dc5d0f9 commit 3871b83

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

test/parallel/test-macos-app-sandbox.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const child_process = require('child_process');
1212
const path = require('path');
1313
const fs = require('fs');
1414
const os = require('os');
15+
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
1516

1617
const nodeBinary = process.execPath;
1718

@@ -42,30 +43,26 @@ fs.copyFileSync(
4243
nodeBinary,
4344
appExecutablePath);
4445

45-
4646
// 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);
47+
spawnSyncAndExitWithoutError('/usr/bin/codesign', [
48+
'--entitlements',
49+
fixtures.path('macos-app-sandbox', 'node_sandboxed.entitlements'),
50+
'--force',
51+
'-s',
52+
'-',
53+
appBundlePath,
54+
]);
5555

5656
// 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);
57+
spawnSyncAndExitWithoutError(appExecutablePath, [
58+
'-e',
59+
'fs.readdirSync(process.argv[1])',
60+
os.homedir(),
61+
]);
6262

6363
if (process.stdin.isTTY) {
6464
// 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);
65+
spawnSyncAndExitWithoutError(appExecutablePath, ['-e', ''], {
66+
stdio: 'inherit',
67+
});
7168
}

0 commit comments

Comments
 (0)