test.js
This file
Path
test.js
837 lines · 26.3 KiB · JavaScript
Last changed by
Fix shape of exceptions rejected by `execa()` (#276)ehmickybefore adoption49c74ac
History of this fileTake it
fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
line 1why, one step back1import path from 'path';Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 2why, one step back2import fs from 'fs';add `input` optionJames Talmagebefore adoption605a674
line 3why, one step back3import stream from 'stream';add tests (#48)James Talmagebefore adoptionb15483a
line 4why, one step back4import childProcess from 'child_process';5import test from 'ava';make `execa.spawn()` use the same argument normalization as `execa()`Sindre Sorhusbefore adoptiond6e3220
line 6why, one step back6import getStream from 'get-stream';Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd
line 7why, one step back7import isRunning from 'is-running';Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 8why, one step back8import tempfile from 'tempfile';Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c
line 9why, one step back9import pEvent from 'p-event';Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 10why, one step back10import execa from '.';11fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
line 12why, one step back12process.env.PATH = path.join(__dirname, 'fixtures') + path.delimiter + process.env.PATH;Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117
line 13why, one step back13process.env.FOO = 'foo';fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
line 14why, one step back14Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
line 15why, one step back15const TIMEOUT_REGEXP = /timed out after/;Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671
line 16why, one step back16Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 17why, one step back17const getExitRegExp = exitMessage => new RegExp(`failed with exit code ${exitMessage}`);Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
line 18why, one step back1819test('execa()', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 20why, one step back20 const {stdout} = await execa('noop', ['foo']);initSindre Sorhusbefore adoptionbc16d6b
lines 21–2321 t.is(stdout, 'foo');22});23Turn off echo on Windows - fixes #116 (#118)Sam Verschuerenbefore adoptionff76235
lines 24–25why, one step back24if (process.platform === 'win32') {25 test('execa() - cmd file', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 26why, one step back26 const {stdout} = await execa('hello.cmd');Turn off echo on Windows - fixes #116 (#118)Sam Verschuerenbefore adoptionff76235
lines 27–28why, one step back27 t.is(stdout, 'Hello World');28 });Add `/q` option to `cmd` as well as `cmd.exe` on Windows (#203)Guillaume Martignybefore adoption10c73dc
lines 29–33why, one step back2930 test('execa() - run cmd command', async t => {31 const {stdout} = await execa('cmd', ['/c', 'hello.cmd']);32 t.is(stdout, 'Hello World');33 });Turn off echo on Windows - fixes #116 (#118)Sam Verschuerenbefore adoptionff76235
lines 34–35why, one step back34}3536test('buffer', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 37why, one step back37 const {stdout} = await execa('noop', ['foo'], {encoding: null});initSindre Sorhusbefore adoptionbc16d6b
lines 38–4138 t.true(Buffer.isBuffer(stdout));39 t.is(stdout.toString(), 'foo');40});41Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911
line 42why, one step back42test.serial('result.all shows both `stdout` and `stderr` intermixed', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 43–44why, one step back43 const {all} = await execa('noop-132');44 t.is(all, '132');Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911
lines 45–47why, one step back45});4647test('stdout/stderr/all available on errors', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 48–51why, one step back48 const {stdout, stderr, all} = await t.throwsAsync(execa('exit', ['2']), {message: getExitRegExp('2')});49 t.is(typeof stdout, 'string');50 t.is(typeof stderr, 'string');51 t.is(typeof all, 'string');add `stdout`/`stderr` to errorsSindre Sorhusbefore adoption0ea8aaf
lines 52–53why, one step back52});53Make `stdout` and `stderr` properties `undefined` instead of `null` (#246)ehmickybefore adoptionc8a53da
lines 54–67why, one step back54test('stdout/stderr/all are undefined if ignored', async t => {55 const {stdout, stderr, all} = await execa('noop', {stdio: 'ignore'});56 t.is(stdout, undefined);57 t.is(stderr, undefined);58 t.is(all, undefined);59});6061test('stdout/stderr/all are undefined if ignored in sync mode', t => {62 const {stdout, stderr, all} = execa.sync('noop', {stdio: 'ignore'});63 t.is(stdout, undefined);64 t.is(stderr, undefined);65 t.is(all, undefined);66});67Improve error handling of streams (#271)ehmickybefore adoptionbad2140
lines 68–71why, one step back68const WRONG_COMMAND = process.platform === 'win32' ?69 '\'wrong\' is not recognized as an internal or external command,\r\noperable program or batch file.' :70 '';71Make `stdout` and `stderr` properties `undefined` instead of `null` (#246)ehmickybefore adoptionc8a53da
lines 72–74why, one step back72test('stdout/stderr/all on process errors', async t => {73 const {stdout, stderr, all} = await t.throwsAsync(execa('wrong command'));74 t.is(stdout, '');Improve error handling of streams (#271)ehmickybefore adoptionbad2140
lines 75–76why, one step back75 t.is(stderr, WRONG_COMMAND);76 t.is(all, WRONG_COMMAND);Make `stdout` and `stderr` properties `undefined` instead of `null` (#246)ehmickybefore adoptionc8a53da
lines 77–83why, one step back77});7879test('stdout/stderr/all on process errors, in sync mode', t => {80 const {stdout, stderr, all} = t.throws(() => {81 execa.sync('wrong command');82 });83 t.is(stdout, '');Improve error handling of streams (#271)ehmickybefore adoptionbad2140
line 84why, one step back84 t.is(stderr, WRONG_COMMAND);Make `stdout` and `stderr` properties `undefined` instead of `null` (#246)ehmickybefore adoptionc8a53da
lines 85–87why, one step back85 t.is(all, undefined);86});87Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 88–89why, one step back88test('pass `stdout` to a file descriptor', async t => {89 const file = tempfile('.txt');Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 90why, one step back90 await execa('fixtures/noop', ['foo bar'], {stdout: fs.openSync(file, 'w')});Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 91–95why, one step back91 t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');92});9394test('pass `stderr` to a file descriptor', async t => {95 const file = tempfile('.txt');Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 96why, one step back96 await execa('fixtures/noop-err', ['foo bar'], {stderr: fs.openSync(file, 'w')});Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 97why, one step back97 t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');Do not output stderr and stdout on stdio inherit - fixes #70 (#79)Sam Verschuerenbefore adoption2a12986
lines 98–99why, one step back98});99add `execa.sync()` (#7)Sindre Sorhusbefore adoption9345d2c
line 100why, one step back100test('execa.sync()', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 101why, one step back101 const {stdout} = execa.sync('noop', ['foo']);add `execa.sync()` (#7)Sindre Sorhusbefore adoption9345d2c
lines 102–104why, one step back102 t.is(stdout, 'foo');103});104Throw error in sync method - fixes #66 (#67)Sam Verschuerenbefore adoptionc8c9c7b
line 105why, one step back105test('execa.sync() throws error if written to stderr', t => {Minor test code style tweaksSindre Sorhusbefore adoptionf6db264
lines 106–107why, one step back106 t.throws(() => {107 execa.sync('foo');Make error messages more consistent (#230)ehmickybefore adoption5f8bd52
line 108why, one step back108 }, process.platform === 'win32' ? /failed with exit code 1/ : /spawnSync foo ENOENT/);Throw error in sync method - fixes #66 (#67)Sam Verschuerenbefore adoptionc8c9c7b
lines 109–110why, one step back109});110Improve tests for the `reject` option (#233)ehmickybefore adoptione55dc8b
line 111why, one step back111test('skip throwing when using reject option', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 112–113why, one step back112 const {exitCode} = await execa('fail', {reject: false});113 t.is(exitCode, 2);Enhance error object in sync methods - fixes #98 (#107)Sam Verschuerenbefore adoptiond31cc91
lines 114–115why, one step back114});115Improve tests for the `reject` option (#233)ehmickybefore adoptione55dc8b
line 116why, one step back116test('skip throwing when using reject option in sync mode', t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 117–118why, one step back117 const {exitCode} = execa.sync('fail', {reject: false});118 t.is(exitCode, 2);Improve tests for the `reject` option (#233)ehmickybefore adoptione55dc8b
lines 119–120why, one step back119});120Refactor tests of `kill()` (#284)ehmickybefore adoption7e2c835
lines 121–122why, one step back121test('kill("SIGKILL") should terminate cleanly', async t => {122 const subprocess = execa('node', ['fixtures/no-killable'], {stdio: ['ipc']});Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596
lines 123–133why, one step back123 await pEvent(subprocess, 'message');124125 subprocess.kill('SIGKILL');126127 const {signal} = await t.throwsAsync(subprocess);128 t.is(signal, 'SIGKILL');129});130131// `SIGTERM` cannot be caught on Windows, and it always aborts the process (like `SIGKILL` on Unix).132// Therefore, this feature and those tests do not make sense on Windows.133if (process.platform !== 'win32') {Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882
line 134why, one step back134 test('`forceKillAfterTimeout: false` should not kill after a timeout', async t => {Refactor tests of `kill()` (#284)ehmickybefore adoption7e2c835
line 135why, one step back135 const subprocess = execa('node', ['fixtures/no-killable'], {stdio: ['ipc']});Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596
lines 136–137why, one step back136 await pEvent(subprocess, 'message');137Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882
line 138why, one step back138 subprocess.kill('SIGTERM', {forceKillAfterTimeout: false});Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596
lines 139–143why, one step back139140 t.true(isRunning(subprocess.pid));141 subprocess.kill('SIGKILL');142 });143Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882
line 144why, one step back144 test('`forceKillAfterTimeout: number` should kill after a timeout', async t => {Refactor tests of `kill()` (#284)ehmickybefore adoption7e2c835
line 145why, one step back145 const subprocess = execa('node', ['fixtures/no-killable'], {stdio: ['ipc']});Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596
lines 146–147why, one step back146 await pEvent(subprocess, 'message');147Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882
line 148why, one step back148 subprocess.kill('SIGTERM', {forceKillAfterTimeout: 50});Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596
lines 149–153why, one step back149150 const {signal} = await t.throwsAsync(subprocess);151 t.is(signal, 'SIGKILL');152 });153Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882
line 154why, one step back154 test('`forceKillAfterTimeout: true` should kill after a timeout', async t => {Refactor tests of `kill()` (#284)ehmickybefore adoption7e2c835
lines 155–156why, one step back155 const subprocess = execa('node', ['fixtures/no-killable'], {stdio: ['ipc']});156 await pEvent(subprocess, 'message');Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596
line 157why, one step back157Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882
line 158why, one step back158 subprocess.kill('SIGTERM', {forceKillAfterTimeout: true});Refactor tests of `kill()` (#284)ehmickybefore adoption7e2c835
lines 159–165why, one step back159160 const {signal} = await t.throwsAsync(subprocess);161 t.is(signal, 'SIGKILL');162 });163164 test('kill() with no arguments should kill after a timeout', async t => {165 const subprocess = execa('node', ['fixtures/no-killable'], {stdio: ['ipc']});Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596
lines 166–172why, one step back166 await pEvent(subprocess, 'message');167168 subprocess.kill();169170 const {signal} = await t.throwsAsync(subprocess);171 t.is(signal, 'SIGKILL');172 });Refactor `kill()` again (#280)ehmickybefore adoption1b38dc9
line 173why, one step back173Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882
line 174why, one step back174 test('`forceKillAfterTimeout` should not be a float', t => {Refactor `kill()` again (#280)ehmickybefore adoption1b38dc9
line 175why, one step back175 t.throws(() => {Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882
line 176why, one step back176 execa('noop').kill('SIGTERM', {forceKillAfterTimeout: 0.5});Refactor `kill()` again (#280)ehmickybefore adoption1b38dc9
lines 177–179why, one step back177 }, {instanceOf: TypeError, message: /non-negative integer/});178 });179Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882
line 180why, one step back180 test('`forceKillAfterTimeout` should not be negative', t => {Refactor `kill()` again (#280)ehmickybefore adoption1b38dc9
line 181why, one step back181 t.throws(() => {Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882
line 182why, one step back182 execa('noop').kill('SIGTERM', {forceKillAfterTimeout: -1});Refactor `kill()` again (#280)ehmickybefore adoption1b38dc9
lines 183–184why, one step back183 }, {instanceOf: TypeError, message: /non-negative integer/});184 });Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596
lines 185–186why, one step back185}186Fix `stripFinalNewline` not applied on `error.stdout|stderr|all` (#240)ehmickybefore adoption943f040
lines 187–192why, one step back187test('stripFinalNewline: true', async t => {188 const {stdout} = await execa('noop', ['foo']);189 t.is(stdout, 'foo');190});191192test('stripFinalNewline: false', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 193why, one step back193 const {stdout} = await execa('noop', ['foo'], {stripFinalNewline: false});194 t.is(stdout, 'foo\n');Fix `stripFinalNewline` not applied on `error.stdout|stderr|all` (#240)ehmickybefore adoption943f040
lines 195–207why, one step back195});196197test('stripFinalNewline on failure', async t => {198 const {stderr} = await t.throwsAsync(execa('noop-throw', ['foo'], {stripFinalNewline: true}));199 t.is(stderr, 'foo');200});201202test('stripFinalNewline in sync mode', t => {203 const {stdout} = execa.sync('noop', ['foo'], {stripFinalNewline: true});204 t.is(stdout, 'foo');205});206207test('stripFinalNewline in sync mode on failure', t => {Make `error.killed` more consistent (#248)ehmickybefore adoptionfd064a7
lines 208–210why, one step back208 const {stderr} = t.throws(() => {209 execa.sync('noop-throw', ['foo'], {stripFinalNewline: true});210 });Fix `stripFinalNewline` not applied on `error.stdout|stderr|all` (#240)ehmickybefore adoption943f040
line 211why, one step back211 t.is(stderr, 'foo');initSindre Sorhusbefore adoptionbc16d6b
lines 212–213212});213Improve test for `options.preferLocal` (#216)ehmickybefore adoption575d464
lines 214–215why, one step back214test('preferLocal option', async t => {215 await execa('ava', ['--version'], {env: {PATH: ''}});Make error messages more consistent (#230)ehmickybefore adoption5f8bd52
line 216why, one step back216 const errorRegExp = process.platform === 'win32' ? /failed with exit code 1/ : /spawn ava ENOENT/;Improve test for `options.preferLocal` (#216)ehmickybefore adoption575d464
line 217why, one step back217 await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: {PATH: ''}}), errorRegExp);add `input` optionJames Talmagebefore adoption605a674
lines 218–219why, one step back218});219Fix test for `options.localDir` (#218)ehmickybefore adoption0070738
lines 220–226why, one step back220test('localDir option', async t => {221 const command = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH';222 const {stdout} = await execa(command, {shell: true, localDir: '/test'});223 const envPaths = stdout.split(path.delimiter).map(envPath =>224 envPath.replace(/\\/g, '/').replace(/^[^/]+/, '')225 );226 t.true(envPaths.some(envPath => envPath === '/test/node_modules/.bin'));Add test for #73Sindre Sorhusbefore adoptionc7481f4
lines 227–228why, one step back227});228add `input` optionJames Talmagebefore adoption605a674
line 229why, one step back229test('input option can be a String', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 230why, one step back230 const {stdout} = await execa('stdin', {input: 'foobar'});add `input` optionJames Talmagebefore adoption605a674
lines 231–234why, one step back231 t.is(stdout, 'foobar');232});233234test('input option can be a Buffer', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 235why, one step back235 const {stdout} = await execa('stdin', {input: 'testing12'});add `input` optionJames Talmagebefore adoption605a674
lines 236–239why, one step back236 t.is(stdout, 'testing12');237});238239test('input can be a Stream', async t => {[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 240why, one step back240 const s = new stream.PassThrough();add `input` optionJames Talmagebefore adoption605a674
lines 241–242why, one step back241 s.write('howdy');242 s.end();Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 243why, one step back243 const {stdout} = await execa('stdin', {input: s});add `input` optionJames Talmagebefore adoption605a674
lines 244–246why, one step back244 t.is(stdout, 'howdy');245});246return the child process instead of a promise. (#18)James Talmagebefore adoption99f10ba
line 247why, one step back247test('you can write to child.stdin', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 248why, one step back248 const child = execa('stdin');return the child process instead of a promise. (#18)James Talmagebefore adoption99f10ba
lines 249–252why, one step back249 child.stdin.end('unicorns');250 t.is((await child).stdout, 'unicorns');251});252Fix linting (#77)Sam Verschuerenbefore adoption80a059d
line 253why, one step back253test('input option can be a String - sync', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 254why, one step back254 const {stdout} = execa.sync('stdin', {input: 'foobar'});add `input` optionJames Talmagebefore adoption605a674
lines 255–257why, one step back255 t.is(stdout, 'foobar');256});257Fix linting (#77)Sam Verschuerenbefore adoption80a059d
line 258why, one step back258test('input option can be a Buffer - sync', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 259why, one step back259 const {stdout} = execa.sync('stdin', {input: Buffer.from('testing12', 'utf8')});add `input` optionJames Talmagebefore adoption605a674
line 260why, one step back260 t.is(stdout, 'testing12');Use spawn instead of execFile (#27)James Talmagebefore adoption31a8d87
lines 261–262why, one step back261});262Improve error handling of streams (#271)ehmickybefore adoptionbad2140
lines 263–268why, one step back263test('stdin errors are handled', async t => {264 const child = execa('noop');265 child.stdin.emit('error', new Error('test'));266 await t.throwsAsync(child, /test/);267});268Improve error messages when an `error` event is emitted (#269)ehmickybefore adoption2307d95
lines 269–271why, one step back269test('child process errors are handled', async t => {270 const child = execa('noop');271 child.emit('error', new Error('test'));Improve error handling of streams (#271)ehmickybefore adoptionbad2140
line 272why, one step back272 await t.throwsAsync(child, /test/);Improve error messages when an `error` event is emitted (#269)ehmickybefore adoption2307d95
lines 273–274why, one step back273});274Use spawn instead of execFile (#27)James Talmagebefore adoption31a8d87
line 275why, one step back275test('opts.stdout:ignore - stdout will not collect data', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 276why, one step back276 const {stdout} = await execa('stdin', {fix XO lint issuesSindre Sorhusbefore adoption342096c
line 277why, one step back277 input: 'hello',Improve the TS types and don't accept `null` in the `stdio` optionSindre Sorhusbefore adoption4692dcd
line 278why, one step back278 stdio: [undefined, 'ignore', undefined]fix XO lint issuesSindre Sorhusbefore adoption342096c
line 279why, one step back279 });Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
line 280why, one step back280 t.is(stdout, undefined);add `input` optionJames Talmagebefore adoption605a674
lines 281–284why, one step back281});282283test('helpful error trying to provide an input stream in sync mode', t => {284 t.throws(Minor test code style tweaksSindre Sorhusbefore adoptionf6db264
lines 285–287why, one step back285 () => {286 execa.sync('stdin', {input: new stream.PassThrough()});287 },add `input` optionJames Talmagebefore adoption605a674
lines 288–289why, one step back288 /The `input` option cannot be a stream in sync mode/289 );Child process errors should reject the promise right away (#270)ehmickybefore adoption3b8df50
lines 290–295why, one step back290});291292test('child process errors rejects promise right away', async t => {293 const child = execa('forever');294 child.emit('error', new Error('test'));295 await t.throwsAsync(child, /test/);Attach pid and kill() to returned promise (#11)Luke Horvatbefore adoption9da5484
lines 296–298why, one step back296});297298test('execa() returns a promise with kill() and pid', t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 299–301why, one step back299 const {kill, pid} = execa('noop', ['foo']);300 t.is(typeof kill, 'function');301 t.is(typeof pid, 'number');302});add max-buffer support (#37)James Talmagebefore adoption6288806
line 303why, one step back303Fix shape of exceptions rejected by `execa()` (#276)ehmickybefore adoption49c74ac
lines 304–312why, one step back304test('child_process.spawn() propagated errors have correct shape', t => {305 const cp = execa('noop', {uid: -1});306 t.notThrows(() => {307 cp.catch(() => {});308 cp.unref();309 cp.on('error', () => {});310 });311});312Make errors more consistent (#266)ehmickybefore adoptione5ed8de
line 313why, one step back313test('child_process.spawn() errors are propagated', async t => {Fix tests on Mac (#283)ehmickybefore adoption55337f7
lines 314–315why, one step back314 const {failed} = await t.throwsAsync(execa('noop', {uid: -1}));315 t.true(failed);Make errors more consistent (#266)ehmickybefore adoptione5ed8de
lines 316–317why, one step back316});317Fix shape of exceptions thrown by `execa.sync()` (#277)ehmickybefore adoption048b23e
lines 318–320why, one step back318test('child_process.spawnSync() errors are propagated with a correct shape', t => {319 const {failed} = t.throws(() => {320 execa.sync('noop', {timeout: -1});Make errors more consistent (#266)ehmickybefore adoptione5ed8de
line 321why, one step back321 });Fix shape of exceptions thrown by `execa.sync()` (#277)ehmickybefore adoption048b23e
line 322why, one step back322 t.true(failed);Make errors more consistent (#266)ehmickybefore adoptione5ed8de
lines 323–324why, one step back323});324Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 325why, one step back325test('maxBuffer affects stdout', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 326why, one step back326 await t.notThrowsAsync(execa('max-buffer', ['stdout', '10'], {maxBuffer: 10}));Improve error handling of streams (#271)ehmickybefore adoptionbad2140
lines 327–329why, one step back327 const {stdout, all} = await t.throwsAsync(execa('max-buffer', ['stdout', '11'], {maxBuffer: 10}), /max-buffer stdout/);328 t.is(stdout, '.'.repeat(10));329 t.is(all, '.'.repeat(10));add max-buffer support (#37)James Talmagebefore adoption6288806
lines 330–331why, one step back330});331Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 332why, one step back332test('maxBuffer affects stderr', async t => {Improve error handling of streams (#271)ehmickybefore adoptionbad2140
lines 333–336why, one step back333 await t.notThrowsAsync(execa('max-buffer', ['stderr', '10'], {maxBuffer: 10}));334 const {stderr, all} = await t.throwsAsync(execa('max-buffer', ['stderr', '11'], {maxBuffer: 10}), /max-buffer stderr/);335 t.is(stderr, '.'.repeat(10));336 t.is(all, '.'.repeat(10));add max-buffer support (#37)James Talmagebefore adoption6288806
line 337why, one step back337});Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
line 338why, one step back338Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa
line 339why, one step back339test('do not buffer stdout when `buffer` set to `false`', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 340why, one step back340 const promise = execa('max-buffer', ['stdout', '10'], {buffer: false});Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa
lines 341–342why, one step back341 const [result, stdout] = await Promise.all([342 promise,Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911
lines 343–344why, one step back343 getStream(promise.stdout),344 getStream(promise.all)Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa
lines 345–351why, one step back345 ]);346347 t.is(result.stdout, undefined);348 t.is(stdout, '.........\n');349});350351test('do not buffer stderr when `buffer` set to `false`', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 352why, one step back352 const promise = execa('max-buffer', ['stderr', '10'], {buffer: false});Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa
lines 353–354why, one step back353 const [result, stderr] = await Promise.all([354 promise,Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911
lines 355–356why, one step back355 getStream(promise.stderr),356 getStream(promise.all)Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa
lines 357–360why, one step back357 ]);358359 t.is(result.stderr, undefined);360 t.is(stderr, '.........\n');Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
lines 361–362why, one step back361});362Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
line 363why, one step back363test('allow unknown exit code', async t => {Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
lines 364–366why, one step back364 const {exitCode, exitCodeName} = await t.throwsAsync(execa('exit', ['255']), {message: /exit code 255 \(Unknown system error -255\)/});365 t.is(exitCode, 255);366 t.is(exitCodeName, 'Unknown system error -255');Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
lines 367–368why, one step back367});368Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 369why, one step back369test('execa() does not return code and failed properties on success', async t => {Remove `error.code` (#250)ehmickybefore adoptionbc0984e
line 370why, one step back370 const {exitCode, exitCodeName, failed} = await execa('noop', ['foo']);Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
lines 371–372why, one step back371 t.is(exitCode, 0);372 t.is(exitCodeName, 'SUCCESS');Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
line 373why, one step back373 t.false(failed);Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 374why, one step back374});Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
line 375why, one step back375Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 376–378why, one step back376test('execa() returns code and failed properties', async t => {377 const {exitCode, exitCodeName, failed} = await t.throwsAsync(execa('exit', ['2']), {message: getExitRegExp('2')});378 t.is(exitCode, 2);Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
line 379why, one step back379 const expectedName = process.platform === 'win32' ? 'Unknown system error -2' : 'ENOENT';Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 380–381why, one step back380 t.is(exitCodeName, expectedName);381 t.true(failed);Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
line 382why, one step back382});Add test for `../` paths (#43)James Talmagebefore adoption56a20b1
line 383why, one step back383Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 384why, one step back384test('use relative path with \'..\' chars', async t => {Add test for `../` paths (#43)James Talmagebefore adoption56a20b1
line 385why, one step back385 const pathViaParentDir = path.join('..', path.basename(__dirname), 'fixtures', 'noop');Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 386why, one step back386 const {stdout} = await execa(pathViaParentDir, ['foo']);Add test for `../` paths (#43)James Talmagebefore adoption56a20b1
lines 387–388why, one step back387 t.is(stdout, 'foo');388});add tests (#48)James Talmagebefore adoptionb15483a
line 389why, one step back389add test case for throwing on non-executables (#49)Markus Wolfbefore adoptione10d263
line 390why, one step back390if (process.platform !== 'win32') {Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 391why, one step back391 test('execa() rejects if running non-executable', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 392why, one step back392 const cp = execa('non-executable');Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671
line 393why, one step back393 await t.throwsAsync(cp);add test case for throwing on non-executables (#49)Markus Wolfbefore adoptione10d263
line 394why, one step back394 });Fix non-executable execution with `input` option (#212)Yanis Bensonbefore adoptiona428249
lines 395–398why, one step back395396 test('execa() rejects with correct error and doesn\'t throw if running non-executable with input', async t => {397 await t.throwsAsync(execa('non-executable', {input: 'Hey!'}), /EACCES/);398 });add test case for throwing on non-executables (#49)Markus Wolfbefore adoptione10d263
lines 399–400why, one step back399}400Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 401why, one step back401test('error.killed is true if process was killed directly', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 402why, one step back402 const cp = execa('forever');add tests (#48)James Talmagebefore adoptionb15483a
line 403why, one step back403Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c
line 404why, one step back404 cp.kill();add tests (#48)James Talmagebefore adoptionb15483a
line 405why, one step back405Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 406–407why, one step back406 const {killed} = await t.throwsAsync(cp, {message: /was killed with SIGTERM/});407 t.true(killed);add tests (#48)James Talmagebefore adoptionb15483a
lines 408–409why, one step back408});409Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 410why, one step back410test('error.killed is false if process was killed indirectly', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 411why, one step back411 const cp = execa('forever');add tests (#48)James Talmagebefore adoptionb15483a
line 412why, one step back412Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c
line 413why, one step back413 process.kill(cp.pid, 'SIGINT');add tests (#48)James Talmagebefore adoptionb15483a
line 414why, one step back414Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
lines 415–416why, one step back415 // `process.kill()` is emulated by Node.js on Windows416 const message = process.platform === 'win32' ? /failed with exit code 1/ : /was killed with SIGINT/;Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 417–418why, one step back417 const {killed} = await t.throwsAsync(cp, {message});418 t.false(killed);add tests (#48)James Talmagebefore adoptionb15483a
lines 419–420why, one step back419});420Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d
line 421why, one step back421test('result.killed is false if not killed', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 422–423why, one step back422 const {killed} = await execa('noop');423 t.false(killed);Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d
lines 424–426why, one step back424});425426test('result.killed is false if not killed, in sync mode', t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 427–428why, one step back427 const {killed} = execa.sync('noop');428 t.false(killed);Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d
lines 429–430why, one step back429});430Make `error.killed` more consistent (#248)ehmickybefore adoptionfd064a7
lines 431–442why, one step back431test('result.killed is false on process error', async t => {432 const {killed} = await t.throwsAsync(execa('wrong command'));433 t.false(killed);434});435436test('result.killed is false on process error, in sync mode', t => {437 const {killed} = t.throws(() => {438 execa.sync('wrong command');439 });440 t.false(killed);441});442add tests (#48)James Talmagebefore adoptionb15483a
lines 443–444why, one step back443if (process.platform === 'darwin') {444 test.cb('sanity check: child_process.exec also has killed.false if killed indirectly', t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 445why, one step back445 const {pid} = childProcess.exec('forever', error => {Fix lint issuesSindre Sorhusbefore adoptionb7752fb
lines 446–447why, one step back446 t.truthy(error);447 t.false(error.killed);add tests (#48)James Talmagebefore adoptionb15483a
lines 448–450why, one step back448 t.end();449 });450Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 451why, one step back451 process.kill(pid, 'SIGINT');add tests (#48)James Talmagebefore adoptionb15483a
lines 452–455why, one step back452 });453}454455if (process.platform !== 'win32') {Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 456why, one step back456 test('error.signal is SIGINT', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 457why, one step back457 const cp = execa('forever');add tests (#48)James Talmagebefore adoptionb15483a
line 458why, one step back458Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c
line 459why, one step back459 process.kill(cp.pid, 'SIGINT');add tests (#48)James Talmagebefore adoptionb15483a
line 460why, one step back460Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 461–462why, one step back461 const {signal} = await t.throwsAsync(cp, {message: /was killed with SIGINT/});462 t.is(signal, 'SIGINT');add tests (#48)James Talmagebefore adoptionb15483a
lines 463–464why, one step back463 });464Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 465why, one step back465 test('error.signal is SIGTERM', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 466why, one step back466 const cp = execa('forever');add tests (#48)James Talmagebefore adoptionb15483a
line 467why, one step back467Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c
line 468why, one step back468 process.kill(cp.pid, 'SIGTERM');add tests (#48)James Talmagebefore adoptionb15483a
line 469why, one step back469Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 470–471why, one step back470 const {signal} = await t.throwsAsync(cp, {message: /was killed with SIGTERM/});471 t.is(signal, 'SIGTERM');add tests (#48)James Talmagebefore adoptionb15483a
line 472why, one step back472 });Fix `killSignal` option (#93)Kevin Mårtenssonbefore adoption2cbcc5c
line 473why, one step back473Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 474why, one step back474 test('custom error.signal', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 475–476why, one step back475 const {signal} = await t.throwsAsync(execa('forever', {killSignal: 'SIGHUP', timeout: 1, message: TIMEOUT_REGEXP}));476 t.is(signal, 'SIGHUP');Fix `killSignal` option (#93)Kevin Mårtenssonbefore adoption2cbcc5c
line 477why, one step back477 });add tests (#48)James Talmagebefore adoptionb15483a
lines 478–479why, one step back478}479Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
line 480why, one step back480test('result.signal is undefined for successful execution', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 481–482why, one step back481 const {signal} = await execa('noop');482 t.is(signal, undefined);add tests (#48)James Talmagebefore adoptionb15483a
lines 483–484why, one step back483});484Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
line 485why, one step back485test('result.signal is undefined if process failed, but was not killed', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 486–487why, one step back486 const {signal} = await t.throwsAsync(execa('exit', [2]), {message: getExitRegExp('2')});487 t.is(signal, undefined);add tests (#48)James Talmagebefore adoptionb15483a
lines 488–489why, one step back488});489Remove `error.code` (#250)ehmickybefore adoptionbc0984e
lines 490–492why, one step back490async function testExitCode(t, num) {491 const {exitCode} = await t.throwsAsync(execa('exit', [`${num}`]), {message: getExitRegExp(num)});492 t.is(exitCode, num);add tests (#48)James Talmagebefore adoptionb15483a
lines 493–494why, one step back493}494Remove `error.code` (#250)ehmickybefore adoptionbc0984e
lines 495–497why, one step back495test('error.exitCode is 2', testExitCode, 2);496test('error.exitCode is 3', testExitCode, 3);497test('error.exitCode is 4', testExitCode, 4);add tests (#48)James Talmagebefore adoptionb15483a
line 498why, one step back498Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c
line 499why, one step back499test('timeout kills the process if it times out', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 500–502why, one step back500 const {killed, timedOut} = await t.throwsAsync(execa('forever', {timeout: 1, message: TIMEOUT_REGEXP}));501 t.false(killed);502 t.true(timedOut);Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d
lines 503–504why, one step back503});504Fix `error.timedOut` not working with `execa.sync()` (#249)ehmickybefore adoption21c706a
lines 505–512why, one step back505test('timeout kills the process if it times out, in sync mode', async t => {506 const {killed, timedOut} = await t.throws(() => {507 execa.sync('forever', {timeout: 1, message: TIMEOUT_REGEXP});508 });509 t.false(killed);510 t.true(timedOut);511});512Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c
line 513why, one step back513test('timeout does not kill the process if it does not time out', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 514–515why, one step back514 const {timedOut} = await execa('delay', ['500'], {timeout: 1e8});515 t.false(timedOut);Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d
lines 516–517why, one step back516});517Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c
line 518why, one step back518test('timedOut is false if no timeout was set', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 519–520why, one step back519 const {timedOut} = await execa('noop');520 t.false(timedOut);Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d
lines 521–522why, one step back521});522Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d
line 523why, one step back523test('timedOut will be false if no timeout was set and zero exit code in sync mode', t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 524–525why, one step back524 const {timedOut} = execa.sync('noop');525 t.false(timedOut);Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d
lines 526–527why, one step back526});527add tests (#48)James Talmagebefore adoptionb15483a
line 528why, one step back528async function errorMessage(t, expected, ...args) {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 529why, one step back529 await t.throwsAsync(execa('exit', args), {message: expected});add tests (#48)James Talmagebefore adoptionb15483a
lines 530–531why, one step back530}531Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 532why, one step back532errorMessage.title = (message, expected) => `error.message matches: ${expected}`;add tests (#48)James Talmagebefore adoptionb15483a
line 533why, one step back533Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
lines 534–535why, one step back534test(errorMessage, /Command failed with exit code 2.*: exit 2 foo bar/, 2, 'foo', 'bar');535test(errorMessage, /Command failed with exit code 3.*: exit 3 baz quz/, 3, 'baz', 'quz');add tests (#48)James Talmagebefore adoptionb15483a
line 536why, one step back536Rename `.cmd` to `.command` (#194)Satya Rohithbefore adoption95c8a14
line 537why, one step back537async function command(t, expected, ...args) {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 538–539why, one step back538 const {command: failCommand} = await t.throwsAsync(execa('fail', args));539 t.is(failCommand, `fail${expected}`);add tests (#48)James Talmagebefore adoptionb15483a
line 540why, one step back540Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 541–542why, one step back541 const {command} = await execa('noop', args);542 t.is(command, `noop${expected}`);add tests (#48)James Talmagebefore adoptionb15483a
lines 543–544why, one step back543}544Rename `.cmd` to `.command` (#194)Satya Rohithbefore adoption95c8a14
line 545why, one step back545command.title = (message, expected) => `command is: ${JSON.stringify(expected)}`;add tests (#48)James Talmagebefore adoptionb15483a
line 546why, one step back546Rename `.cmd` to `.command` (#194)Satya Rohithbefore adoption95c8a14
lines 547–549why, one step back547test(command, ' foo bar', 'foo', 'bar');548test(command, ' baz quz', 'baz', 'quz');549test(command, '');Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd
line 550why, one step back550Improve `cleanup` option (code quality, tests, documentation) (#225)ehmickybefore adoption659f444
lines 551–554why, one step back551// When child process exits before parent process552async function spawnAndExit(t, cleanup, detached) {553 await t.notThrowsAsync(execa('sub-process-exit', [cleanup, detached]));554}Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd
line 555why, one step back555Improve `cleanup` option (code quality, tests, documentation) (#225)ehmickybefore adoption659f444
lines 556–564why, one step back556test('spawnAndExit', spawnAndExit, false, false);557test('spawnAndExit cleanup', spawnAndExit, true, false);558test('spawnAndExit detached', spawnAndExit, false, true);559test('spawnAndExit cleanup detached', spawnAndExit, true, true);560561// When parent process exits before child process562async function spawnAndKill(t, signal, cleanup, detached, isKilled) {563 const subprocess = execa('sub-process', [cleanup, detached], {stdio: ['ignore', 'ignore', 'ignore', 'ipc']});564Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c
lines 565–567why, one step back565 const pid = await pEvent(subprocess, 'message');566 t.true(Number.isInteger(pid));567 t.true(isRunning(pid));Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd
line 568why, one step back568Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c
line 569why, one step back569 process.kill(subprocess.pid, signal);Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd
line 570why, one step back570Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c
line 571why, one step back571 await t.throwsAsync(subprocess);Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd
line 572why, one step back572Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c
lines 573–574why, one step back573 t.false(isRunning(subprocess.pid));574 t.is(isRunning(pid), !isKilled);Improve `cleanup` option (code quality, tests, documentation) (#225)ehmickybefore adoption659f444
lines 575–578why, one step back575576 if (!isKilled) {577 process.kill(pid, 'SIGKILL');578 }Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd
lines 579–580why, one step back579}580Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c
lines 581–587why, one step back581// Without `options.cleanup`:582// - on Windows subprocesses are killed if `options.detached: false`, but not583// if `options.detached: true`584// - on Linux subprocesses are never killed regardless of `options.detached`585// With `options.cleanup`, subprocesses are always killed586// - `options.cleanup` with SIGKILL is a noop, since it cannot be handled587const exitIfWindows = process.platform === 'win32';Improve `cleanup` option (code quality, tests, documentation) (#225)ehmickybefore adoption659f444
lines 588–595why, one step back588test('spawnAndKill SIGTERM', spawnAndKill, 'SIGTERM', false, false, exitIfWindows);589test('spawnAndKill SIGKILL', spawnAndKill, 'SIGKILL', false, false, exitIfWindows);590test('spawnAndKill cleanup SIGTERM', spawnAndKill, 'SIGTERM', true, false, true);591test('spawnAndKill cleanup SIGKILL', spawnAndKill, 'SIGKILL', true, false, exitIfWindows);592test('spawnAndKill detached SIGTERM', spawnAndKill, 'SIGTERM', false, true, false);593test('spawnAndKill detached SIGKILL', spawnAndKill, 'SIGKILL', false, true, false);594test('spawnAndKill cleanup detached SIGTERM', spawnAndKill, 'SIGTERM', true, true, false);595test('spawnAndKill cleanup detached SIGKILL', spawnAndKill, 'SIGKILL', true, true, false);fix support for the `shell` option in `execa.shell()`Sindre Sorhusbefore adoptiona80487b
line 596why, one step back596Attach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2
lines 597–598why, one step back597if (process.platform !== 'win32') {598 test('write to fast-exit process', async t => {Fix linting (#77)Sam Verschuerenbefore adoption80a059d
lines 599–600why, one step back599 // Try-catch here is necessary, because this test is not 100% accurate600 // Sometimes process can manage to accept input before exitingAttach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2
line 601why, one step back601 try {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 602why, one step back602 await execa(`fast-exit-${process.platform}`, [], {input: 'data'});Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 603why, one step back603 t.pass();Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 604why, one step back604 } catch (error) {Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
line 605why, one step back605 t.is(error.exitCode, 32);Attach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2
lines 606–608why, one step back606 }607 });608}Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117
line 609why, one step back609Fix extending from process.env when no env option is provided - fixes #101 (#102)Sam Verschuerenbefore adoptionafa9700
line 610why, one step back610test('use environment variables by default', async t => {Remove `execa.stdout()` and `execa.stderr()` (#234)ehmickybefore adoption3973fd4
line 611why, one step back611 const {stdout} = await execa('environment');Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 612why, one step back612 t.deepEqual(stdout.split('\n'), ['foo', 'undefined']);Fix extending from process.env when no env option is provided - fixes #101 (#102)Sam Verschuerenbefore adoptionafa9700
lines 613–614why, one step back613});614Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117
line 615why, one step back615test('extend environment variables by default', async t => {Remove `execa.stdout()` and `execa.stderr()` (#234)ehmickybefore adoption3973fd4
line 616why, one step back616 const {stdout} = await execa('environment', [], {env: {BAR: 'bar'}});Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 617why, one step back617 t.deepEqual(stdout.split('\n'), ['foo', 'bar']);Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117
lines 618–619why, one step back618});619Fix `extendEnv` option not working with `shell` option (#184)ehmickybefore adoptione897f44
line 620why, one step back620test('do not extend environment with `extendEnv: false`', async t => {Remove `execa.stdout()` and `execa.stderr()` (#234)ehmickybefore adoption3973fd4
line 621why, one step back621 const {stdout} = await execa('environment', [], {env: {BAR: 'bar', PATH: process.env.PATH}, extendEnv: false});Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 622why, one step back622 t.deepEqual(stdout.split('\n'), ['undefined', 'bar']);Remove `execa.shell()` and `execa.shellSync()` (#219)ehmickybefore adoption06f21c6
lines 623–630why, one step back623});624625test('can use `options.shell: true`', async t => {626 const {stdout} = await execa('node fixtures/noop foo', {shell: true});627 t.is(stdout, 'foo');628});629630test('can use `options.shell: string`', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 631–632why, one step back631 const shell = process.platform === 'win32' ? 'cmd.exe' : '/bin/bash';632 const {stdout} = await execa('node fixtures/noop foo', {shell});Remove `execa.shell()` and `execa.shellSync()` (#219)ehmickybefore adoption06f21c6
line 633why, one step back633 t.is(stdout, 'foo');Fix `extendEnv` option not working with `shell` option (#184)ehmickybefore adoptione897f44
lines 634–638why, one step back634});635636test('use extend environment with `extendEnv: true` and `shell: true`', async t => {637 process.env.TEST = 'test';638 const command = process.platform === 'win32' ? 'echo %TEST%' : 'echo $TEST';Remove `execa.stdout()` and `execa.stderr()` (#234)ehmickybefore adoption3973fd4
line 639why, one step back639 const {stdout} = await execa(command, {shell: true, env: {}, extendEnv: true});Fix `extendEnv` option not working with `shell` option (#184)ehmickybefore adoptione897f44
lines 640–641why, one step back640 t.is(stdout, 'test');641 delete process.env.TEST;Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117
line 642why, one step back642});Do not buffer when streams are used - fixes #84 (#95)Sam Verschuerenbefore adoption5bab08b
lines 643–644why, one step back643644test('do not buffer when streaming', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 645–646why, one step back645 const {stdout} = execa('max-buffer', ['stdout', '21'], {maxBuffer: 10});646 const result = await getStream(stdout);Do not buffer when streams are used - fixes #84 (#95)Sam Verschuerenbefore adoption5bab08b
lines 647–648why, one step back647 t.is(result, '....................\n');648});Detached child process should not kill child - fixes #115 (#117)Sam Verschuerenbefore adoption5f890ab
lines 649–650why, one step back649650test('detach child process', async t => {Fix `options.detached` test (#215)ehmickybefore adoption88585d2
lines 651–654why, one step back651 const {stdout} = await execa('detach');652 const pid = Number(stdout);653 t.true(Number.isInteger(pid));654 t.true(isRunning(pid));Detached child process should not kill child - fixes #115 (#117)Sam Verschuerenbefore adoption5f890ab
line 655why, one step back655Fix `options.detached` test (#215)ehmickybefore adoption88585d2
line 656why, one step back656 process.kill(pid, 'SIGKILL');Detached child process should not kill child - fixes #115 (#117)Sam Verschuerenbefore adoption5f890ab
line 657why, one step back657});Remove exit handler on exit (#129)Ryan Berdeenbefore adoption0defad4
lines 658–663why, one step back658659// See #128660test('removes exit handler on exit', async t => {661 // FIXME: This relies on `signal-exit` internals662 const ee = process.__signal_exit_emitter__;663Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 664why, one step back664 const child = execa('noop');Remove exit handler on exit (#129)Ryan Berdeenbefore adoption0defad4
lines 665–671why, one step back665 const listener = ee.listeners('exit').pop();666667 await new Promise((resolve, reject) => {668 child.on('error', reject);669 child.on('exit', resolve);670 });671Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 672why, one step back672 const included = ee.listeners('exit').includes(listener);Remove exit handler on exit (#129)Ryan Berdeenbefore adoption0defad4
line 673why, one step back673 t.false(included);Fix shape of exceptions rejected by `execa()` (#276)ehmickybefore adoption49c74ac
lines 674–684why, one step back674});675676test('promise methods are not enumerable', t => {677 const descriptors = Object.getOwnPropertyDescriptors(execa('noop'));678 // eslint-disable-next-line promise/prefer-await-to-then679 t.false(descriptors.then.enumerable);680 t.false(descriptors.catch.enumerable);681 // TOOD: Remove the `if`-guard when targeting Node.js 10682 if (Promise.prototype.finally) {683 t.false(descriptors.finally.enumerable);684 }Remove exit handler on exit (#129)Ryan Berdeenbefore adoption0defad4
line 685why, one step back685});Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
line 686why, one step back686Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 687why, one step back687// TOOD: Remove the `if`-guard when targeting Node.js 10Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 688–689why, one step back688if (Promise.prototype.finally) {689 test('finally function is executed on success', async t => {Minor test code style tweaksSindre Sorhusbefore adoptionf6db264
line 690why, one step back690 let isCalled = false;Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 691why, one step back691 const {stdout} = await execa('noop', ['foo']).finally(() => {Minor test code style tweaksSindre Sorhusbefore adoptionf6db264
line 692why, one step back692 isCalled = true;Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
line 693why, one step back693 });Minor test code style tweaksSindre Sorhusbefore adoptionf6db264
line 694why, one step back694 t.is(isCalled, true);Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 695–698why, one step back695 t.is(stdout, 'foo');696 });697698 test('finally function is executed on failure', async t => {Minor test code style tweaksSindre Sorhusbefore adoptionf6db264
line 699why, one step back699 let isError = false;Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 700why, one step back700 const {stdout, stderr} = await t.throwsAsync(execa('exit', ['2']).finally(() => {Minor test code style tweaksSindre Sorhusbefore adoptionf6db264
line 701why, one step back701 isError = true;Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
line 702why, one step back702 }));Minor test code style tweaksSindre Sorhusbefore adoptionf6db264
line 703why, one step back703 t.is(isError, true);Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 704–705why, one step back704 t.is(typeof stdout, 'string');705 t.is(typeof stderr, 'string');Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 706–708why, one step back706 });707708 test('throw in finally function bubbles up on success', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 709why, one step back709 const {message} = await t.throwsAsync(execa('noop', ['foo']).finally(() => {Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 710–711why, one step back710 throw new Error('called');711 }));Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 712why, one step back712 t.is(message, 'called');Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 713–715why, one step back713 });714715 test('throw in finally bubbles up on error', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 716why, one step back716 const {message} = await t.throwsAsync(execa('exit', ['2']).finally(() => {Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 717–718why, one step back717 throw new Error('called');718 }));Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 719why, one step back719 t.is(message, 'called');Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 720–721why, one step back720 });721}Make the spawned process cancelable (#189)Ammarbefore adoption79356cc
line 722why, one step back722Clean up #189Sindre Sorhusbefore adoptionf24e7c7
lines 723–726why, one step back723test('cancel method kills the subprocess', t => {724 const subprocess = execa('node');725 subprocess.cancel();726 t.true(subprocess.killed);Make the spawned process cancelable (#189)Ammarbefore adoption79356cc
lines 727–728why, one step back727});728Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d
line 729why, one step back729test('result.isCanceled is false when spawned.cancel() isn\'t called (success)', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 730–731why, one step back730 const {isCanceled} = await execa('noop');731 t.false(isCanceled);Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d
lines 732–734why, one step back732});733734test('result.isCanceled is false when spawned.cancel() isn\'t called (failure)', async t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 735–736why, one step back735 const {isCanceled} = await t.throwsAsync(execa('fail'));736 t.false(isCanceled);Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d
lines 737–739why, one step back737});738739test('result.isCanceled is false when spawned.cancel() isn\'t called in sync mode (success)', t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 740–741why, one step back740 const {isCanceled} = execa.sync('noop');741 t.false(isCanceled);Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d
lines 742–744why, one step back742});743744test('result.isCanceled is false when spawned.cancel() isn\'t called in sync mode (failure)', t => {Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 745why, one step back745 const {isCanceled} = t.throws(() => {Make `error.killed` more consistent (#248)ehmickybefore adoptionfd064a7
lines 746–747why, one step back746 execa.sync('fail');747 });Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 748why, one step back748 t.false(isCanceled);Make the spawned process cancelable (#189)Ammarbefore adoption79356cc
lines 749–751why, one step back749});750751test('calling cancel method throws an error with message "Command was canceled"', async t => {Clean up #189Sindre Sorhusbefore adoptionf24e7c7
lines 752–754why, one step back752 const subprocess = execa('noop');753 subprocess.cancel();754 await t.throwsAsync(subprocess, {message: /Command was canceled/});Make the spawned process cancelable (#189)Ammarbefore adoption79356cc
lines 755–757why, one step back755});756757test('error.isCanceled is true when cancel method is used', async t => {Clean up #189Sindre Sorhusbefore adoptionf24e7c7
lines 758–759why, one step back758 const subprocess = execa('noop');759 subprocess.cancel();Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 760–761why, one step back760 const {isCanceled} = await t.throwsAsync(subprocess);761 t.true(isCanceled);Make the spawned process cancelable (#189)Ammarbefore adoption79356cc
lines 762–764why, one step back762});763764test('error.isCanceled is false when kill method is used', async t => {Clean up #189Sindre Sorhusbefore adoptionf24e7c7
lines 765–766why, one step back765 const subprocess = execa('noop');766 subprocess.kill();Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 767–768why, one step back767 const {isCanceled} = await t.throwsAsync(subprocess);768 t.false(isCanceled);Make the spawned process cancelable (#189)Ammarbefore adoption79356cc
lines 769–771why, one step back769});770771test('calling cancel method twice should show the same behaviour as calling it once', async t => {Clean up #189Sindre Sorhusbefore adoptionf24e7c7
lines 772–774why, one step back772 const subprocess = execa('noop');773 subprocess.cancel();774 subprocess.cancel();Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 775–776why, one step back775 const {isCanceled} = await t.throwsAsync(subprocess);776 t.true(isCanceled);Clean up #189Sindre Sorhusbefore adoptionf24e7c7
line 777why, one step back777 t.true(subprocess.killed);Make the spawned process cancelable (#189)Ammarbefore adoption79356cc
lines 778–779why, one step back778});779Clean up #189Sindre Sorhusbefore adoptionf24e7c7
lines 780–781why, one step back780test('calling cancel method on a successfuly completed process does not make result.isCanceled true', async t => {781 const subprocess = execa('noop');Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 782why, one step back782 const {isCanceled} = await subprocess;Clean up #189Sindre Sorhusbefore adoptionf24e7c7
line 783why, one step back783 subprocess.cancel();Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
line 784why, one step back784 t.false(isCanceled);Make the spawned process cancelable (#189)Ammarbefore adoption79356cc
lines 785–787why, one step back785});786787test('calling cancel method on a process which has been killed does not make error.isCanceled true', async t => {Clean up #189Sindre Sorhusbefore adoptionf24e7c7
lines 788–789why, one step back788 const subprocess = execa('noop');789 subprocess.kill();Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd
lines 790–791why, one step back790 const {isCanceled} = await t.throwsAsync(subprocess);791 t.false(isCanceled);Add `execa.command()` (#261)ehmickybefore adoption6853316
lines 792–836why, one step back792});793794test('allow commands with spaces and no array arguments', async t => {795 const {stdout} = await execa('./fixtures/command with space');796 t.is(stdout, '');797});798799test('allow commands with spaces and array arguments', async t => {800 const {stdout} = await execa('./fixtures/command with space', ['foo', 'bar']);801 t.is(stdout, 'foo\nbar');802});803804test('execa.command()', async t => {805 const {stdout} = await execa.command('node fixtures/echo foo bar');806 t.is(stdout, 'foo\nbar');807});808809test('execa.command() ignores consecutive spaces', async t => {810 const {stdout} = await execa.command('node fixtures/echo foo bar');811 t.is(stdout, 'foo\nbar');812});813814test('execa.command() allows escaping spaces in commands', async t => {815 const {stdout} = await execa.command('./fixtures/command\\ with\\ space foo bar');816 t.is(stdout, 'foo\nbar');817});818819test('execa.command() allows escaping spaces in arguments', async t => {820 const {stdout} = await execa.command('node fixtures/echo foo\\ bar');821 t.is(stdout, 'foo bar');822});823824test('execa.command() escapes other whitespaces', async t => {825 const {stdout} = await execa.command('node fixtures/echo foo\tbar');826 t.is(stdout, 'foo\tbar');827});828829test('execa.command() trims', async t => {830 const {stdout} = await execa.command(' node fixtures/echo foo bar ');831 t.is(stdout, 'foo\nbar');832});833834test('execa.command.sync()', t => {835 const {stdout} = execa.commandSync('node fixtures/echo foo bar');836 t.is(stdout, 'foo\nbar');Make the spawned process cancelable (#189)Ammarbefore adoption79356cc
line 837why, one step back837});