Skip to content
Myr

Rename internal variables (#379)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by Sindre Sorhus · parent cf32d16 · Browse files · 4 files+61 added−61 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+61 added−61 removed

  • tests:+61 added−61 removed

4 files+61 added−61 removed

modified:test/error.js+15 added-15 removed
modified:test/kill.js+6 added-6 removed
174 unmodified lines
175176// See #128177test('removes exit handler on exit', async t => {178 // FIXME: This relies on `signal-exit` internals179 const ee = process.__signal_exit_emitter__;179 const emitter = process.__signal_exit_emitter__;180181 const child = execa('noop');182 const listener = ee.listeners('exit').pop();181 const subprocess = execa('noop');182 const listener = emitter.listeners('exit').pop();183184 await new Promise((resolve, reject) => {185 child.on('error', reject);186 child.on('exit', resolve);185 subprocess.on('error', reject);186 subprocess.on('exit', resolve);187 });188189 const included = ee.listeners('exit').includes(listener);189 const included = emitter.listeners('exit').includes(listener);190 t.false(included);191});192193test('cancel method kills the subprocess', t => {
69 unmodified lines
modified:test/stream.js+22 added-22 removed
1import path from 'path';2import fs from 'fs';3import stream from 'stream';3import Stream from 'stream';4import test from 'ava';5import getStream from 'get-stream';6import tempfile from 'tempfile';7import execa from '..';
52 unmodified lines
60 t.is(stdout, 'testing12');61});6263test('input can be a Stream', async t => {64 const s = new stream.PassThrough();65 s.write('howdy');66 s.end();67 const {stdout} = await execa('stdin', {input: s});64 const stream = new Stream.PassThrough();65 stream.write('howdy');66 stream.end();67 const {stdout} = await execa('stdin', {input: stream});68 t.is(stdout, 'howdy');69});7071test('you can write to child.stdin', async t => {72 const child = execa('stdin');73 child.stdin.end('unicorns');74 t.is((await child).stdout, 'unicorns');72 const subprocess = execa('stdin');73 subprocess.stdin.end('unicorns');74 t.is((await subprocess).stdout, 'unicorns');75});7677test('input option can be a String - sync', t => {78 const {stdout} = execa.sync('stdin', {input: 'foobar'});
15 unmodified lines
9495test('helpful error trying to provide an input stream in sync mode', t => {96 t.throws(97 () => {98 execa.sync('stdin', {input: new stream.PassThrough()});98 execa.sync('stdin', {input: new Stream.PassThrough()});99 },100 /The `input` option cannot be a stream in sync mode/101 );102});
48 unmodified lines
151 await t.notThrowsAsync(execa('max-buffer', {buffer: false, stdout: 'ignore'}));152});153154test('buffer: false > promise resolves when output is big and is read', async t => {155 const cp = execa('max-buffer', {buffer: false});156 cp.stdout.resume();157 cp.stderr.resume();158 await t.notThrowsAsync(cp);155 const subprocess = execa('max-buffer', {buffer: false});156 subprocess.stdout.resume();157 subprocess.stderr.resume();158 await t.notThrowsAsync(subprocess);159});160161test('buffer: false > promise resolves when output is big and "all" is used and is read', async t => {162 const cp = execa('max-buffer', {buffer: false, all: true});163 cp.all.resume();164 await t.notThrowsAsync(cp);162 const subprocess = execa('max-buffer', {buffer: false, all: true});163 subprocess.all.resume();164 await t.notThrowsAsync(subprocess);165});166167test('buffer: false > promise rejects when process returns non-zero', async t => {168 const cp = execa('fail', {buffer: false});169 const {exitCode} = await t.throwsAsync(cp);168 const subprocess = execa('fail', {buffer: false});169 const {exitCode} = await t.throwsAsync(subprocess);170 t.is(exitCode, 2);171});172173const BUFFER_TIMEOUT = 1e3;
5 unmodified lines
179 t.true(timedOut);180 });181182 test.serial('buffer: false > promise does not resolve when output is big and "all" is used but not read', async t => {183 const cp = execa('max-buffer', {buffer: false, all: true, timeout: BUFFER_TIMEOUT});184 cp.stdout.resume();185 cp.stderr.resume();186 const {timedOut} = await t.throwsAsync(cp);183 const subprocess = execa('max-buffer', {buffer: false, all: true, timeout: BUFFER_TIMEOUT});184 subprocess.stdout.resume();185 subprocess.stderr.resume();186 const {timedOut} = await t.throwsAsync(subprocess);187 t.true(timedOut);188 });189}
modified:test/test.js+18 added-18 removed
98 unmodified lines
99 t.true(stdout.includes('6.0.0'));100});101102test('stdin errors are handled', async t => {103 const child = execa('noop');104 child.stdin.emit('error', new Error('test'));105 await t.throwsAsync(child, /test/);103 const subprocess = execa('noop');104 subprocess.stdin.emit('error', new Error('test'));105 await t.throwsAsync(subprocess, /test/);106});107108test('child process errors are handled', async t => {109 const child = execa('noop');110 child.emit('error', new Error('test'));111 await t.throwsAsync(child, /test/);109 const subprocess = execa('noop');110 subprocess.emit('error', new Error('test'));111 await t.throwsAsync(subprocess, /test/);112});113114test('child process errors rejects promise right away', async t => {115 const child = execa('noop');116 child.emit('error', new Error('test'));117 await t.throwsAsync(child, /test/);115 const subprocess = execa('noop');116 subprocess.emit('error', new Error('test'));117 await t.throwsAsync(subprocess, /test/);118});119120test('execa() returns a promise with pid', t => {121 const {pid} = execa('noop', ['foo']);122 t.is(typeof pid, 'number');123});124125test('child_process.spawn() propagated errors have correct shape', t => {126 const cp = execa('noop', {uid: -1});126 const subprocess = execa('noop', {uid: -1});127 t.notThrows(() => {128 cp.catch(() => {});129 cp.unref();130 cp.on('error', () => {});128 subprocess.catch(() => {});129 subprocess.unref();130 subprocess.on('error', () => {});131 });132});133134test('child_process.spawn() errors are propagated', async t => {
8 unmodified lines
143 t.true(failed);144});145146test('do not try to consume streams twice', async t => {147 const cp = execa('noop', ['foo']);148 t.is((await cp).stdout, 'foo');149 t.is((await cp).stdout, 'foo');147 const subprocess = execa('noop', ['foo']);148 t.is((await subprocess).stdout, 'foo');149 t.is((await subprocess).stdout, 'foo');150});151152test('use relative path with \'..\' chars', async t => {153 const pathViaParentDir = path.join('..', path.basename(path.dirname(__dirname)), 'test', 'fixtures', 'noop');
2 unmodified lines
156});157158if (process.platform !== 'win32') {159 test('execa() rejects if running non-executable', async t => {160 const cp = execa('non-executable');161 await t.throwsAsync(cp);160 const subprocess = execa('non-executable');161 await t.throwsAsync(subprocess);162 });163164 test('execa() rejects with correct error and doesn\'t throw if running non-executable with input', async t => {165 // On Node <12.6.0, `EACCESS` is emitted on `childProcess`.
60 unmodified lines