From 3871b837dbdcaa9dae2fe48f7171f71a17c37539 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Thu, 9 Jan 2025 08:35:35 +0100 Subject: [PATCH] test: use spawnSyncAndExitWithoutError() Use `spawnSyncAndExitWithoutError()` in `test/parallel/test-macos-app-sandbox.js`. Refs: https://github.com/nodejs/node/pull/54802#discussion_r1747327358 --- test/parallel/test-macos-app-sandbox.js | 37 ++++++++++++------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/test/parallel/test-macos-app-sandbox.js b/test/parallel/test-macos-app-sandbox.js index 60ad67b3db3790b..65e8a958ddde243 100644 --- a/test/parallel/test-macos-app-sandbox.js +++ b/test/parallel/test-macos-app-sandbox.js @@ -12,6 +12,7 @@ const child_process = require('child_process'); const path = require('path'); const fs = require('fs'); const os = require('os'); +const { spawnSyncAndExitWithoutError } = require('../common/child_process'); const nodeBinary = process.execPath; @@ -42,30 +43,26 @@ fs.copyFileSync( nodeBinary, appExecutablePath); - // Sign the app bundle with sandbox entitlements: -assert.strictEqual( - child_process.spawnSync('/usr/bin/codesign', [ - '--entitlements', fixtures.path( - 'macos-app-sandbox', 'node_sandboxed.entitlements'), - '--force', '-s', '-', - appBundlePath, - ]).status, - 0); +spawnSyncAndExitWithoutError('/usr/bin/codesign', [ + '--entitlements', + fixtures.path('macos-app-sandbox', 'node_sandboxed.entitlements'), + '--force', + '-s', + '-', + appBundlePath, +]); // Sandboxed app shouldn't be able to read the home dir -assert.notStrictEqual( - child_process.spawnSync(appExecutablePath, [ - '-e', 'fs.readdirSync(process.argv[1])', os.homedir(), - ]).status, - 0); +spawnSyncAndExitWithoutError(appExecutablePath, [ + '-e', + 'fs.readdirSync(process.argv[1])', + os.homedir(), +]); if (process.stdin.isTTY) { // Run the sandboxed node instance with inherited tty stdin - const spawnResult = child_process.spawnSync( - appExecutablePath, ['-e', ''], - { stdio: 'inherit' } - ); - - assert.strictEqual(spawnResult.signal, null); + spawnSyncAndExitWithoutError(appExecutablePath, ['-e', ''], { + stdio: 'inherit', + }); }