test.js
This file
Path
test.js
450 lines · 12.3 KiB · JavaScript
Last changed by
Meta tweaksSindre Sorhusbefore adoptionc0fc20c
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';tweaksSindre Sorhusbefore adoptione3505a8
line 10why, one step back10import m 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 back1415test('execa()', async t => {fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
line 16why, one step back16 const {stdout} = await m('noop', ['foo']);initSindre Sorhusbefore adoptionbc16d6b
lines 17–2017 t.is(stdout, 'foo');18});1920test('buffer', async t => {fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
line 21why, one step back21 const {stdout} = await m('noop', ['foo'], {encoding: null});initSindre Sorhusbefore adoptionbc16d6b
lines 22–2522 t.true(Buffer.isBuffer(stdout));23 t.is(stdout.toString(), 'foo');24});25add `execa.stdout()` shortcut (#14)Sindre Sorhusbefore adoption868f505
lines 26–35why, one step back26test('execa.stdout()', async t => {27 const stdout = await m.stdout('noop', ['foo']);28 t.is(stdout, 'foo');29});3031test('execa.stderr()', async t => {32 const stderr = await m.stderr('noop-err', ['foo']);33 t.is(stderr, 'foo');34});35add `stdout`/`stderr` to errorsSindre Sorhusbefore adoption0ea8aaf
line 36why, one step back36test('stdout/stderr available on errors', async t => {meta tweaksSindre Sorhusbefore adoption858af26
lines 37–39why, one step back37 const err = await t.throws(m('exit', ['2']));38 t.is(typeof err.stdout, 'string');39 t.is(typeof err.stderr, 'string');add `stdout`/`stderr` to errorsSindre Sorhusbefore adoption0ea8aaf
lines 40–41why, one step back40});41add tests (#48)James Talmagebefore adoptionb15483a
line 42why, one step back42test('include stdout and stderr in errors for improved debugging', async t => {Use spawn instead of execFile (#27)James Talmagebefore adoption31a8d87
lines 43–44why, one step back43 const err = await t.throws(m('fixtures/error-message.js'));44 t.regex(err.message, /stdout/);add tests (#48)James Talmagebefore adoptionb15483a
line 45why, one step back45 t.regex(err.message, /stderr/);Fix test for exit code 1 on windows (#78)Sam Verschuerenbefore adoption4231a10
line 46why, one step back46 t.is(err.code, 1);include stdout in errors for improved debuggingSindre Sorhusbefore adoptionaea8c9a
lines 47–48why, one step back47});48Do not output stderr and stdout on stdio inherit - fixes #70 (#79)Sam Verschuerenbefore adoption2a12986
lines 49–50why, one step back49test('do not include in errors when `stdio` is set to `inherit`', async t => {50 const err = await t.throws(m('fixtures/error-message.js', {stdio: 'inherit'}));Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 51–85why, one step back51 t.notRegex(err.message, /\n/);52});5354test('do not include `stderr` and `stdout` in errors when set to `inherit`', async t => {55 const err = await t.throws(m('fixtures/error-message.js', {stdout: 'inherit', stderr: 'inherit'}));56 t.notRegex(err.message, /\n/);57});5859test('do not include `stderr` and `stdout` in errors when `stdio` is set to `inherit`', async t => {60 const err = await t.throws(m('fixtures/error-message.js', {stdio: [null, 'inherit', 'inherit']}));61 t.notRegex(err.message, /\n/);62});6364test('do not include `stdout` in errors when set to `inherit`', async t => {65 const err = await t.throws(m('fixtures/error-message.js', {stdout: 'inherit'}));66 t.notRegex(err.message, /stdout/);67 t.regex(err.message, /stderr/);68});6970test('do not include `stderr` in errors when set to `inherit`', async t => {71 const err = await t.throws(m('fixtures/error-message.js', {stderr: 'inherit'}));72 t.regex(err.message, /stdout/);73 t.notRegex(err.message, /stderr/);74});7576test('pass `stdout` to a file descriptor', async t => {77 const file = tempfile('.txt');78 await m('fixtures/noop', ['foo bar'], {stdout: fs.openSync(file, 'w')});79 t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');80});8182test('pass `stderr` to a file descriptor', async t => {83 const file = tempfile('.txt');84 await m('fixtures/noop-err', ['foo bar'], {stderr: fs.openSync(file, 'w')});85 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 86–87why, one step back86});87Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
line 88why, one step back88test('execa.shell()', async t => {fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
line 89why, one step back89 const {stdout} = await m.shell('node fixtures/noop foo');Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
lines 90–92why, one step back90 t.is(stdout, 'foo');91});92make `execa.spawn()` use the same argument normalization as `execa()`Sindre Sorhusbefore adoptiond6e3220
line 93why, one step back93test('execa.spawn()', async t => {fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
lines 94–95why, one step back94 t.is(typeof m.spawn('noop').pid, 'number');95 t.is((await getStream(m.spawn('noop', ['foo']).stdout)).trim(), 'foo');expose `.spawn`Sindre Sorhusbefore adoptionb65479c
lines 96–97why, one step back96});97add `execa.sync()` (#7)Sindre Sorhusbefore adoption9345d2c
line 98why, one step back98test('execa.sync()', t => {[BREAKING] for consistency return a result object from `execa.sync()` instead of string (#22)James Talmagebefore adoptiona8f2100
line 99why, one step back99 const {stdout} = m.sync('noop', ['foo']);add `execa.sync()` (#7)Sindre Sorhusbefore adoption9345d2c
lines 100–102why, one step back100 t.is(stdout, 'foo');101});102Throw error in sync method - fixes #66 (#67)Sam Verschuerenbefore adoptionc8c9c7b
lines 103–106why, one step back103test('execa.sync() throws error if written to stderr', t => {104 t.throws(() => m.sync('foo'), process.platform === 'win32' ? /'foo' is not recognized as an internal or external command/ : 'spawnSync foo ENOENT');105});106add `execa.shellSync()`Sindre Sorhusbefore adoption71a58ee
line 107why, one step back107test('execa.shellSync()', t => {[BREAKING] for consistency return a result object from `execa.sync()` instead of string (#22)James Talmagebefore adoptiona8f2100
line 108why, one step back108 const {stdout} = m.shellSync('node fixtures/noop foo');add `execa.shellSync()`Sindre Sorhusbefore adoption71a58ee
lines 109–111why, one step back109 t.is(stdout, 'foo');110});111112test('stripEof option', async t => {fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
line 113why, one step back113 const {stdout} = await m('noop', ['foo'], {stripEof: false});initSindre Sorhusbefore adoptionbc16d6b
lines 114–116114 t.is(stdout, 'foo\n');115});116Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
line 117why, one step back117test.serial('preferLocal option', async t => {tweaksSindre Sorhusbefore adoptione3505a8
line 118why, one step back118 t.true((await m('cat-names')).stdout.length > 2);Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
line 119why, one step back119fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
lines 120–124why, one step back120 if (process.platform === 'win32') {121 // TODO: figure out how to make the below not hang on Windows122 return;123 }124Fix linting (#77)Sam Verschuerenbefore adoption80a059d
line 125why, one step back125 // Account for npm adding local binaries to the PATHMerge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
lines 126–127why, one step back126 const _path = process.env.PATH;127 process.env.PATH = '';fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
line 128why, one step back128 await t.throws(m('cat-names', {preferLocal: false}), /spawn .* ENOENT/);Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c
line 129why, one step back129 process.env.PATH = _path;add `input` optionJames Talmagebefore adoption605a674
lines 130–131why, one step back130});131Add test for #73Sindre Sorhusbefore adoptionc7481f4
lines 132–139why, one step back132test('localDir option', async t => {133 const cwd = 'fixtures/local-dir';134 const bin = path.resolve(cwd, 'node_modules/.bin/self-path');135136 await m('npm', ['install', '--no-package-lock'], {cwd});137138 const {stdout} = await m(bin, {localDir: cwd});139Meta tweaksSindre Sorhusbefore adoptionc0fc20c
line 140why, one step back140 t.is(path.relative(cwd, stdout), path.normalize('node_modules/self-path'));Add test for #73Sindre Sorhusbefore adoptionc7481f4
lines 141–142why, one step back141});142add `input` optionJames Talmagebefore adoption605a674
line 143why, one step back143test('input option can be a String', async t => {fix option handling in #15Sindre Sorhusbefore adoption3d31e8d
line 144why, one step back144 const {stdout} = await m('stdin', {input: 'foobar'});add `input` optionJames Talmagebefore adoption605a674
lines 145–148why, one step back145 t.is(stdout, 'foobar');146});147148test('input option can be a Buffer', async t => {fix option handling in #15Sindre Sorhusbefore adoption3d31e8d
line 149why, one step back149 const {stdout} = await m('stdin', {input: 'testing12'});add `input` optionJames Talmagebefore adoption605a674
lines 150–153why, one step back150 t.is(stdout, 'testing12');151});152153test('input can be a Stream', async t => {[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 154why, one step back154 const s = new stream.PassThrough();add `input` optionJames Talmagebefore adoption605a674
lines 155–156why, one step back155 s.write('howdy');156 s.end();fix option handling in #15Sindre Sorhusbefore adoption3d31e8d
line 157why, one step back157 const {stdout} = await m('stdin', {input: s});add `input` optionJames Talmagebefore adoption605a674
lines 158–160why, one step back158 t.is(stdout, 'howdy');159});160return the child process instead of a promise. (#18)James Talmagebefore adoption99f10ba
lines 161–166why, one step back161test('you can write to child.stdin', async t => {162 const child = m('stdin');163 child.stdin.end('unicorns');164 t.is((await child).stdout, 'unicorns');165});166Fix linting (#77)Sam Verschuerenbefore adoption80a059d
line 167why, one step back167test('input option can be a String - sync', t => {[BREAKING] for consistency return a result object from `execa.sync()` instead of string (#22)James Talmagebefore adoptiona8f2100
line 168why, one step back168 const {stdout} = m.sync('stdin', {input: 'foobar'});add `input` optionJames Talmagebefore adoption605a674
lines 169–171why, one step back169 t.is(stdout, 'foobar');170});171Fix linting (#77)Sam Verschuerenbefore adoption80a059d
lines 172–173why, one step back172test('input option can be a Buffer - sync', t => {173 const {stdout} = m.sync('stdin', {input: Buffer.from('testing12', 'utf8')});add `input` optionJames Talmagebefore adoption605a674
line 174why, one step back174 t.is(stdout, 'testing12');Use spawn instead of execFile (#27)James Talmagebefore adoption31a8d87
lines 175–177why, one step back175});176177test('opts.stdout:ignore - stdout will not collect data', async t => {fix XO lint issuesSindre Sorhusbefore adoption342096c
lines 178–181why, one step back178 const {stdout} = await m('stdin', {179 input: 'hello',180 stdio: [null, 'ignore', null]181 });Use spawn instead of execFile (#27)James Talmagebefore adoption31a8d87
line 182why, one step back182 t.is(stdout, null);add `input` optionJames Talmagebefore adoption605a674
lines 183–186why, one step back183});184185test('helpful error trying to provide an input stream in sync mode', t => {186 t.throws(fix option handling in #15Sindre Sorhusbefore adoption3d31e8d
line 187why, one step back187 () => m.sync('stdin', {input: new stream.PassThrough()}),add `input` optionJames Talmagebefore adoption605a674
lines 188–189why, one step back188 /The `input` option cannot be a stream in sync mode/189 );Attach pid and kill() to returned promise (#11)Luke Horvatbefore adoption9da5484
lines 190–192why, one step back190});191192test('execa() returns a promise with kill() and pid', t => {fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df
line 193why, one step back193 const promise = m('noop', ['foo']);Attach pid and kill() to returned promise (#11)Luke Horvatbefore adoption9da5484
lines 194–195why, one step back194 t.is(typeof promise.kill, 'function');195 t.is(typeof promise.pid, 'number');196});add max-buffer support (#37)James Talmagebefore adoption6288806
line 197why, one step back197Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
lines 198–200why, one step back198test('maxBuffer affects stdout', async t => {199 await t.throws(m('max-buffer', ['stdout', '11'], {maxBuffer: 10}), /stdout maxBuffer exceeded/);200 await t.notThrows(m('max-buffer', ['stdout', '10'], {maxBuffer: 10}));add max-buffer support (#37)James Talmagebefore adoption6288806
lines 201–202why, one step back201});202Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
lines 203–205why, one step back203test('maxBuffer affects stderr', async t => {204 await t.throws(m('max-buffer', ['stderr', '13'], {maxBuffer: 12}), /stderr maxBuffer exceeded/);205 await t.notThrows(m('max-buffer', ['stderr', '12'], {maxBuffer: 12}));add max-buffer support (#37)James Talmagebefore adoption6288806
line 206why, one step back206});Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
lines 207–208why, one step back207208test('skip throwing when using reject option', async t => {Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 209why, one step back209 const err = await m('exit', ['2'], {reject: false});Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76
lines 210–221why, one step back210 t.is(typeof err.stdout, 'string');211 t.is(typeof err.stderr, 'string');212});213214test('execa() returns code and failed properties', async t => {215 const {code, failed} = await m('noop', ['foo']);216 const err = await t.throws(m('exit', ['2']));217 t.is(code, 0);218 t.false(failed);219 t.is(err.code, 2);220 t.true(err.failed);221});Add test for `../` paths (#43)James Talmagebefore adoption56a20b1
lines 222–227why, one step back222223test(`use relative path with '..' chars`, async t => {224 const pathViaParentDir = path.join('..', path.basename(__dirname), 'fixtures', 'noop');225 const {stdout} = await m(pathViaParentDir, ['foo']);226 t.is(stdout, 'foo');227});add tests (#48)James Talmagebefore adoptionb15483a
line 228why, one step back228add test case for throwing on non-executables (#49)Markus Wolfbefore adoptione10d263
line 229why, one step back229if (process.platform !== 'win32') {Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 230why, one step back230 test('execa() rejects if running non-executable', async t => {ensure `execa` rejects and not throws when the core spawn throws and errorSindre Sorhusbefore adoption03964c1
line 231why, one step back231 const cp = m('non-executable');Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 232why, one step back232 await t.throws(cp);add test case for throwing on non-executables (#49)Markus Wolfbefore adoptione10d263
lines 233–235why, one step back233 });234}235add tests (#48)James Talmagebefore adoptionb15483a
lines 236–238why, one step back236test('err.killed is true if process was killed directly', async t => {237 const cp = m('forever');238[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 239why, one step back239 setTimeout(() => {add tests (#48)James Talmagebefore adoptionb15483a
lines 240–251why, one step back240 cp.kill();241 }, 100);242243 const err = await t.throws(cp);244245 t.true(err.killed);246});247248// TODO: Should this really be the case, or should we improve on child_process?249test('err.killed is false if process was killed indirectly', async t => {250 const cp = m('forever');251[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 252why, one step back252 setTimeout(() => {add tests (#48)James Talmagebefore adoptionb15483a
lines 253–268why, one step back253 process.kill(cp.pid, 'SIGINT');254 }, 100);255256 const err = await t.throws(cp);257258 t.false(err.killed);259});260261if (process.platform === 'darwin') {262 test.cb('sanity check: child_process.exec also has killed.false if killed indirectly', t => {263 const cp = childProcess.exec('forever', err => {264 t.truthy(err);265 t.false(err.killed);266 t.end();267 });268[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 269why, one step back269 setTimeout(() => {add tests (#48)James Talmagebefore adoptionb15483a
lines 270–278why, one step back270 process.kill(cp.pid, 'SIGINT');271 }, 100);272 });273}274275if (process.platform !== 'win32') {276 test('err.signal is SIGINT', async t => {277 const cp = m('forever');278[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 279why, one step back279 setTimeout(() => {add tests (#48)James Talmagebefore adoptionb15483a
lines 280–290why, one step back280 process.kill(cp.pid, 'SIGINT');281 }, 100);282283 const err = await t.throws(cp);284285 t.is(err.signal, 'SIGINT');286 });287288 test('err.signal is SIGTERM', async t => {289 const cp = m('forever');290[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c
line 291why, one step back291 setTimeout(() => {add tests (#48)James Talmagebefore adoptionb15483a
lines 292–298why, one step back292 process.kill(cp.pid, 'SIGTERM');293 }, 100);294295 const err = await t.throws(cp);296297 t.is(err.signal, 'SIGTERM');298 });Fix `killSignal` option (#93)Kevin Mårtenssonbefore adoption2cbcc5c
lines 299–304why, one step back299300 test('custom err.signal', async t => {301 const err = await t.throws(m('delay', ['3000', '0'], {killSignal: 'SIGHUP', timeout: 1500}));302303 t.is(err.signal, 'SIGHUP');304 });add tests (#48)James Talmagebefore adoptionb15483a
lines 305–325why, one step back305}306307test('result.signal is null for successful execution', async t => {308 t.is((await m('noop')).signal, null);309});310311test('result.signal is null if process failed, but was not killed', async t => {312 const err = await t.throws(m('exit', [2]));313 t.is(err.signal, null);314});315316async function code(t, num) {317 const err = await t.throws(m('exit', [`${num}`]));318319 t.is(err.code, num);320}321322test('err.code is 2', code, 2);323test('err.code is 3', code, 3);324test('err.code is 4', code, 4);325Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d
lines 326–351why, one step back326test('timeout will kill the process early', async t => {327 const err = await t.throws(m('delay', ['3000', '0'], {timeout: 1500}));328329 t.true(err.timedOut);330 t.not(err.code, 22);331});332333test('timeout will not kill the process early', async t => {334 const err = await t.throws(m('delay', ['3000', '22'], {timeout: 9000}));335336 t.false(err.timedOut);337 t.is(err.code, 22);338});339340test('timedOut will be false if no timeout was set and zero exit code', async t => {341 const result = await m('delay', ['1000', '0']);342343 t.false(result.timedOut);344});345346test('timedOut will be false if no timeout was set and non-zero exit code', async t => {347 const err = await t.throws(m('delay', ['1000', '3']));348349 t.false(err.timedOut);350});351add tests (#48)James Talmagebefore adoptionb15483a
lines 352–377why, one step back352async function errorMessage(t, expected, ...args) {353 const err = await t.throws(m('exit', args));354355 t.regex(err.message, expected);356}357358errorMessage.title = (message, expected) => `err.message matches: ${expected}`;359360test(errorMessage, /Command failed: exit 2 foo bar/, 2, 'foo', 'bar');361test(errorMessage, /Command failed: exit 3 baz quz/, 3, 'baz', 'quz');362363async function cmd(t, expected, ...args) {364 const err = await t.throws(m('fail', args));365366 t.is(err.cmd, `fail${expected}`);367368 const result = await m('noop', args);369370 t.is(result.cmd, `noop${expected}`);371}372373cmd.title = (message, expected) => `cmd is: ${JSON.stringify(expected)}`;374375test(cmd, ' foo bar', 'foo', 'bar');376test(cmd, ' baz quz', 'baz', 'quz');377test(cmd, '');Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd
lines 378–410why, one step back378379async function spawnAndKill(t, signal, cleanup) {380 const name = cleanup ? 'sub-process' : 'sub-process-false';381 const cp = m(name);382 let pid;383384 cp.stdout.setEncoding('utf8');385 cp.stdout.on('data', chunk => {386 pid = parseInt(chunk, 10);387 t.is(typeof pid, 'number');388389 setTimeout(() => {390 process.kill(cp.pid, signal);391 }, 100);392 });393394 await t.throws(cp);395396 // Give everybody some time to breath and kill things397 await delay(200);398399 t.false(isRunning(cp.pid));400 t.is(isRunning(pid), !cleanup);401}402403test('cleanup - SIGINT', spawnAndKill, 'SIGINT', true);404test('cleanup - SIGKILL', spawnAndKill, 'SIGTERM', true);405406if (process.platform !== 'win32') {407 // On Windows the subprocesses are actually always killed408 test('cleanup false - SIGINT', spawnAndKill, 'SIGTERM', false);409 test('cleanup false - SIGKILL', spawnAndKill, 'SIGKILL', false);410}fix support for the `shell` option in `execa.shell()`Sindre Sorhusbefore adoptiona80487b
line 411why, one step back411Fix linting (#77)Sam Verschuerenbefore adoption80a059d
line 412why, one step back412// See: https://github.com/sindresorhus/execa/issues/56only set to failing test on WindowsSindre Sorhusbefore adoption7d88adc
lines 413–414why, one step back413const onlyWinFailing = test[process.platform === 'win32' ? 'failing' : 'serial'];414onlyWinFailing('execa.shell() supports the `shell` option', async t => {fix support for the `shell` option in `execa.shell()`Sindre Sorhusbefore adoptiona80487b
lines 415–419why, one step back415 const {stdout} = await m.shell('noop foo', {416 shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash'417 });418 t.is(stdout, 'foo');419});Attach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2
lines 420–422why, one step back420421if (process.platform !== 'win32') {422 test('write to fast-exit process', async t => {Fix linting (#77)Sam Verschuerenbefore adoption80a059d
lines 423–424why, one step back423 // Try-catch here is necessary, because this test is not 100% accurate424 // Sometimes process can manage to accept input before exitingAttach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2
lines 425–426why, one step back425 try {426 await m(`fast-exit-${process.platform}`, [], {input: 'data'});Fix tests (#89)Sam Verschuerenbefore adoption1861b5e
line 427why, one step back427 t.pass();Attach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2
lines 428–432why, one step back428 } catch (err) {429 t.is(err.code, 'EPIPE');430 }431 });432}Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117
lines 433–450why, one step back433434test('extend environment variables by default', async t => {435 const result = await m.stdout('environment', [], {env: {BAR: 'bar'}});436437 t.deepEqual(result.split('\n'), [438 'foo',439 'bar'440 ]);441});442443test('do not extend environment with `envExtend` option', async t => {444 const result = await m.stdout('environment', [], {env: {BAR: 'bar', PATH: process.env.PATH}, extendEnv: false});445446 t.deepEqual(result.split('\n'), [447 'undefined',448 'bar'449 ]);450});