Skip to content
Myr

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

6 files+31 added−11 removed

modified:test/arguments/prototype-pollution.js+5 added-2 removed
16 unmodified lines
1718setFixtureDirectory();19process.env.FOO = 'foo';2021const isWindows = process.platform === 'win32';2223/*24A 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.25Options are therefore always kept on null-prototype objects.26Those tests must run one at a time since they temporarily modify `Object.prototype`.
161 unmodified lines
188test('Polluted environment variables are ignored, sync', t => testPollutedEnvironment(t, execaSync, {}));189test('Polluted environment variables are ignored, extendEnv false', t => testPollutedEnvironment(t, execa, {extendEnv: false}));190test('Polluted environment variables are ignored, preferLocal', t => testPollutedEnvironment(t, execa, {preferLocal: true}));191192// On Windows, libuv always passes the current process' `PATH` to the subprocess when its environment has none193const testPollutedPath = async (t, execaMethod) => {194 pollutePrototype(t, {[PATH_KEY]: POLLUTED_LOCAL_DIRECTORY});195196 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};199200test('Polluted PATH is ignored', t => testPollutedPath(t, execa));201test('Polluted PATH is ignored, sync', t => testPollutedPath(t, execaSync));
54 unmodified lines
256// A subprocess which failed to spawn has no output, which must not read its `error` from the prototype257test('Polluted "error" is ignored, sync early error', t => {258 pollutePrototype(t, {error: foobarString});259257 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});263264// Without `lines`, the output has no `finalResult` property, which must not be read from the prototype
6 unmodified lines
added:test/fixtures/stdin-fds.js+8 added
modified:test/io/max-buffer.js+1 added-1 removed
346 unmodified lines
347});348349test('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 lines
modified:test/methods/template.js+9 added-1 removed
1import assert from 'node:assert/strict';2import process from 'node:process';3import test from 'node:test';4import {assertThrows} from '../helpers/assert.js';5import {$} from '../../index.js';6import {setFixtureDirectory} from '../helpers/fixtures-directory.js';7import {majorNodeVersion} from '../helpers/node-version.js';89setFixtureDirectory();1011const isWindows = process.platform === 'win32';1213// Workaround since some text editors or IDEs do not allow inputting \r directly14const escapedCall = string => {15 const templates = [string];16 templates.raw = [string];
254 unmodified lines
271test('$ splits expressions - \\u{1F600}', () => testScriptStdout(() => $`echo.js ${'a'}\u{1F600}${'b'}`, 'a\u{1F600}b'));272test('$ concatenates tokens - \\u{1F600}', () => testScriptStdout(() => $`echo.js \u{1F600}a\u{1F600} b`, '\u{1F600}a\u{1F600}\nb'));273test('$ concatenates expressions - \\u{1F600}', () => testScriptStdout(() => $`echo.js \u{1F600}${'a'}\u{1F600} b`, '\u{1F600}a\u{1F600}\nb'));274test('$ 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 24276if (!isWindows || majorNodeVersion >= 24) {271test('$ 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}279280// The BMP boundary is the exact point where the character count changes281test('$ handles the last BMP code point - \\u{FFFF}', () => testScriptStdout(() => $`echo.js \u{FFFF} b`, '\u{FFFF}\nb'));282test('$ handles the first astral code point - \\u{10000}', () => testScriptStdout(() => $`echo.js \u{10000} b`, '\u{10000}\nb'));283test('$ handles tokens - \\u{0063}}', () => testScriptStdout(() => $`echo.js \u{0063}}`, 'c}'));
111 unmodified lines
modified:test/return/early-error.js+4 added-3 removed
27 unmodified lines
2829const isWindows = process.platform === 'win32';30const ENOENT_REGEXP = isWindows ? /failed with exit code 1/ : /spawn.* ENOENT/;3132// A nonexistent command fails asynchronously, so it does not go through the early error path, but the subprocess still has no process to signal33test('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.34test('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 lines
modified:test/stdio/web-stream.js+4 added-4 removed