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
Provenance
- Commit
1ac56ea- Tree
cc9b3ae- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
cf32d16
4 files changed+61 added−61 removed
modified:test/error.js+15 added-15 removed
68 unmodified lines69707172737374757576777778798081828283848485868788888990919231 unmodified lines12412512612712812812913013013113213213313413513613713713813913914014114114214314414514614714814915015115115215315315415515515615715815919 unmodified lines68 unmodified lines t.true(failed);});
test('error.killed is true if process was killed directly', async t => { const cp = execa('noop'); const subprocess = execa('noop');
cp.kill(); subprocess.kill();
const {killed} = await t.throwsAsync(cp, {message: /was killed with SIGTERM/}); const {killed} = await t.throwsAsync(subprocess, {message: /was killed with SIGTERM/}); t.true(killed);});
test('error.killed is false if process was killed indirectly', async t => { const cp = execa('noop'); const subprocess = execa('noop');
process.kill(cp.pid, 'SIGINT'); process.kill(subprocess.pid, 'SIGINT');
// `process.kill()` is emulated by Node.js on Windows const message = process.platform === 'win32' ? /failed with exit code 1/ : /was killed with SIGINT/; const {killed} = await t.throwsAsync(cp, {message}); const {killed} = await t.throwsAsync(subprocess, {message}); t.false(killed);});
test('result.killed is false if not killed', async t => {31 unmodified lines}
if (process.platform !== 'win32') { test('error.signal is SIGINT', async t => { const cp = execa('noop'); const subprocess = execa('noop');
process.kill(cp.pid, 'SIGINT'); process.kill(subprocess.pid, 'SIGINT');
const {signal} = await t.throwsAsync(cp, {message: /was killed with SIGINT/}); const {signal} = await t.throwsAsync(subprocess, {message: /was killed with SIGINT/}); t.is(signal, 'SIGINT'); });
test('error.signal is SIGTERM', async t => { const cp = execa('noop'); const subprocess = execa('noop');
process.kill(cp.pid, 'SIGTERM'); process.kill(subprocess.pid, 'SIGTERM');
const {signal} = await t.throwsAsync(cp, {message: /was killed with SIGTERM/}); const {signal} = await t.throwsAsync(subprocess, {message: /was killed with SIGTERM/}); t.is(signal, 'SIGTERM'); });
test('custom error.signal', async t => { const {signal} = await t.throwsAsync(execa('noop', {killSignal: 'SIGHUP', timeout: 1, message: TIMEOUT_REGEXP})); t.is(signal, 'SIGHUP'); });
test('exitCode is undefined on signal termination', async t => { const cp = execa('noop'); const subprocess = execa('noop');
process.kill(cp.pid); process.kill(subprocess.pid);
const {exitCode} = await t.throwsAsync(cp); const {exitCode} = await t.throwsAsync(subprocess); t.is(exitCode, undefined); });}
19 unmodified linesmodified:test/kill.js+6 added-6 removed
174 unmodified lines175 176 // See #128177 test('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__;180 181- const child = execa('noop');182- const listener = ee.listeners('exit').pop();181+ const subprocess = execa('noop');182+ const listener = emitter.listeners('exit').pop();183 184 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 });188 189- const included = ee.listeners('exit').includes(listener);189+ const included = emitter.listeners('exit').includes(listener);190 t.false(included);191 });192 193 test('cancel method kills the subprocess', t => {69 unmodified linesmodified:test/stream.js+22 added-22 removed
1 import path from 'path';2 import fs from 'fs';3-import stream from 'stream';3+import Stream from 'stream';4 import test from 'ava';5 import getStream from 'get-stream';6 import tempfile from 'tempfile';7 import execa from '..';52 unmodified lines60 t.is(stdout, 'testing12');61 });62 63 test('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 });70 71 test('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 });76 77 test('input option can be a String - sync', t => {78 const {stdout} = execa.sync('stdin', {input: 'foobar'});15 unmodified lines94 95 test('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 lines151 await t.notThrowsAsync(execa('max-buffer', {buffer: false, stdout: 'ignore'}));152 });153 154 test('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 });160 161 test('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 });166 167 test('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 });172 173 const BUFFER_TIMEOUT = 1e3;5 unmodified lines179 t.true(timedOut);180 });181 182 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 lines99 t.true(stdout.includes('6.0.0'));100 });101 102 test('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 });107 108 test('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 });113 114 test('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 });119 120 test('execa() returns a promise with pid', t => {121 const {pid} = execa('noop', ['foo']);122 t.is(typeof pid, 'number');123 });124 125 test('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 });133 134 test('child_process.spawn() errors are propagated', async t => {8 unmodified lines143 t.true(failed);144 });145 146 test('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 });151 152 test('use relative path with \'..\' chars', async t => {153 const pathViaParentDir = path.join('..', path.basename(path.dirname(__dirname)), 'test', 'fixtures', 'noop');2 unmodified lines156 });157 158 if (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 });163 164 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