From 58dbcb0e9169a5dffd4ab06f353dd4e0d579f866 Mon Sep 17 00:00:00 2001 From: pfg Date: Mon, 31 Mar 2025 19:43:56 -0700 Subject: [PATCH] test-child-process-windows-hide --- .../test-child-process-windows-hide.js | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test/js/node/test/parallel/test-child-process-windows-hide.js diff --git a/test/js/node/test/parallel/test-child-process-windows-hide.js b/test/js/node/test/parallel/test-child-process-windows-hide.js new file mode 100644 index 0000000000..e71adf76f3 --- /dev/null +++ b/test/js/node/test/parallel/test-child-process-windows-hide.js @@ -0,0 +1,38 @@ +// This test is modified to not test node internals, only public APIs. windowsHide is not observable, +// so this only tests that the flag does not cause an error. + +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cp = require('child_process'); +const { test } = require('node:test'); +const cmd = process.execPath; +const args = ['-p', '42']; +const options = { windowsHide: true }; + +test('spawnSync() passes windowsHide correctly', (t) => { + const child = cp.spawnSync(cmd, args, options); + + assert.strictEqual(child.status, 0); + assert.strictEqual(child.signal, null); + assert.strictEqual(child.stdout.toString().trim(), '42'); + assert.strictEqual(child.stderr.toString().trim(), ''); +}); + +test('spawn() passes windowsHide correctly', (t, done) => { + const child = cp.spawn(cmd, args, options); + + child.on('exit', common.mustCall((code, signal) => { + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + done(); + })); +}); + +test('execFile() passes windowsHide correctly', (t, done) => { + cp.execFile(cmd, args, options, common.mustSucceed((stdout, stderr) => { + assert.strictEqual(stdout.trim(), '42'); + assert.strictEqual(stderr.trim(), ''); + done(); + })); +});