test.js
This file
Path
test.js
642 lines · 19.5 KiB · JavaScript
Last changed by
Make the spawned process cancelable (#189)Ammarbefore adoption79356cc
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
lines 7–8why, one step back7import isRunning from 'is-running';8import delay from 'delay';Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 9why, one step back9import tempfile from 'tempfile';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 back14Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671
lines 15–16why, one step back15const NO_NEWLINES_REGEXP = /^[^\n]*$/;16const STDERR_STDOUT_REGEXP = /stderr[^]*stdout/;Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
line 17why, one step back17const TIMEOUT_REGEXP = /timed out after/;Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671
line 18why, one step back18Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 19why, one step back19const getExitRegExp = exitMessage => new RegExp(`failed with exit code ${exitMessage}`);Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
line 20why, one step back2021test('execa()', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 22why, one step back22 const {stdout} = await execa('noop', ['foo']);initSindre Sorhusbefore adoptionbc16d6b
lines 23–2523 t.is(stdout, 'foo');24});25Turn off echo on Windows - fixes #116 (#118)Sam Verschuerenbefore adoptionff76235
lines 26–27why, one step back26if (process.platform === 'win32') {27 test('execa() - cmd file', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 28why, one step back28 const {stdout} = await execa('hello.cmd');Turn off echo on Windows - fixes #116 (#118)Sam Verschuerenbefore adoptionff76235
lines 29–32why, one step back29 t.is(stdout, 'Hello World');30 });31}3233test('buffer', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 34why, one step back34 const {stdout} = await execa('noop', ['foo'], {encoding: null});initSindre Sorhusbefore adoptionbc16d6b
lines 35–3835 t.true(Buffer.isBuffer(stdout));36 t.is(stdout.toString(), 'foo');37});38add `execa.stdout()` shortcut (#14)Sindre Sorhusbefore adoption868f505
line 39why, one step back39test('execa.stdout()', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 40why, one step back40 const stdout = await execa.stdout('noop', ['foo']);add `execa.stdout()` shortcut (#14)Sindre Sorhusbefore adoption868f505
lines 41–44why, one step back41 t.is(stdout, 'foo');42});4344test('execa.stderr()', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 45why, one step back45 const stderr = await execa.stderr('noop-err', ['foo']);add `execa.stdout()` shortcut (#14)Sindre Sorhusbefore adoption868f505
lines 46–48why, one step back46 t.is(stderr, 'foo');47});48Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911
lines 49–54why, one step back49test.serial('result.all shows both `stdout` and `stderr` intermixed', async t => {50 const result = await execa('noop-132');51 t.is(result.all, '132');52});5354test('stdout/stderr/all available on errors', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 55why, one step back55 const err = await t.throwsAsync(execa('exit', ['2']), {message: getExitRegExp('2')});meta tweaksSindre Sorhusbefore adoption858af26
lines 56–57why, one step back56 t.is(typeof err.stdout, 'string');57 t.is(typeof err.stderr, 'string');Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911
line 58why, one step back58 t.is(typeof err.all, 'string');add `stdout`/`stderr` to errorsSindre Sorhusbefore adoption0ea8aaf
lines 59–60why, one step back59});60add tests (#48)James Talmagebefore adoptionb15483a
line 61why, one step back61test('include stdout and stderr in errors for improved debugging', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 62why, one step back62 await t.throwsAsync(execa('fixtures/error-message.js'), {message: STDERR_STDOUT_REGEXP, code: 1});include stdout in errors for improved debuggingSindre Sorhusbefore adoptionaea8c9a
lines 63–64why, one step back63});64Do not output stderr and stdout on stdio inherit - fixes #70 (#79)Sam Verschuerenbefore adoption2a12986
line 65why, one step back65test('do not include in errors when `stdio` is set to `inherit`', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 66why, one step back66 await t.throwsAsync(execa('fixtures/error-message.js', {stdio: 'inherit'}), {message: NO_NEWLINES_REGEXP});Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 67–69why, one step back67});6869test('do not include `stderr` and `stdout` in errors when set to `inherit`', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 70why, one step back70 await t.throwsAsync(execa('fixtures/error-message.js', {stdout: 'inherit', stderr: 'inherit'}), {message: NO_NEWLINES_REGEXP});Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 71–73why, one step back71});7273test('do not include `stderr` and `stdout` in errors when `stdio` is set to `inherit`', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 74why, one step back74 await t.throwsAsync(execa('fixtures/error-message.js', {stdio: [null, 'inherit', 'inherit']}), {message: NO_NEWLINES_REGEXP});Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 75–77why, one step back75});7677test('do not include `stdout` in errors when set to `inherit`', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 78why, one step back78 const err = await t.throwsAsync(execa('fixtures/error-message.js', {stdout: 'inherit'}), {message: /stderr/});Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 79–82why, one step back79 t.notRegex(err.message, /stdout/);80});8182test('do not include `stderr` in errors when set to `inherit`', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 83why, one step back83 const err = await t.throwsAsync(execa('fixtures/error-message.js', {stderr: 'inherit'}), {message: /stdout/});Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 84–88why, one step back84 t.notRegex(err.message, /stderr/);85});8687test('pass `stdout` to a file descriptor', async t => {88 const file = tempfile('.txt');Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 89why, one step back89 await execa('fixtures/noop', ['foo bar'], {stdout: fs.openSync(file, 'w')});Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 90–94why, one step back90 t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');91});9293test('pass `stderr` to a file descriptor', async t => {94 const file = tempfile('.txt');Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 95why, one step back95 await execa('fixtures/noop-err', ['foo bar'], {stderr: fs.openSync(file, 'w')});Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 96why, one step back96 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 97–98why, one step back97});98Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
line 99why, one step back99test('execa.shell()', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 100why, one step back100 const {stdout} = await execa.shell('node fixtures/noop foo');Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
lines 101–103why, one step back101 t.is(stdout, 'foo');102});103add `execa.sync()` (#7)Sindre Sorhusbefore adoption9345d2c
line 104why, one step back104test('execa.sync()', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 105why, one step back105 const {stdout} = execa.sync('noop', ['foo']);add `execa.sync()` (#7)Sindre Sorhusbefore adoption9345d2c
lines 106–108why, one step back106 t.is(stdout, 'foo');107});108Throw error in sync method - fixes #66 (#67)Sam Verschuerenbefore adoptionc8c9c7b
line 109why, one step back109test('execa.sync() throws error if written to stderr', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 110why, one step back110 t.throws(() => execa.sync('foo'), process.platform === 'win32' ? /'foo' is not recognized as an internal or external command/ : /spawnSync foo ENOENT/);Throw error in sync method - fixes #66 (#67)Sam Verschuerenbefore adoptionc8c9c7b
lines 111–112why, one step back111});112Enhance error object in sync methods - fixes #98 (#107)Sam Verschuerenbefore adoptiond31cc91
line 113why, one step back113test('execa.sync() includes stdout and stderr in errors for improved debugging', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 114why, one step back114 t.throws(() => execa.sync('node', ['fixtures/error-message.js']), {message: STDERR_STDOUT_REGEXP, code: 1});Enhance error object in sync methods - fixes #98 (#107)Sam Verschuerenbefore adoptiond31cc91
lines 115–117why, one step back115});116117test('skip throwing when using reject option in execa.sync()', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 118why, one step back118 const err = execa.sync('node', ['fixtures/error-message.js'], {reject: false});Enhance error object in sync methods - fixes #98 (#107)Sam Verschuerenbefore adoptiond31cc91
lines 119–122why, one step back119 t.is(typeof err.stdout, 'string');120 t.is(typeof err.stderr, 'string');121});122add `execa.shellSync()`Sindre Sorhusbefore adoption71a58ee
line 123why, one step back123test('execa.shellSync()', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 124why, one step back124 const {stdout} = execa.shellSync('node fixtures/noop foo');add `execa.shellSync()`Sindre Sorhusbefore adoption71a58ee
line 125why, one step back125 t.is(stdout, 'foo');Enhance error object in sync methods - fixes #98 (#107)Sam Verschuerenbefore adoptiond31cc91
lines 126–128why, one step back126});127128test('execa.shellSync() includes stdout and stderr in errors for improved debugging', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 129why, one step back129 t.throws(() => execa.shellSync('node fixtures/error-message.js'), {message: STDERR_STDOUT_REGEXP, code: 1});Enhance error object in sync methods - fixes #98 (#107)Sam Verschuerenbefore adoptiond31cc91
lines 130–132why, one step back130});131132test('skip throwing when using reject option in execa.shellSync()', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 133why, one step back133 const err = execa.shellSync('node fixtures/error-message.js', {reject: false});Enhance error object in sync methods - fixes #98 (#107)Sam Verschuerenbefore adoptiond31cc91
lines 134–135why, one step back134 t.is(typeof err.stdout, 'string');135 t.is(typeof err.stderr, 'string');add `execa.shellSync()`Sindre Sorhusbefore adoption71a58ee
lines 136–137why, one step back136});137Rename `stripEof` option to `stripFinalNewline`Sindre Sorhusbefore adoptionf8397ba
line 138why, one step back138test('stripEof option (legacy)', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 139why, one step back139 const {stdout} = await execa('noop', ['foo'], {stripEof: false});Rename `stripEof` option to `stripFinalNewline`Sindre Sorhusbefore adoptionf8397ba
lines 140–143why, one step back140 t.is(stdout, 'foo\n');141});142143test('stripFinalNewline option', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 144why, one step back144 const {stdout} = await execa('noop', ['foo'], {stripFinalNewline: false});initSindre Sorhusbefore adoptionbc16d6b
lines 145–147145 t.is(stdout, 'foo\n');146});147Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
line 148why, one step back148test.serial('preferLocal option', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 149why, one step back149 t.true((await execa('cat-names')).stdout.length > 2);Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
line 150why, one step back150fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
lines 151–155why, one step back151 if (process.platform === 'win32') {152 // TODO: figure out how to make the below not hang on Windows153 return;154 }155Fix linting (#77)Sam Verschuerenbefore adoption80a059d
line 156why, one step back156 // Account for npm adding local binaries to the PATHMerge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
lines 157–158why, one step back157 const _path = process.env.PATH;158 process.env.PATH = '';Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 159why, one step back159 await t.throwsAsync(execa('cat-names', {preferLocal: false}), /spawn .* ENOENT/);Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
line 160why, one step back160 process.env.PATH = _path;add `input` optionJames Talmagebefore adoption605a674
lines 161–162why, one step back161});162Fix test flakiness on WindowsSindre Sorhusbefore adoptionf071546
line 163why, one step back163test.serial('localDir option', async t => {Add test for #73Sindre Sorhusbefore adoptionc7481f4
lines 164–166why, one step back164 const cwd = 'fixtures/local-dir';165 const bin = path.resolve(cwd, 'node_modules/.bin/self-path');166Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 167why, one step back167 await execa('npm', ['install', '--no-package-lock'], {cwd});Add test for #73Sindre Sorhusbefore adoptionc7481f4
line 168why, one step back168Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 169why, one step back169 const {stdout} = await execa(bin, {localDir: cwd});Add test for #73Sindre Sorhusbefore adoptionc7481f4
line 170why, one step back170Meta tweaksSindre Sorhusbefore adoptionc0fc20c
line 171why, one step back171 t.is(path.relative(cwd, stdout), path.normalize('node_modules/self-path'));Add test for #73Sindre Sorhusbefore adoptionc7481f4
lines 172–173why, one step back172});173add `input` optionJames Talmagebefore adoption605a674
line 174why, one step back174test('input option can be a String', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 175why, one step back175 const {stdout} = await execa('stdin', {input: 'foobar'});add `input` optionJames Talmagebefore adoption605a674
lines 176–179why, one step back176 t.is(stdout, 'foobar');177});178179test('input option can be a Buffer', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 180why, one step back180 const {stdout} = await execa('stdin', {input: 'testing12'});add `input` optionJames Talmagebefore adoption605a674
lines 181–184why, one step back181 t.is(stdout, 'testing12');182});183184test('input can be a Stream', async t => {[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 185why, one step back185 const s = new stream.PassThrough();add `input` optionJames Talmagebefore adoption605a674
lines 186–187why, one step back186 s.write('howdy');187 s.end();Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 188why, one step back188 const {stdout} = await execa('stdin', {input: s});add `input` optionJames Talmagebefore adoption605a674
lines 189–191why, one step back189 t.is(stdout, 'howdy');190});191return the child process instead of a promise. (#18)James Talmagebefore adoption99f10ba
line 192why, one step back192test('you can write to child.stdin', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 193why, one step back193 const child = execa('stdin');return the child process instead of a promise. (#18)James Talmagebefore adoption99f10ba
lines 194–197why, one step back194 child.stdin.end('unicorns');195 t.is((await child).stdout, 'unicorns');196});197Fix linting (#77)Sam Verschuerenbefore adoption80a059d
line 198why, one step back198test('input option can be a String - sync', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 199why, one step back199 const {stdout} = execa.sync('stdin', {input: 'foobar'});add `input` optionJames Talmagebefore adoption605a674
lines 200–202why, one step back200 t.is(stdout, 'foobar');201});202Fix linting (#77)Sam Verschuerenbefore adoption80a059d
line 203why, one step back203test('input option can be a Buffer - sync', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 204why, one step back204 const {stdout} = execa.sync('stdin', {input: Buffer.from('testing12', 'utf8')});add `input` optionJames Talmagebefore adoption605a674
line 205why, one step back205 t.is(stdout, 'testing12');Use spawn instead of execFile (#27)James Talmagebefore adoption31a8d87
lines 206–208why, one step back206});207208test('opts.stdout:ignore - stdout will not collect data', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 209why, one step back209 const {stdout} = await execa('stdin', {fix XO lint issuesSindre Sorhusbefore adoption342096c
lines 210–212why, one step back210 input: 'hello',211 stdio: [null, 'ignore', null]212 });Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
line 213why, one step back213 t.is(stdout, undefined);add `input` optionJames Talmagebefore adoption605a674
lines 214–217why, one step back214});215216test('helpful error trying to provide an input stream in sync mode', t => {217 t.throws(Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 218why, one step back218 () => execa.sync('stdin', {input: new stream.PassThrough()}),add `input` optionJames Talmagebefore adoption605a674
lines 219–220why, one step back219 /The `input` option cannot be a stream in sync mode/220 );Attach pid and kill() to returned promise (#11)Luke Horvatbefore adoption9da5484
lines 221–223why, one step back221});222223test('execa() returns a promise with kill() and pid', t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 224why, one step back224 const promise = execa('noop', ['foo']);Attach pid and kill() to returned promise (#11)Luke Horvatbefore adoption9da5484
lines 225–226why, one step back225 t.is(typeof promise.kill, 'function');226 t.is(typeof promise.pid, 'number');227});add max-buffer support (#37)James Talmagebefore adoption6288806
line 228why, one step back228Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 229why, one step back229test('maxBuffer affects stdout', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
lines 230–231why, one step back230 await t.throwsAsync(execa('max-buffer', ['stdout', '11'], {maxBuffer: 10}), /stdout maxBuffer exceeded/);231 await t.notThrowsAsync(execa('max-buffer', ['stdout', '10'], {maxBuffer: 10}));add max-buffer support (#37)James Talmagebefore adoption6288806
lines 232–233why, one step back232});233Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 234why, one step back234test('maxBuffer affects stderr', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
lines 235–236why, one step back235 await t.throwsAsync(execa('max-buffer', ['stderr', '13'], {maxBuffer: 12}), /stderr maxBuffer exceeded/);236 await t.notThrowsAsync(execa('max-buffer', ['stderr', '12'], {maxBuffer: 12}));add max-buffer support (#37)James Talmagebefore adoption6288806
line 237why, one step back237});Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
line 238why, one step back238Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa
line 239why, one step back239test('do not buffer stdout when `buffer` set to `false`', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 240why, one step back240 const promise = execa('max-buffer', ['stdout', '10'], {buffer: false});Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa
lines 241–242why, one step back241 const [result, stdout] = await Promise.all([242 promise,Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911
lines 243–244why, one step back243 getStream(promise.stdout),244 getStream(promise.all)Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa
lines 245–251why, one step back245 ]);246247 t.is(result.stdout, undefined);248 t.is(stdout, '.........\n');249});250251test('do not buffer stderr when `buffer` set to `false`', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 252why, one step back252 const promise = execa('max-buffer', ['stderr', '10'], {buffer: false});Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa
lines 253–254why, one step back253 const [result, stderr] = await Promise.all([254 promise,Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911
lines 255–256why, one step back255 getStream(promise.stderr),256 getStream(promise.all)Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa
lines 257–262why, one step back257 ]);258259 t.is(result.stderr, undefined);260 t.is(stderr, '.........\n');261});262Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
line 263why, one step back263test('skip throwing when using reject option', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 264why, one step back264 const error = await execa('exit', ['2'], {reject: false});Fix lint issuesSindre Sorhusbefore adoptionb7752fb
lines 265–266why, one step back265 t.is(typeof error.stdout, 'string');266 t.is(typeof error.stderr, 'string');Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
lines 267–268why, one step back267});268Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
line 269why, one step back269test('allow unknown exit code', async t => {Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
lines 270–272why, one step back270 const {exitCode, exitCodeName} = await t.throwsAsync(execa('exit', ['255']), {message: /exit code 255 \(Unknown system error -255\)/});271 t.is(exitCode, 255);272 t.is(exitCodeName, 'Unknown system error -255');Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
lines 273–274why, one step back273});274Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
line 275why, one step back275test('execa() returns code and failed properties', async t => {Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
line 276why, one step back276 const {code, exitCode, exitCodeName, failed} = await execa('noop', ['foo']);Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
line 277why, one step back277 t.is(code, 0);Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
lines 278–279why, one step back278 t.is(exitCode, 0);279 t.is(exitCodeName, 'SUCCESS');Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
line 280why, one step back280 t.false(failed);Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
lines 281–285why, one step back281282 const error = await t.throwsAsync(execa('exit', ['2']), {code: 2, message: getExitRegExp('2')});283 t.is(error.exitCode, 2);284 const expectedName = process.platform === 'win32' ? 'Unknown system error -2' : 'ENOENT';285 t.is(error.exitCodeName, expectedName);Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 286why, one step back286 t.true(error.failed);Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
line 287why, one step back287});Add test for `../` paths (#43)James Talmagebefore adoption56a20b1
line 288why, one step back288Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 289why, one step back289test('use relative path with \'..\' chars', async t => {Add test for `../` paths (#43)James Talmagebefore adoption56a20b1
line 290why, one step back290 const pathViaParentDir = path.join('..', path.basename(__dirname), 'fixtures', 'noop');Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 291why, one step back291 const {stdout} = await execa(pathViaParentDir, ['foo']);Add test for `../` paths (#43)James Talmagebefore adoption56a20b1
lines 292–293why, one step back292 t.is(stdout, 'foo');293});add tests (#48)James Talmagebefore adoptionb15483a
line 294why, one step back294add test case for throwing on non-executables (#49)Markus Wolfbefore adoptione10d263
line 295why, one step back295if (process.platform !== 'win32') {Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 296why, one step back296 test('execa() rejects if running non-executable', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 297why, one step back297 const cp = execa('non-executable');Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671
line 298why, one step back298 await t.throwsAsync(cp);add test case for throwing on non-executables (#49)Markus Wolfbefore adoptione10d263
lines 299–301why, one step back299 });300}301Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 302why, one step back302test('error.killed is true if process was killed directly', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 303why, one step back303 const cp = execa('forever');add tests (#48)James Talmagebefore adoptionb15483a
line 304why, one step back304[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 305why, one step back305 setTimeout(() => {add tests (#48)James Talmagebefore adoptionb15483a
lines 306–308why, one step back306 cp.kill();307 }, 100);308Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
line 309why, one step back309 const error = await t.throwsAsync(cp, {message: /was killed with SIGTERM/});Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 310why, one step back310 t.true(error.killed);add tests (#48)James Talmagebefore adoptionb15483a
lines 311–313why, one step back311});312313// TODO: Should this really be the case, or should we improve on child_process?Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 314why, one step back314test('error.killed is false if process was killed indirectly', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 315why, one step back315 const cp = execa('forever');add tests (#48)James Talmagebefore adoptionb15483a
line 316why, one step back316[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 317why, one step back317 setTimeout(() => {add tests (#48)James Talmagebefore adoptionb15483a
lines 318–320why, one step back318 process.kill(cp.pid, 'SIGINT');319 }, 100);320Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
lines 321–323why, one step back321 // `process.kill()` is emulated by Node.js on Windows322 const message = process.platform === 'win32' ? /failed with exit code 1/ : /was killed with SIGINT/;323 const error = await t.throwsAsync(cp, {message});Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 324why, one step back324 t.false(error.killed);add tests (#48)James Talmagebefore adoptionb15483a
lines 325–328why, one step back325});326327if (process.platform === 'darwin') {328 test.cb('sanity check: child_process.exec also has killed.false if killed indirectly', t => {Fix lint issuesSindre Sorhusbefore adoptionb7752fb
lines 329–331why, one step back329 const cp = childProcess.exec('forever', error => {330 t.truthy(error);331 t.false(error.killed);add tests (#48)James Talmagebefore adoptionb15483a
lines 332–334why, one step back332 t.end();333 });334[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 335why, one step back335 setTimeout(() => {add tests (#48)James Talmagebefore adoptionb15483a
lines 336–341why, one step back336 process.kill(cp.pid, 'SIGINT');337 }, 100);338 });339}340341if (process.platform !== 'win32') {Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 342why, one step back342 test('error.signal is SIGINT', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 343why, one step back343 const cp = execa('forever');add tests (#48)James Talmagebefore adoptionb15483a
line 344why, one step back344[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 345why, one step back345 setTimeout(() => {add tests (#48)James Talmagebefore adoptionb15483a
lines 346–348why, one step back346 process.kill(cp.pid, 'SIGINT');347 }, 100);348Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
line 349why, one step back349 const error = await t.throwsAsync(cp, {message: /was killed with SIGINT/});Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 350why, one step back350 t.is(error.signal, 'SIGINT');add tests (#48)James Talmagebefore adoptionb15483a
lines 351–352why, one step back351 });352Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 353why, one step back353 test('error.signal is SIGTERM', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 354why, one step back354 const cp = execa('forever');add tests (#48)James Talmagebefore adoptionb15483a
line 355why, one step back355[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 356why, one step back356 setTimeout(() => {add tests (#48)James Talmagebefore adoptionb15483a
lines 357–359why, one step back357 process.kill(cp.pid, 'SIGTERM');358 }, 100);359Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
line 360why, one step back360 const error = await t.throwsAsync(cp, {message: /was killed with SIGTERM/});Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 361why, one step back361 t.is(error.signal, 'SIGTERM');add tests (#48)James Talmagebefore adoptionb15483a
line 362why, one step back362 });Fix `killSignal` option (#93)Kevin Mårtenssonbefore adoption2cbcc5c
line 363why, one step back363Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 364why, one step back364 test('custom error.signal', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 365why, one step back365 const error = await t.throwsAsync(execa('delay', ['3000', '0'], {killSignal: 'SIGHUP', timeout: 1500, message: TIMEOUT_REGEXP}));Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 366why, one step back366 t.is(error.signal, 'SIGHUP');Fix `killSignal` option (#93)Kevin Mårtenssonbefore adoption2cbcc5c
line 367why, one step back367 });add tests (#48)James Talmagebefore adoptionb15483a
lines 368–369why, one step back368}369Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
lines 370–371why, one step back370test('result.signal is undefined for successful execution', async t => {371 t.is((await execa('noop')).signal, undefined);add tests (#48)James Talmagebefore adoptionb15483a
lines 372–373why, one step back372});373Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
line 374why, one step back374test('result.signal is undefined if process failed, but was not killed', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 375why, one step back375 const error = await t.throwsAsync(execa('exit', [2]), {message: getExitRegExp('2')});Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
line 376why, one step back376 t.is(error.signal, undefined);add tests (#48)James Talmagebefore adoptionb15483a
lines 377–379why, one step back377});378379async function code(t, num) {Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
lines 380–381why, one step back380 const error = await t.throwsAsync(execa('exit', [`${num}`]), {code: num, message: getExitRegExp(num)});381 t.is(error.exitCode, num);add tests (#48)James Talmagebefore adoptionb15483a
lines 382–383why, one step back382}383Fix lint issuesSindre Sorhusbefore adoptionb7752fb
lines 384–386why, one step back384test('error.code is 2', code, 2);385test('error.code is 3', code, 3);386test('error.code is 4', code, 4);add tests (#48)James Talmagebefore adoptionb15483a
line 387why, one step back387Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d
line 388why, one step back388test('timeout will kill the process early', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 389why, one step back389 const error = await t.throwsAsync(execa('delay', ['60000', '0'], {timeout: 1500, message: TIMEOUT_REGEXP}));Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d
line 390why, one step back390Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 391why, one step back391 t.true(error.timedOut);Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
line 392why, one step back392 t.not(error.exitCode, 22);Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d
lines 393–395why, one step back393});394395test('timeout will not kill the process early', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 396why, one step back396 const error = await t.throwsAsync(execa('delay', ['3000', '22'], {timeout: 30000}), {code: 22, message: getExitRegExp('22')});Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 397why, one step back397 t.false(error.timedOut);Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d
lines 398–400why, one step back398});399400test('timedOut will be false if no timeout was set and zero exit code', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 401why, one step back401 const result = await execa('delay', ['1000', '0']);Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d
lines 402–405why, one step back402 t.false(result.timedOut);403});404405test('timedOut will be false if no timeout was set and non-zero exit code', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 406why, one step back406 const error = await t.throwsAsync(execa('delay', ['1000', '3']), {message: getExitRegExp('3')});Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 407why, one step back407 t.false(error.timedOut);Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d
lines 408–409why, one step back408});409add tests (#48)James Talmagebefore adoptionb15483a
line 410why, one step back410async function errorMessage(t, expected, ...args) {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 411why, one step back411 await t.throwsAsync(execa('exit', args), {message: expected});add tests (#48)James Talmagebefore adoptionb15483a
lines 412–413why, one step back412}413Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 414why, one step back414errorMessage.title = (message, expected) => `error.message matches: ${expected}`;add tests (#48)James Talmagebefore adoptionb15483a
line 415why, one step back415Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4
lines 416–417why, one step back416test(errorMessage, /Command failed with exit code 2.*: exit 2 foo bar/, 2, 'foo', 'bar');417test(errorMessage, /Command failed with exit code 3.*: exit 3 baz quz/, 3, 'baz', 'quz');add tests (#48)James Talmagebefore adoptionb15483a
lines 418–419why, one step back418419async function cmd(t, expected, ...args) {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 420why, one step back420 const error = await t.throwsAsync(execa('fail', args));Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 421why, one step back421 t.is(error.cmd, `fail${expected}`);add tests (#48)James Talmagebefore adoptionb15483a
line 422why, one step back422Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 423why, one step back423 const result = await execa('noop', args);add tests (#48)James Talmagebefore adoptionb15483a
lines 424–431why, one step back424 t.is(result.cmd, `noop${expected}`);425}426427cmd.title = (message, expected) => `cmd is: ${JSON.stringify(expected)}`;428429test(cmd, ' foo bar', 'foo', 'bar');430test(cmd, ' baz quz', 'baz', 'quz');431test(cmd, '');Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd
lines 432–434why, one step back432433async function spawnAndKill(t, signal, cleanup) {434 const name = cleanup ? 'sub-process' : 'sub-process-false';Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 435why, one step back435 const cp = execa(name);Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd
lines 436–447why, one step back436 let pid;437438 cp.stdout.setEncoding('utf8');439 cp.stdout.on('data', chunk => {440 pid = parseInt(chunk, 10);441 t.is(typeof pid, 'number');442443 setTimeout(() => {444 process.kill(cp.pid, signal);445 }, 100);446 });447Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671
line 448why, one step back448 await t.throwsAsync(cp);Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd
lines 449–464why, one step back449450 // Give everybody some time to breath and kill things451 await delay(200);452453 t.false(isRunning(cp.pid));454 t.is(isRunning(pid), !cleanup);455}456457test('cleanup - SIGINT', spawnAndKill, 'SIGINT', true);458test('cleanup - SIGKILL', spawnAndKill, 'SIGTERM', true);459460if (process.platform !== 'win32') {461 // On Windows the subprocesses are actually always killed462 test('cleanup false - SIGINT', spawnAndKill, 'SIGTERM', false);463 test('cleanup false - SIGKILL', spawnAndKill, 'SIGKILL', false);464}fix support for the `shell` option in `execa.shell()`Sindre Sorhusbefore adoptiona80487b
line 465why, one step back465Fix Windows test related to `shell` option (#185)ehmickybefore adoptioneac23b0
line 466why, one step back466test('execa.shell() supports the `shell` option', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 467why, one step back467 const {stdout} = await execa.shell('node fixtures/noop foo', {fix support for the `shell` option in `execa.shell()`Sindre Sorhusbefore adoptiona80487b
lines 468–471why, one step back468 shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash'469 });470 t.is(stdout, 'foo');471});Attach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2
lines 472–474why, one step back472473if (process.platform !== 'win32') {474 test('write to fast-exit process', async t => {Fix linting (#77)Sam Verschuerenbefore adoption80a059d
lines 475–476why, one step back475 // Try-catch here is necessary, because this test is not 100% accurate476 // Sometimes process can manage to accept input before exitingAttach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2
line 477why, one step back477 try {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 478why, one step back478 await execa(`fast-exit-${process.platform}`, [], {input: 'data'});Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 479why, one step back479 t.pass();Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 480why, one step back480 } catch (error) {Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2
line 481why, one step back481 t.is(error.exitCode, 32);Attach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2
lines 482–484why, one step back482 }483 });484}Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117
line 485why, one step back485Fix extending from process.env when no env option is provided - fixes #101 (#102)Sam Verschuerenbefore adoptionafa9700
line 486why, one step back486test('use environment variables by default', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 487why, one step back487 const result = await execa.stdout('environment');Fix extending from process.env when no env option is provided - fixes #101 (#102)Sam Verschuerenbefore adoptionafa9700
lines 488–494why, one step back488489 t.deepEqual(result.split('\n'), [490 'foo',491 'undefined'492 ]);493});494Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117
line 495why, one step back495test('extend environment variables by default', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 496why, one step back496 const result = await execa.stdout('environment', [], {env: {BAR: 'bar'}});Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117
lines 497–503why, one step back497498 t.deepEqual(result.split('\n'), [499 'foo',500 'bar'501 ]);502});503Fix `extendEnv` option not working with `shell` option (#184)ehmickybefore adoptione897f44
line 504why, one step back504test('do not extend environment with `extendEnv: false`', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 505why, one step back505 const result = await execa.stdout('environment', [], {env: {BAR: 'bar', PATH: process.env.PATH}, extendEnv: false});Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117
lines 506–510why, one step back506507 t.deepEqual(result.split('\n'), [508 'undefined',509 'bar'510 ]);Fix `extendEnv` option not working with `shell` option (#184)ehmickybefore adoptione897f44
lines 511–515why, one step back511});512513test('use extend environment with `extendEnv: true` and `shell: true`', async t => {514 process.env.TEST = 'test';515 const command = process.platform === 'win32' ? 'echo %TEST%' : 'echo $TEST';Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 516why, one step back516 const stdout = await execa.stdout(command, {shell: true, env: {}, extendEnv: true});Fix `extendEnv` option not working with `shell` option (#184)ehmickybefore adoptione897f44
lines 517–518why, one step back517 t.is(stdout, 'test');518 delete process.env.TEST;Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117
line 519why, one step back519});Do not buffer when streams are used - fixes #84 (#95)Sam Verschuerenbefore adoption5bab08b
lines 520–521why, one step back520521test('do not buffer when streaming', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 522why, one step back522 const result = await getStream(execa('max-buffer', ['stdout', '21'], {maxBuffer: 10}).stdout);Do not buffer when streams are used - fixes #84 (#95)Sam Verschuerenbefore adoption5bab08b
lines 523–525why, one step back523524 t.is(result, '....................\n');525});Detached child process should not kill child - fixes #115 (#117)Sam Verschuerenbefore adoption5f890ab
lines 526–529why, one step back526527test('detach child process', async t => {528 const file = tempfile('.txt');529Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 530why, one step back530 await execa('detach', [file]);Detached child process should not kill child - fixes #115 (#117)Sam Verschuerenbefore adoption5f890ab
line 531why, one step back531Increase delay of detached child process (#120)Sam Verschuerenbefore adoption8fb8b6d
line 532why, one step back532 await delay(5000);Detached child process should not kill child - fixes #115 (#117)Sam Verschuerenbefore adoption5f890ab
lines 533–535why, one step back533534 t.is(fs.readFileSync(file, 'utf8'), 'foo\n');535});Remove exit handler on exit (#129)Ryan Berdeenbefore adoption0defad4
lines 536–541why, one step back536537// See #128538test('removes exit handler on exit', async t => {539 // FIXME: This relies on `signal-exit` internals540 const ee = process.__signal_exit_emitter__;541Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 542why, one step back542 const child = execa('noop');Remove exit handler on exit (#129)Ryan Berdeenbefore adoption0defad4
lines 543–549why, one step back543 const listener = ee.listeners('exit').pop();544545 await new Promise((resolve, reject) => {546 child.on('error', reject);547 child.on('exit', resolve);548 });549Fix lint issuesSindre Sorhusbefore adoptionb7752fb
line 550why, one step back550 const included = ee.listeners('exit').includes(listener);Remove exit handler on exit (#129)Ryan Berdeenbefore adoption0defad4
lines 551–552why, one step back551 t.false(included);552});Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
line 553why, one step back553Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 554why, one step back554// TOOD: Remove the `if`-guard when targeting Node.js 10Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 555–557why, one step back555if (Promise.prototype.finally) {556 test('finally function is executed on success', async t => {557 let called = false;Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 558why, one step back558 const {stdout} = await execa('noop', ['foo']).finally(() => {Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 559–566why, one step back559 called = true;560 });561 t.is(called, true);562 t.is(stdout, 'foo');563 });564565 test('finally function is executed on failure', async t => {566 let called = false;Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 567why, one step back567 const err = await t.throwsAsync(execa('exit', ['2']).finally(() => {Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 568–575why, one step back568 called = true;569 }));570 t.is(called, true);571 t.is(typeof err.stdout, 'string');572 t.is(typeof err.stderr, 'string');573 });574575 test('throw in finally function bubbles up on success', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 576why, one step back576 const result = await t.throwsAsync(execa('noop', ['foo']).finally(() => {Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 577–582why, one step back577 throw new Error('called');578 }));579 t.is(result.message, 'called');580 });581582 test('throw in finally bubbles up on error', async t => {Require Node.js 8Sindre Sorhusbefore adoptiondce2267
line 583why, one step back583 const result = await t.throwsAsync(execa('exit', ['2']).finally(() => {Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669
lines 584–588why, one step back584 throw new Error('called');585 }));586 t.is(result.message, 'called');587 });588}Make the spawned process cancelable (#189)Ammarbefore adoption79356cc
lines 589–642why, one step back589590test('cancel method kills the spawned process', t => {591 const spawned = execa('node');592 spawned.cancel();593 t.true(spawned.killed);594});595596test('result.isCanceled is false when spawned.cancel isn\'t called', async t => {597 const result = await execa('noop');598 t.false(result.isCanceled);599});600601test('calling cancel method throws an error with message "Command was canceled"', async t => {602 const spawned = execa('noop');603 spawned.cancel();604 await t.throwsAsync(spawned, {message: /Command was canceled/});605});606607test('error.isCanceled is true when cancel method is used', async t => {608 const spawned = execa('noop');609 spawned.cancel();610 const error = await t.throwsAsync(spawned);611 t.true(error.isCanceled);612});613614test('error.isCanceled is false when kill method is used', async t => {615 const spawned = execa('noop');616 spawned.kill();617 const error = await t.throwsAsync(spawned);618 t.false(error.isCanceled);619});620621test('calling cancel method twice should show the same behaviour as calling it once', async t => {622 const spawned = execa('noop');623 spawned.cancel();624 spawned.cancel();625 const error = await t.throwsAsync(spawned);626 t.true(error.isCanceled);627 t.true(spawned.killed);628});629630test('calling cancel method on a successfuly completed process does not make result.cancel true', async t => {631 const spawned = execa('noop');632 const result = await spawned;633 spawned.cancel();634 t.false(result.isCanceled);635});636637test('calling cancel method on a process which has been killed does not make error.isCanceled true', async t => {638 const spawned = execa('noop');639 spawned.kill();640 const error = await t.throwsAsync(spawned);641 t.false(error.isCanceled);642});