From 9a47792cd1d56694db82176cef814d83d6cd54cb Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 25 May 2024 21:26:36 +0300 Subject: [PATCH] test: skip `test-setproctitle` when `ps` is not available PR-URL: https://github.com/nodejs/node/pull/53104 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-setproctitle.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-setproctitle.js b/test/parallel/test-setproctitle.js index 46288e8156edde..7c4287829f7c0a 100644 --- a/test/parallel/test-setproctitle.js +++ b/test/parallel/test-setproctitle.js @@ -12,7 +12,7 @@ if (!common.isMainThread) common.skip('Setting the process title from Workers is not supported'); const assert = require('assert'); -const exec = require('child_process').exec; +const { exec, execSync } = require('child_process'); const path = require('path'); // The title shouldn't be too long; libuv's uv_set_process_title() out of @@ -28,6 +28,15 @@ assert.strictEqual(process.title, title); if (common.isWindows) common.skip('Windows does not have "ps" utility'); +try { + execSync('command -v ps'); +} catch (err) { + if (err.status === 1) { + common.skip('The "ps" utility is not available'); + } + throw err; +} + // To pass this test on alpine, since Busybox `ps` does not // support `-p` switch, use `ps -o` and `grep` instead. const cmd = common.isLinux ?