output.js
This file
Path
test/return/output.js
110 lines · 4.2 KiB · JavaScript
Last changed by
Upgrade xo (#980)ehmickybefore adoptionccfa412
History of this fileTake it
Split files (#837)ehmickybefore adoption672c2d7
lines 1–2why, one step back1import test from 'ava';2import {execa, execaSync} from '../../index.js';Upgrade xo (#980)ehmickybefore adoptionccfa412
line 3why, one step back3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';Split files (#837)ehmickybefore adoption672c2d7
line 4why, one step back4import {fullStdio, getStdio} from '../helpers/stdio.js';Allow setting different `stripFinalNewline` values for `stdout`/`stderr` (#971)ehmickybefore adoption64d52db
line 5why, one step back5import {foobarString} from '../helpers/input.js';Split files (#837)ehmickybefore adoption672c2d7
line 6why, one step back6Upgrade xo (#980)ehmickybefore adoptionccfa412
line 7why, one step back7setFixtureDirectory();Split files (#837)ehmickybefore adoption672c2d7
line 8why, one step back8Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 9why, one step back9const testOutput = async (t, fdNumber, execaMethod) => {Allow setting different `stripFinalNewline` values for `stdout`/`stderr` (#971)ehmickybefore adoption64d52db
lines 10–11why, one step back10 const {stdout, stderr, stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], fullStdio);11 t.is(stdio[fdNumber], foobarString);Split files (#837)ehmickybefore adoption672c2d7
line 12why, one step back12Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
lines 13–16why, one step back13 if (fdNumber === 1) {14 t.is(stdio[fdNumber], stdout);15 } else if (fdNumber === 2) {16 t.is(stdio[fdNumber], stderr);Split files (#837)ehmickybefore adoption672c2d7
lines 17–22why, one step back17 }18};1920test('can return stdout', testOutput, 1, execa);21test('can return stderr', testOutput, 2, execa);22test('can return output stdio[*]', testOutput, 3, execa);Allow setting different `stripFinalNewline` values for `stdout`/`stderr` (#971)ehmickybefore adoption64d52db
lines 23–25why, one step back23test('can return stdout, sync', testOutput, 1, execaSync);24test('can return stderr, sync', testOutput, 2, execaSync);25test('can return output stdio[*], sync', testOutput, 3, execaSync);Split files (#837)ehmickybefore adoption672c2d7
lines 26–27why, one step back2627const testNoStdin = async (t, execaMethod) => {Allow setting different `stripFinalNewline` values for `stdout`/`stderr` (#971)ehmickybefore adoption64d52db
line 28why, one step back28 const {stdio} = await execaMethod('noop.js', [foobarString]);Split files (#837)ehmickybefore adoption672c2d7
lines 29–32why, one step back29 t.is(stdio[0], undefined);30};3132test('cannot return stdin', testNoStdin, execa);Allow setting different `stripFinalNewline` values for `stdout`/`stderr` (#971)ehmickybefore adoption64d52db
line 33why, one step back33test('cannot return stdin, sync', testNoStdin, execaSync);Split files (#837)ehmickybefore adoption672c2d7
lines 34–35why, one step back3435test('cannot return input stdio[*]', async t => {Allow setting different `stripFinalNewline` values for `stdout`/`stderr` (#971)ehmickybefore adoption64d52db
line 36why, one step back36 const {stdio} = await execa('stdin-fd.js', ['3'], getStdio(3, [[foobarString]]));Split files (#837)ehmickybefore adoption672c2d7
lines 37–56why, one step back37 t.is(stdio[3], undefined);38});3940test('do not try to consume streams twice', async t => {41 const subprocess = execa('noop.js', ['foo']);42 const {stdout} = await subprocess;43 const {stdout: stdout2} = await subprocess;44 t.is(stdout, 'foo');45 t.is(stdout2, 'foo');46});4748const testEmptyErrorStdio = async (t, execaMethod) => {49 const {failed, stdout, stderr, stdio} = await execaMethod('fail.js', {reject: false});50 t.true(failed);51 t.is(stdout, '');52 t.is(stderr, '');53 t.deepEqual(stdio, [undefined, '', '']);54};5556test('empty error.stdout/stderr/stdio', testEmptyErrorStdio, execa);Allow setting different `stripFinalNewline` values for `stdout`/`stderr` (#971)ehmickybefore adoption64d52db
line 57why, one step back57test('empty error.stdout/stderr/stdio, sync', testEmptyErrorStdio, execaSync);Split files (#837)ehmickybefore adoption672c2d7
lines 58–66why, one step back5859const testUndefinedErrorStdio = async (t, execaMethod) => {60 const {stdout, stderr, stdio} = await execaMethod('empty.js', {stdio: 'ignore'});61 t.is(stdout, undefined);62 t.is(stderr, undefined);63 t.deepEqual(stdio, [undefined, undefined, undefined]);64};6566test('undefined error.stdout/stderr/stdio', testUndefinedErrorStdio, execa);Allow setting different `stripFinalNewline` values for `stdout`/`stderr` (#971)ehmickybefore adoption64d52db
line 67why, one step back67test('undefined error.stdout/stderr/stdio, sync', testUndefinedErrorStdio, execaSync);Split files (#837)ehmickybefore adoption672c2d7
line 68why, one step back68Add support for `all` option to `execaSync()` (#956)ehmickybefore adoption63b5ac4
lines 69–70why, one step back69const testEmptyAll = async (t, options, expectedValue, execaMethod) => {70 const {all} = await execaMethod('empty.js', options);Split files (#837)ehmickybefore adoption672c2d7
lines 71–73why, one step back71 t.is(all, expectedValue);72};73Add support for `all` option to `execaSync()` (#956)ehmickybefore adoption63b5ac4
lines 74–79why, one step back74test('empty error.all', testEmptyAll, {all: true}, '', execa);75test('undefined error.all', testEmptyAll, {}, undefined, execa);76test('ignored error.all', testEmptyAll, {all: true, stdio: 'ignore'}, undefined, execa);77test('empty error.all, sync', testEmptyAll, {all: true}, '', execaSync);78test('undefined error.all, sync', testEmptyAll, {}, undefined, execaSync);79test('ignored error.all, sync', testEmptyAll, {all: true, stdio: 'ignore'}, undefined, execaSync);Split files (#837)ehmickybefore adoption672c2d7
lines 80–88why, one step back8081test('empty error.stdio[0] even with input', async t => {82 const {stdio} = await t.throwsAsync(execa('fail.js', {input: 'test'}));83 t.is(stdio[0], undefined);84});8586// `error.code` is OS-specific here87const SPAWN_ERROR_CODES = new Set(['EINVAL', 'ENOTSUP', 'EPERM']);88Add support for `all` option to `execaSync()` (#956)ehmickybefore adoption63b5ac4
lines 89–90why, one step back89const testSpawnError = async (t, execaMethod) => {90 const {code, stdout, stderr, stdio, all} = await execaMethod('empty.js', {uid: -1, all: true, reject: false});Split files (#837)ehmickybefore adoption672c2d7
lines 91–93why, one step back91 t.true(SPAWN_ERROR_CODES.has(code));92 t.is(stdout, undefined);93 t.is(stderr, undefined);Add support for `all` option to `execaSync()` (#956)ehmickybefore adoption63b5ac4
line 94why, one step back94 t.is(all, undefined);Split files (#837)ehmickybefore adoption672c2d7
line 95why, one step back95 t.deepEqual(stdio, [undefined, undefined, undefined]);Add support for `all` option to `execaSync()` (#956)ehmickybefore adoption63b5ac4
line 96why, one step back96};Split files (#837)ehmickybefore adoption672c2d7
line 97why, one step back97Add support for `all` option to `execaSync()` (#956)ehmickybefore adoption63b5ac4
line 98why, one step back98test('stdout/stderr/all/stdio on subprocess spawning errors', testSpawnError, execa);Allow setting different `stripFinalNewline` values for `stdout`/`stderr` (#971)ehmickybefore adoption64d52db
line 99why, one step back99test('stdout/stderr/all/stdio on subprocess spawning errors, sync', testSpawnError, execaSync);Split files (#837)ehmickybefore adoption672c2d7
lines 100–109why, one step back100101const testErrorOutput = async (t, execaMethod) => {102 const {failed, stdout, stderr, stdio} = await execaMethod('echo-fail.js', {...fullStdio, reject: false});103 t.true(failed);104 t.is(stdout, 'stdout');105 t.is(stderr, 'stderr');106 t.deepEqual(stdio, [undefined, 'stdout', 'stderr', 'fd3']);107};108109test('error.stdout/stderr/stdio is defined', testErrorOutput, execa);Allow setting different `stripFinalNewline` values for `stdout`/`stderr` (#971)ehmickybefore adoption64d52db
line 110why, one step back110test('error.stdout/stderr/stdio is defined, sync', testErrorOutput, execaSync);