Skip to content

Commit 01e4d77

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

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

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

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ if (process.config.variables.node_builtin_modules_path)
77

88
const fixtures = require('../common/fixtures');
99
const tmpdir = require('../common/tmpdir');
10-
const assert = require('assert');
11-
const child_process = require('child_process');
1210
const path = require('path');
1311
const fs = require('fs');
1412
const os = require('os');
13+
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
1514

1615
const 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

6361
if (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

Comments
 (0)