Simplify tests (#552)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 950d1e6 · Browse files · 6 files·+48 added−48 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+48 added−48 removed
- tests:+48 added−48 removed
Provenance
- Commit
5fa61d8- Tree
3af10d3- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
950d1e6
6 files changed+48 added−48 removed
modified:test/fixtures/detach.js+1 added-1 removed
12345567#!/usr/bin/env nodeimport process from 'node:process';import {execa} from '../../index.js';
const subprocess = execa('node', ['./test/fixtures/forever.js'], {detached: true});const subprocess = execa('forever.js', {detached: true});console.log(subprocess.pid);process.exit(0);modified:test/fixtures/sub-process-exit.js+1 added-1 removed
4 unmodified lines567899101112134 unmodified linesconst cleanup = process.argv[2] === 'true';const detached = process.argv[3] === 'true';
try { await execa('node', ['./test/fixtures/noop.js'], {cleanup, detached}); await execa('noop.js', {cleanup, detached});} catch (error) { console.error(error); process.exit(1);}modified:test/fixtures/sub-process.js+1 added-1 removed
2 unmodified lines34567782 unmodified linesimport {execa} from '../../index.js';
const cleanup = process.argv[2] === 'true';const detached = process.argv[3] === 'true';const subprocess = execa('node', ['./test/fixtures/forever.js'], {cleanup, detached});const subprocess = execa('forever.js', {cleanup, detached});process.send(subprocess.pid);modified:test/command.js+38 added-38 removed
51 unmodified lines52 t.is(stdout, 'foo\nbar');53 });54 55 test('execaCommand()', async t => {56- const {stdout} = await execaCommand('node test/fixtures/echo.js foo bar');56+ const {stdout} = await execaCommand('echo.js foo bar');57 t.is(stdout, 'foo\nbar');58 });59 60 test('execaCommand() ignores consecutive spaces', async t => {61- const {stdout} = await execaCommand('node test/fixtures/echo.js foo bar');61+ const {stdout} = await execaCommand('echo.js foo bar');62 t.is(stdout, 'foo\nbar');63 });64 65 test('execaCommand() allows escaping spaces in commands', async t => {1 unmodified line67 t.is(stdout, 'foo\nbar');68 });69 70 test('execaCommand() allows escaping spaces in arguments', async t => {71- const {stdout} = await execaCommand('node test/fixtures/echo.js foo\\ bar');71+ const {stdout} = await execaCommand('echo.js foo\\ bar');72 t.is(stdout, 'foo bar');73 });74 75 test('execaCommand() escapes other whitespaces', async t => {76- const {stdout} = await execaCommand('node test/fixtures/echo.js foo\tbar');76+ const {stdout} = await execaCommand('echo.js foo\tbar');77 t.is(stdout, 'foo\tbar');78 });79 80 test('execaCommand() trims', async t => {81- const {stdout} = await execaCommand(' node test/fixtures/echo.js foo bar ');81+ const {stdout} = await execaCommand(' echo.js foo bar ');82 t.is(stdout, 'foo\nbar');83 });84 85 test('execaCommandSync()', t => {86- const {stdout} = execaCommandSync('node test/fixtures/echo.js foo bar');86+ const {stdout} = execaCommandSync('echo.js foo bar');87 t.is(stdout, 'foo\nbar');88 });89 90 test('$', async t => {91- const {stdout} = await $`node test/fixtures/echo.js foo bar`;91+ const {stdout} = await $`echo.js foo bar`;92 t.is(stdout, 'foo\nbar');93 });94 95 test('$ accepts options', async t => {1 unmodified line97 t.is(stdout, 'foo');98 });99 100 test('$ allows string interpolation', async t => {101- const {stdout} = await $`node test/fixtures/echo.js foo ${'bar'}`;101+ const {stdout} = await $`echo.js foo ${'bar'}`;102 t.is(stdout, 'foo\nbar');103 });104 105 test('$ allows number interpolation', async t => {106- const {stdout} = await $`node test/fixtures/echo.js 1 ${2}`;106+ const {stdout} = await $`echo.js 1 ${2}`;107 t.is(stdout, '1\n2');108 });109 110 test('$ allows array interpolation', async t => {111- const {stdout} = await $`node test/fixtures/echo.js ${['foo', 'bar']}`;111+ const {stdout} = await $`echo.js ${['foo', 'bar']}`;112 t.is(stdout, 'foo\nbar');113 });114 115 test('$ allows execa return value interpolation', async t => {116- const foo = await $`node test/fixtures/echo.js foo`;117- const {stdout} = await $`node test/fixtures/echo.js ${foo} bar`;116+ const foo = await $`echo.js foo`;117+ const {stdout} = await $`echo.js ${foo} bar`;118 t.is(stdout, 'foo\nbar');119 });120 121 test('$ allows execa return value array interpolation', async t => {122- const foo = await $`node test/fixtures/echo.js foo`;123- const {stdout} = await $`node test/fixtures/echo.js ${[foo, 'bar']}`;122+ const foo = await $`echo.js foo`;123+ const {stdout} = await $`echo.js ${[foo, 'bar']}`;124 t.is(stdout, 'foo\nbar');125 });126 127 test('$ allows execa return value buffer interpolation', async t => {128- const foo = await $({encoding: null})`node test/fixtures/echo.js foo`;129- const {stdout} = await $`node test/fixtures/echo.js ${foo} bar`;128+ const foo = await $({encoding: null})`echo.js foo`;129+ const {stdout} = await $`echo.js ${foo} bar`;130 t.is(stdout, 'foo\nbar');131 });132 133 test('$ allows execa return value buffer array interpolation', async t => {134- const foo = await $({encoding: null})`node test/fixtures/echo.js foo`;135- const {stdout} = await $`node test/fixtures/echo.js ${[foo, 'bar']}`;134+ const foo = await $({encoding: null})`echo.js foo`;135+ const {stdout} = await $`echo.js ${[foo, 'bar']}`;136 t.is(stdout, 'foo\nbar');137 });138 139 test('$ ignores consecutive spaces', async t => {140- const {stdout} = await $`node test/fixtures/echo.js foo bar`;140+ const {stdout} = await $`echo.js foo bar`;141 t.is(stdout, 'foo\nbar');142 });143 144 test('$ allows escaping spaces with interpolation', async t => {145- const {stdout} = await $`node test/fixtures/echo.js ${'foo bar'}`;145+ const {stdout} = await $`echo.js ${'foo bar'}`;146 t.is(stdout, 'foo bar');147 });148 149 test('$ disallows escaping spaces with backslashes', async t => {150- const {stdout} = await $`node test/fixtures/echo.js foo\\ bar`;150+ const {stdout} = await $`echo.js foo\\ bar`;151 t.is(stdout, 'foo\\\nbar');152 });153 154 test('$ allows space escaped values in array interpolation', async t => {155- const {stdout} = await $`node test/fixtures/echo.js ${['foo', 'bar baz']}`;155+ const {stdout} = await $`echo.js ${['foo', 'bar baz']}`;156 t.is(stdout, 'foo\nbar baz');157 });158 159 test('$ passes newline escape sequence as one argument', async t => {160- const {stdout} = await $`node test/fixtures/echo.js \n`;160+ const {stdout} = await $`echo.js \n`;161 t.is(stdout, '\n');162 });163 164 test('$ passes newline escape sequence in interpolation as one argument', async t => {165- const {stdout} = await $`node test/fixtures/echo.js ${'\n'}`;165+ const {stdout} = await $`echo.js ${'\n'}`;166 t.is(stdout, '\n');167 });168 169 test('$ handles invalid escape sequence', async t => {170- const {stdout} = await $`node test/fixtures/echo.js \u`;170+ const {stdout} = await $`echo.js \u`;171 t.is(stdout, '\\u');172 });173 174 test('$ allows escaping spaces in commands with interpolation', async t => {1 unmodified line176 t.is(stdout, 'foo\nbar');177 });178 179 test('$ escapes other whitespaces', async t => {180- const {stdout} = await $`node test/fixtures/echo.js foo\tbar`;180+ const {stdout} = await $`echo.js foo\tbar`;181 t.is(stdout, 'foo\tbar');182 });183 184 test('$ trims', async t => {185- const {stdout} = await $` node test/fixtures/echo.js foo bar `;185+ const {stdout} = await $` echo.js foo bar `;186 t.is(stdout, 'foo\nbar');187 });188 189 test('$.sync', t => {190- const {stdout} = $.sync`node test/fixtures/echo.js foo bar`;190+ const {stdout} = $.sync`echo.js foo bar`;191 t.is(stdout, 'foo\nbar');192 });193 194 test('$.sync accepts options', t => {1 unmodified line196 t.is(stdout, 'foo');197 });198 199 test('$.sync allows execa return value interpolation', t => {200- const foo = $.sync`node test/fixtures/echo.js foo`;201- const {stdout} = $.sync`node test/fixtures/echo.js ${foo} bar`;200+ const foo = $.sync`echo.js foo`;201+ const {stdout} = $.sync`echo.js ${foo} bar`;202 t.is(stdout, 'foo\nbar');203 });204 205 test('$.sync allows execa return value array interpolation', t => {206- const foo = $.sync`node test/fixtures/echo.js foo`;207- const {stdout} = $.sync`node test/fixtures/echo.js ${[foo, 'bar']}`;206+ const foo = $.sync`echo.js foo`;207+ const {stdout} = $.sync`echo.js ${[foo, 'bar']}`;208 t.is(stdout, 'foo\nbar');209 });210 211 test('$.sync allows execa return value buffer interpolation', t => {212- const foo = $({encoding: null}).sync`node test/fixtures/echo.js foo`;213- const {stdout} = $.sync`node test/fixtures/echo.js ${foo} bar`;212+ const foo = $({encoding: null}).sync`echo.js foo`;213+ const {stdout} = $.sync`echo.js ${foo} bar`;214 t.is(stdout, 'foo\nbar');215 });216 217 test('$.sync allows execa return value buffer array interpolation', t => {218- const foo = $({encoding: null}).sync`node test/fixtures/echo.js foo`;219- const {stdout} = $.sync`node test/fixtures/echo.js ${[foo, 'bar']}`;218+ const foo = $({encoding: null}).sync`echo.js foo`;219+ const {stdout} = $.sync`echo.js ${[foo, 'bar']}`;220 t.is(stdout, 'foo\nbar');221 });222 223 const invalidExpression = test.macro({224 async exec(t, input, expected) {225 await t.throwsAsync(226- async () => $`node test/fixtures/echo.js ${input}`,226+ async () => $`echo.js ${input}`,227 {instanceOf: TypeError, message: expected},228 );229 230 t.throws(231- () => $.sync`node test/fixtures/echo.js ${input}`,231+ () => $.sync`echo.js ${input}`,232 {instanceOf: TypeError, message: expected},233 );234 },235 title(prettyInput, input, expected) {36 unmodified linesmodified:test/kill.js+5 added-5 removed
8 unmodified lines9 10 const TIMEOUT_REGEXP = /timed out after/;11 12 test('kill("SIGKILL") should terminate cleanly', async t => {13- const subprocess = execa('node', ['./test/fixtures/no-killable.js'], {stdio: ['ipc']});13+ const subprocess = execa('no-killable.js', {stdio: ['ipc']});14 await pEvent(subprocess, 'message');15 16 subprocess.kill('SIGKILL');17 4 unmodified lines22 // `SIGTERM` cannot be caught on Windows, and it always aborts the process (like `SIGKILL` on Unix).23 // Therefore, this feature and those tests do not make sense on Windows.24 if (process.platform !== 'win32') {25 test('`forceKillAfterTimeout: false` should not kill after a timeout', async t => {26- const subprocess = execa('node', ['./test/fixtures/no-killable.js'], {stdio: ['ipc']});26+ const subprocess = execa('no-killable.js', {stdio: ['ipc']});27 await pEvent(subprocess, 'message');28 29 subprocess.kill('SIGTERM', {forceKillAfterTimeout: false});30 1 unmodified line32 subprocess.kill('SIGKILL');33 });34 35 test('`forceKillAfterTimeout: number` should kill after a timeout', async t => {36- const subprocess = execa('node', ['./test/fixtures/no-killable.js'], {stdio: ['ipc']});36+ const subprocess = execa('no-killable.js', {stdio: ['ipc']});37 await pEvent(subprocess, 'message');38 39 subprocess.kill('SIGTERM', {forceKillAfterTimeout: 50});40 1 unmodified line42 t.is(signal, 'SIGKILL');43 });44 45 test('`forceKillAfterTimeout: true` should kill after a timeout', async t => {46- const subprocess = execa('node', ['./test/fixtures/no-killable.js'], {stdio: ['ipc']});46+ const subprocess = execa('no-killable.js', {stdio: ['ipc']});47 await pEvent(subprocess, 'message');48 49 subprocess.kill('SIGTERM', {forceKillAfterTimeout: true});50 1 unmodified line52 t.is(signal, 'SIGKILL');53 });54 55 test('kill() with no arguments should kill after a timeout', async t => {56- const subprocess = execa('node', ['./test/fixtures/no-killable.js'], {stdio: ['ipc']});56+ const subprocess = execa('no-killable.js', {stdio: ['ipc']});57 await pEvent(subprocess, 'message');58 59 subprocess.kill();60 250 unmodified linesmodified:test/stream.js+2 added-2 removed
17 unmodified lines18 });19 20 test('pass `stdout` to a file descriptor', async t => {21 const file = tempfile('.txt');22- await execa('test/fixtures/noop.js', ['foo bar'], {stdout: fs.openSync(file, 'w')});22+ await execa('noop.js', ['foo bar'], {stdout: fs.openSync(file, 'w')});23 t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');24 });25 26 test('pass `stderr` to a file descriptor', async t => {27 const file = tempfile('.txt');28- await execa('test/fixtures/noop-err.js', ['foo bar'], {stderr: fs.openSync(file, 'w')});28+ await execa('noop-err.js', ['foo bar'], {stderr: fs.openSync(file, 'w')});29 t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');30 });31 32 test.serial('result.all shows both `stdout` and `stderr` intermixed', async t => {200 unmodified lines