Fix CI
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sindre Sorhus · committed by Sindre Sorhus · parent 1cee524 · Browse files · 6 files·+31 added−11 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+31 added−11 removed
- tests:+31 added−11 removed
Provenance
- Commit
cfac59f- Tree
fd78ded- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
1cee524
6 files changed+31 added−11 removed
modified:test/arguments/prototype-pollution.js+5 added-2 removed
16 unmodified lines17 18 setFixtureDirectory();19 process.env.FOO = 'foo';20 21+const isWindows = process.platform === 'win32';22+23 /*24 A polluted `Object.prototype` must not inject option values. Otherwise, any prototype pollution elsewhere in the process would let an attacker redirect the command, its input or its output.25 Options are therefore always kept on null-prototype objects.26 Those tests must run one at a time since they temporarily modify `Object.prototype`.161 unmodified lines188 test('Polluted environment variables are ignored, sync', t => testPollutedEnvironment(t, execaSync, {}));189 test('Polluted environment variables are ignored, extendEnv false', t => testPollutedEnvironment(t, execa, {extendEnv: false}));190 test('Polluted environment variables are ignored, preferLocal', t => testPollutedEnvironment(t, execa, {preferLocal: true}));191 192+// On Windows, libuv always passes the current process' `PATH` to the subprocess when its environment has none193 const testPollutedPath = async (t, execaMethod) => {194 pollutePrototype(t, {[PATH_KEY]: POLLUTED_LOCAL_DIRECTORY});195 196 const {stdout} = await execaMethod(process.execPath, printPath, {extendEnv: false});194- assert.equal(stdout, 'undefined');197+ assert.equal(stdout, isWindows ? process.env[PATH_KEY] : 'undefined');198 };199 200 test('Polluted PATH is ignored', t => testPollutedPath(t, execa));201 test('Polluted PATH is ignored, sync', t => testPollutedPath(t, execaSync));54 unmodified lines256 // A subprocess which failed to spawn has no output, which must not read its `error` from the prototype257 test('Polluted "error" is ignored, sync early error', t => {258 pollutePrototype(t, {error: foobarString});259 257- const {code} = execaSync('non-existent-command', {reject: false});260+ const {code} = execaSync('empty.js', {cwd: 'does_not_exist', reject: false});261 assert.equal(code, 'ENOENT');262 });263 264 // Without `lines`, the output has no `finalResult` property, which must not be read from the prototype6 unmodified linesadded:test/fixtures/stdin-fds.js+8 added
12345678#!/usr/bin/env nodeimport process from 'node:process';import {text} from 'node:stream/consumers';import {getReadStream} from '../helpers/fs.js';
// Every file descriptor is read fully, since exiting with unread data in one of them makes the parent fail with `ECONNRESET` on Linuxconst contents = await Promise.all(process.argv.slice(2).map(fdNumber => text(getReadStream(Number(fdNumber)))));process.stdout.write(contents.join(''));modified:test/io/max-buffer.js+1 added-1 removed
346 unmodified lines347 });348 349 test('maxBuffer.stderr is not reported on spawn errors, sync', () => {350 const {code, isMaxBuffer} = assertThrows(() => {351- execaSync('non-existent-command', {maxBuffer: {stderr: 1}});351+ execaSync('empty.js', {cwd: 'does_not_exist', maxBuffer: {stderr: 1}});352 });353 assert.equal(code, 'ENOENT');354 assert.equal(isMaxBuffer, false);355 });163 unmodified linesmodified:test/methods/template.js+9 added-1 removed
1 import assert from 'node:assert/strict';2+import process from 'node:process';3 import test from 'node:test';4 import {assertThrows} from '../helpers/assert.js';5 import {$} from '../../index.js';6 import {setFixtureDirectory} from '../helpers/fixtures-directory.js';7+import {majorNodeVersion} from '../helpers/node-version.js';8 9 setFixtureDirectory();10 11+const isWindows = process.platform === 'win32';12+13 // Workaround since some text editors or IDEs do not allow inputting \r directly14 const escapedCall = string => {15 const templates = [string];16 templates.raw = [string];254 unmodified lines271 test('$ splits expressions - \\u{1F600}', () => testScriptStdout(() => $`echo.js ${'a'}\u{1F600}${'b'}`, 'a\u{1F600}b'));272 test('$ concatenates tokens - \\u{1F600}', () => testScriptStdout(() => $`echo.js \u{1F600}a\u{1F600} b`, '\u{1F600}a\u{1F600}\nb'));273 test('$ concatenates expressions - \\u{1F600}', () => testScriptStdout(() => $`echo.js \u{1F600}${'a'}\u{1F600} b`, '\u{1F600}a\u{1F600}\nb'));274 test('$ handles multiple tokens - \\u{1F600}', () => testScriptStdout(() => $`echo.js \u{1F600}\u{1F600} b c`, '\u{1F600}\u{1F600}\nb\nc'));275+// Node.js 22 aborts when spawning with that code point on Windows, due to a libuv bug fixed in Node.js 24276+if (!isWindows || majorNodeVersion >= 24) {271-test('$ handles the highest code point - \\u{10FFFF}', () => testScriptStdout(() => $`echo.js \u{10FFFF} b`, '\u{10FFFF}\nb'));277+ test('$ handles the highest code point - \\u{10FFFF}', () => testScriptStdout(() => $`echo.js \u{10FFFF} b`, '\u{10FFFF}\nb'));278+}279+280 // The BMP boundary is the exact point where the character count changes281 test('$ handles the last BMP code point - \\u{FFFF}', () => testScriptStdout(() => $`echo.js \u{FFFF} b`, '\u{FFFF}\nb'));282 test('$ handles the first astral code point - \\u{10000}', () => testScriptStdout(() => $`echo.js \u{10000} b`, '\u{10000}\nb'));283 test('$ handles tokens - \\u{0063}}', () => testScriptStdout(() => $`echo.js \u{0063}}`, 'c}'));111 unmodified linesmodified:test/return/early-error.js+4 added-3 removed
27 unmodified lines28 29 const isWindows = process.platform === 'win32';30 const ENOENT_REGEXP = isWindows ? /failed with exit code 1/ : /spawn.* ENOENT/;31 32-// A nonexistent command fails asynchronously, so it does not go through the early error path, but the subprocess still has no process to signal33-test('kill() does not signal the current process when the command does not exist', async () => {34- const subprocess = execa('nonexistent-command-for-execa');32+// A nonexistent `cwd` fails asynchronously, so it does not go through the early error path, but the subprocess still has no process to signal.33+// A nonexistent command cannot be used, since it is run by `cmd.exe` on Windows.34+test('kill() does not signal the current process when the cwd does not exist', async () => {35+ const subprocess = execa('empty.js', {cwd: 'does_not_exist'});36 assert.equal(subprocess.pid, undefined);37 assert.equal(subprocess.kill(), false);38 const {code} = await assertRejects(subprocess);39 assert.equal(code, 'ENOENT');263 unmodified linesmodified:test/stdio/web-stream.js+4 added-4 removed
101 unmodified linesExpand all102103104105106107106107108109110111110111101 unmodified linesExpand all// A web stream can only be used once, but like Node.js streams, the same instance// passed to multiple file descriptors should send its data to each of them.const testSharedReadableStream = async (fixtureArguments, stdio) => { const readableStream = Readable.toWeb(Readable.from('foobar')); const {stdout} = await execa('stdin-fd.js', fixtureArguments, {stdio: stdio.map(value => value === 'shared' ? readableStream : value)}); assert.equal(stdout, 'foobar'); const {stdout} = await execa('stdin-fds.js', fixtureArguments, {stdio: stdio.map(value => value === 'shared' ? readableStream : value)}); assert.equal(stdout, 'foobarfoobar');};
test('stdin can share a ReadableStream with stdio[*]', () => testSharedReadableStream(['0'], ['shared', 'pipe', 'pipe', 'shared']));test('stdio[*] can share a ReadableStream with another stdio[*]', () => testSharedReadableStream(['3'], ['pipe', 'pipe', 'pipe', 'shared', 'shared']));test('stdin can share a ReadableStream with stdio[*]', () => testSharedReadableStream(['0', '3'], ['shared', 'pipe', 'pipe', 'shared']));test('stdio[*] can share a ReadableStream with another stdio[*]', () => testSharedReadableStream(['3', '4'], ['pipe', 'pipe', 'pipe', 'shared', 'shared']));