script.js
This file
Path
test/script.js
367 lines · 27.3 KiB · JavaScript
Last changed by
Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
History of this fileTake it
Split files (#791)ehmickybefore adoption932fb26
lines 1–7why, one step back1import test from 'ava';2import {isStream} from 'is-stream';3import {$} from '../index.js';4import {setFixtureDir} from './helpers/fixtures-dir.js';56setFixtureDir();7Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 8–13why, one step back8// Workaround since some text editors or IDEs do not allow inputting \r directly9const escapedCall = string => {10 const templates = [string];11 templates.raw = [string];12 return $(templates);13};Split files (#791)ehmickybefore adoption932fb26
line 14why, one step back14Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 15–16why, one step back15const testScriptStdout = async (t, getSubprocess, expectedStdout) => {16 const {stdout} = await getSubprocess();Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 17–18why, one step back17 t.is(stdout, expectedStdout);18};Split files (#791)ehmickybefore adoption932fb26
line 19why, one step back19Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 20–239why, one step back20test('$ executes command', testScriptStdout, () => $`echo.js foo bar`, 'foo\nbar');21test('$ accepts options', testScriptStdout, () => $({stripFinalNewline: true})`noop.js foo`, 'foo');22test('$ allows number interpolation', testScriptStdout, () => $`echo.js 1 ${2}`, '1\n2');23test('$ can concatenate multiple tokens', testScriptStdout, () => $`echo.js ${'foo'}bar${'foo'}`, 'foobarfoo');24test('$ can use newlines and tab indentations', testScriptStdout, () => $`echo.js foo25 bar`, 'foo\nbar');26test('$ can use newlines and space indentations', testScriptStdout, () => $`echo.js foo27 bar`, 'foo\nbar');28test('$ can use Windows newlines and tab indentations', testScriptStdout, () => escapedCall('echo.js foo\r\n\tbar'), 'foo\nbar');29test('$ can use Windows newlines and space indentations', testScriptStdout, () => escapedCall('echo.js foo\r\n bar'), 'foo\nbar');30test('$ does not ignore comments in expressions', testScriptStdout, () => $`echo.js foo31 ${/* This is a comment */''}32 bar33 ${/* This is another comment */''}34 baz35`, 'foo\n\nbar\n\nbaz');36test('$ allows escaping spaces with interpolation', testScriptStdout, () => $`echo.js ${'foo bar'}`, 'foo bar');37test('$ allows escaping spaces in commands with interpolation', testScriptStdout, () => $`${'command with space.js'} foo bar`, 'foo\nbar');38test('$ trims', testScriptStdout, () => $` echo.js foo bar `, 'foo\nbar');39test('$ allows array interpolation', testScriptStdout, () => $`echo.js ${['foo', 'bar']}`, 'foo\nbar');40test('$ allows empty array interpolation', testScriptStdout, () => $`echo.js foo ${[]} bar`, 'foo\nbar');41test('$ allows space escaped values in array interpolation', testScriptStdout, () => $`echo.js ${['foo', 'bar baz']}`, 'foo\nbar baz');42test('$ can concatenate at the end of tokens followed by an array', testScriptStdout, () => $`echo.js foo${['bar', 'foo']}`, 'foobar\nfoo');43test('$ can concatenate at the start of tokens followed by an array', testScriptStdout, () => $`echo.js ${['foo', 'bar']}foo`, 'foo\nbarfoo');44test('$ can concatenate at the start and end of tokens followed by an array', testScriptStdout, () => $`echo.js foo${['bar', 'foo']}bar`, 'foobar\nfoobar');45test('$ handles escaped newlines', testScriptStdout, () => $`echo.js a\46b`, 'ab');47test('$ handles backslashes at end of lines', testScriptStdout, () => $`echo.js a\\48 b`, 'a\\\nb');49test('$ handles double backslashes at end of lines', testScriptStdout, () => $`echo.js a\\\\50 b`, 'a\\\\\nb');51test('$ handles tokens - a', testScriptStdout, () => $`echo.js a`, 'a');52test('$ handles expressions - a', testScriptStdout, () => $`echo.js ${'a'}`, 'a');53test('$ handles tokens - abc', testScriptStdout, () => $`echo.js abc`, 'abc');54test('$ handles expressions - abc', testScriptStdout, () => $`echo.js ${'abc'}`, 'abc');55test('$ handles tokens - ""', testScriptStdout, () => $`echo.js`, '');56test('$ handles expressions - ""', testScriptStdout, () => $`echo.js a ${''} b`, 'a\n\nb');57test('$ splits tokens - ""', testScriptStdout, () => $`echo.js ab`, 'ab');58test('$ splits expressions - ""', testScriptStdout, () => $`echo.js ${'a'}${'b'}`, 'ab');59test('$ concatenates expressions - ""', testScriptStdout, () => $`echo.js a${'b'}c`, 'abc');60test('$ handles tokens - " "', testScriptStdout, () => $`echo.js `, '');61test('$ handles expressions - " "', testScriptStdout, () => $`echo.js ${' '}`, ' ');62test('$ splits tokens - " "', testScriptStdout, () => $`echo.js a b`, 'a\nb');63test('$ splits expressions - " "', testScriptStdout, () => $`echo.js ${'a'} ${'b'}`, 'a\nb');64test('$ concatenates tokens - " "', testScriptStdout, () => $`echo.js a `, 'a');65test('$ concatenates expressions - " "', testScriptStdout, () => $`echo.js ${'a'} `, 'a');66test('$ handles tokens - " " (2 spaces)', testScriptStdout, () => $`echo.js `, '');67test('$ handles expressions - " " (2 spaces)', testScriptStdout, () => $`echo.js ${' '}`, ' ');68test('$ splits tokens - " " (2 spaces)', testScriptStdout, () => $`echo.js a b`, 'a\nb');69test('$ splits expressions - " " (2 spaces)', testScriptStdout, () => $`echo.js ${'a'} ${'b'}`, 'a\nb');70test('$ concatenates tokens - " " (2 spaces)', testScriptStdout, () => $`echo.js a `, 'a');71test('$ concatenates expressions - " " (2 spaces)', testScriptStdout, () => $`echo.js ${'a'} `, 'a');72test('$ handles tokens - " " (3 spaces)', testScriptStdout, () => $`echo.js `, '');73test('$ handles expressions - " " (3 spaces)', testScriptStdout, () => $`echo.js ${' '}`, ' ');74test('$ splits tokens - " " (3 spaces)', testScriptStdout, () => $`echo.js a b`, 'a\nb');75test('$ splits expressions - " " (3 spaces)', testScriptStdout, () => $`echo.js ${'a'} ${'b'}`, 'a\nb');76test('$ concatenates tokens - " " (3 spaces)', testScriptStdout, () => $`echo.js a `, 'a');77test('$ concatenates expressions - " " (3 spaces)', testScriptStdout, () => $`echo.js ${'a'} `, 'a');78test('$ handles tokens - \\t (no escape)', testScriptStdout, () => $`echo.js `, '');79test('$ handles expressions - \\t (no escape)', testScriptStdout, () => $`echo.js ${' '}`, '\t');80test('$ splits tokens - \\t (no escape)', testScriptStdout, () => $`echo.js a b`, 'a\nb');81test('$ splits expressions - \\t (no escape)', testScriptStdout, () => $`echo.js ${'a'} ${'b'}`, 'a\nb');82test('$ concatenates tokens - \\t (no escape)', testScriptStdout, () => $`echo.js a b`, 'a\nb');83test('$ concatenates expressions - \\t (no escape)', testScriptStdout, () => $`echo.js ${'a'} b`, 'a\nb');84test('$ handles tokens - \\t (escape)', testScriptStdout, () => $`echo.js \t`, '\t');85test('$ handles expressions - \\t (escape)', testScriptStdout, () => $`echo.js ${'\t'}`, '\t');86test('$ splits tokens - \\t (escape)', testScriptStdout, () => $`echo.js a\tb`, 'a\tb');87test('$ splits expressions - \\t (escape)', testScriptStdout, () => $`echo.js ${'a'}\t${'b'}`, 'a\tb');88test('$ concatenates tokens - \\t (escape)', testScriptStdout, () => $`echo.js \ta\t b`, '\ta\t\nb');89test('$ concatenates expressions - \\t (escape)', testScriptStdout, () => $`echo.js \t${'a'}\t b`, '\ta\t\nb');90test('$ handles tokens - \\n (no escape)', testScriptStdout, () => $`echo.js91 `, '');92test('$ handles expressions - \\n (no escape)', testScriptStdout, () => $`echo.js ${`93`} `, '\n');94test('$ splits tokens - \\n (no escape)', testScriptStdout, () => $`echo.js a95 b`, 'a\nb');96test('$ splits expressions - \\n (no escape)', testScriptStdout, () => $`echo.js ${'a'}97 ${'b'}`, 'a\nb');98test('$ concatenates tokens - \\n (no escape)', testScriptStdout, () => $`echo.js99a100 b`, 'a\nb');101test('$ concatenates expressions - \\n (no escape)', testScriptStdout, () => $`echo.js102${'a'}103 b`, 'a\nb');104test('$ handles tokens - \\n (escape)', testScriptStdout, () => $`echo.js \n `, '\n');105test('$ handles expressions - \\n (escape)', testScriptStdout, () => $`echo.js ${'\n'} `, '\n');106test('$ splits tokens - \\n (escape)', testScriptStdout, () => $`echo.js a\n b`, 'a\n\nb');107test('$ splits expressions - \\n (escape)', testScriptStdout, () => $`echo.js ${'a'}\n ${'b'}`, 'a\n\nb');108test('$ concatenates tokens - \\n (escape)', testScriptStdout, () => $`echo.js \na\n b`, '\na\n\nb');109test('$ concatenates expressions - \\n (escape)', testScriptStdout, () => $`echo.js \n${'a'}\n b`, '\na\n\nb');110test('$ handles tokens - \\r (no escape)', testScriptStdout, () => escapedCall('echo.js \r '), '');111test('$ splits tokens - \\r (no escape)', testScriptStdout, () => escapedCall('echo.js a\rb'), 'a\nb');112test('$ splits expressions - \\r (no escape)', testScriptStdout, () => escapedCall(`echo.js ${'a'}\r${'b'}`), 'a\nb');113test('$ concatenates tokens - \\r (no escape)', testScriptStdout, () => escapedCall('echo.js \ra\r b'), 'a\nb');114test('$ concatenates expressions - \\r (no escape)', testScriptStdout, () => escapedCall(`echo.js \r${'a'}\r b`), 'a\nb');115test('$ splits tokens - \\r (escape)', testScriptStdout, () => $`echo.js a\r b`, 'a\r\nb');116test('$ splits expressions - \\r (escape)', testScriptStdout, () => $`echo.js ${'a'}\r ${'b'}`, 'a\r\nb');117test('$ concatenates tokens - \\r (escape)', testScriptStdout, () => $`echo.js \ra\r b`, '\ra\r\nb');118test('$ concatenates expressions - \\r (escape)', testScriptStdout, () => $`echo.js \r${'a'}\r b`, '\ra\r\nb');119test('$ handles tokens - \\r\\n (no escape)', testScriptStdout, () => escapedCall('echo.js \r\n '), '');120test('$ splits tokens - \\r\\n (no escape)', testScriptStdout, () => escapedCall('echo.js a\r\nb'), 'a\nb');121test('$ splits expressions - \\r\\n (no escape)', testScriptStdout, () => escapedCall(`echo.js ${'a'}\r\n${'b'}`), 'a\nb');122test('$ concatenates tokens - \\r\\n (no escape)', testScriptStdout, () => escapedCall('echo.js \r\na\r\n b'), 'a\nb');123test('$ concatenates expressions - \\r\\n (no escape)', testScriptStdout, () => escapedCall(`echo.js \r\n${'a'}\r\n b`), 'a\nb');124test('$ handles tokens - \\r\\n (escape)', testScriptStdout, () => $`echo.js \r\n `, '\r\n');125test('$ handles expressions - \\r\\n (escape)', testScriptStdout, () => $`echo.js ${'\r\n'} `, '\r\n');126test('$ splits tokens - \\r\\n (escape)', testScriptStdout, () => $`echo.js a\r\n b`, 'a\r\n\nb');127test('$ splits expressions - \\r\\n (escape)', testScriptStdout, () => $`echo.js ${'a'}\r\n ${'b'}`, 'a\r\n\nb');128test('$ concatenates tokens - \\r\\n (escape)', testScriptStdout, () => $`echo.js \r\na\r\n b`, '\r\na\r\n\nb');129test('$ concatenates expressions - \\r\\n (escape)', testScriptStdout, () => $`echo.js \r\n${'a'}\r\n b`, '\r\na\r\n\nb');130/* eslint-disable no-irregular-whitespace */131test('$ handles expressions - \\f (no escape)', testScriptStdout, () => $`echo.js ${''}`, '\f');132test('$ splits tokens - \\f (no escape)', testScriptStdout, () => $`echo.js ab`, 'a\fb');133test('$ splits expressions - \\f (no escape)', testScriptStdout, () => $`echo.js ${'a'}${'b'}`, 'a\fb');134test('$ concatenates tokens - \\f (no escape)', testScriptStdout, () => $`echo.js a b`, '\fa\f\nb');135test('$ concatenates expressions - \\f (no escape)', testScriptStdout, () => $`echo.js ${'a'} b`, '\fa\f\nb');136/* eslint-enable no-irregular-whitespace */137test('$ handles tokens - \\f (escape)', testScriptStdout, () => $`echo.js \f`, '\f');138test('$ handles expressions - \\f (escape)', testScriptStdout, () => $`echo.js ${'\f'}`, '\f');139test('$ splits tokens - \\f (escape)', testScriptStdout, () => $`echo.js a\fb`, 'a\fb');140test('$ splits expressions - \\f (escape)', testScriptStdout, () => $`echo.js ${'a'}\f${'b'}`, 'a\fb');141test('$ concatenates tokens - \\f (escape)', testScriptStdout, () => $`echo.js \fa\f b`, '\fa\f\nb');142test('$ concatenates expressions - \\f (escape)', testScriptStdout, () => $`echo.js \f${'a'}\f b`, '\fa\f\nb');143test('$ handles tokens - \\', testScriptStdout, () => $`echo.js \\`, '\\');144test('$ handles expressions - \\', testScriptStdout, () => $`echo.js ${'\\'}`, '\\');145test('$ splits tokens - \\', testScriptStdout, () => $`echo.js a\\b`, 'a\\b');146test('$ splits expressions - \\', testScriptStdout, () => $`echo.js ${'a'}\\${'b'}`, 'a\\b');147test('$ concatenates tokens - \\', testScriptStdout, () => $`echo.js \\a\\ b`, '\\a\\\nb');148test('$ concatenates expressions - \\', testScriptStdout, () => $`echo.js \\${'a'}\\ b`, '\\a\\\nb');149test('$ handles tokens - \\\\', testScriptStdout, () => $`echo.js \\\\`, '\\\\');150test('$ handles expressions - \\\\', testScriptStdout, () => $`echo.js ${'\\\\'}`, '\\\\');151test('$ splits tokens - \\\\', testScriptStdout, () => $`echo.js a\\\\b`, 'a\\\\b');152test('$ splits expressions - \\\\', testScriptStdout, () => $`echo.js ${'a'}\\\\${'b'}`, 'a\\\\b');153test('$ concatenates tokens - \\\\', testScriptStdout, () => $`echo.js \\\\a\\\\ b`, '\\\\a\\\\\nb');154test('$ concatenates expressions - \\\\', testScriptStdout, () => $`echo.js \\\\${'a'}\\\\ b`, '\\\\a\\\\\nb');155test('$ handles tokens - `', testScriptStdout, () => $`echo.js \``, '`');156test('$ handles expressions - `', testScriptStdout, () => $`echo.js ${'`'}`, '`');157test('$ splits tokens - `', testScriptStdout, () => $`echo.js a\`b`, 'a`b');158test('$ splits expressions - `', testScriptStdout, () => $`echo.js ${'a'}\`${'b'}`, 'a`b');159test('$ concatenates tokens - `', testScriptStdout, () => $`echo.js \`a\` b`, '`a`\nb');160test('$ concatenates expressions - `', testScriptStdout, () => $`echo.js \`${'a'}\` b`, '`a`\nb');161test('$ handles tokens - \\v', testScriptStdout, () => $`echo.js \v`, '\v');162test('$ handles expressions - \\v', testScriptStdout, () => $`echo.js ${'\v'}`, '\v');163test('$ splits tokens - \\v', testScriptStdout, () => $`echo.js a\vb`, 'a\vb');164test('$ splits expressions - \\v', testScriptStdout, () => $`echo.js ${'a'}\v${'b'}`, 'a\vb');165test('$ concatenates tokens - \\v', testScriptStdout, () => $`echo.js \va\v b`, '\va\v\nb');166test('$ concatenates expressions - \\v', testScriptStdout, () => $`echo.js \v${'a'}\v b`, '\va\v\nb');167test('$ handles tokens - \\u2028', testScriptStdout, () => $`echo.js \u2028`, '\u2028');168test('$ handles expressions - \\u2028', testScriptStdout, () => $`echo.js ${'\u2028'}`, '\u2028');169test('$ splits tokens - \\u2028', testScriptStdout, () => $`echo.js a\u2028b`, 'a\u2028b');170test('$ splits expressions - \\u2028', testScriptStdout, () => $`echo.js ${'a'}\u2028${'b'}`, 'a\u2028b');171test('$ concatenates tokens - \\u2028', testScriptStdout, () => $`echo.js \u2028a\u2028 b`, '\u2028a\u2028\nb');172test('$ concatenates expressions - \\u2028', testScriptStdout, () => $`echo.js \u2028${'a'}\u2028 b`, '\u2028a\u2028\nb');173test('$ handles tokens - \\a', testScriptStdout, () => $`echo.js \a`, 'a');174test('$ splits tokens - \\a', testScriptStdout, () => $`echo.js a\ab`, 'aab');175test('$ splits expressions - \\a', testScriptStdout, () => $`echo.js ${'a'}\a${'b'}`, 'aab');176test('$ concatenates tokens - \\a', testScriptStdout, () => $`echo.js \aa\a b`, 'aaa\nb');177test('$ concatenates expressions - \\a', testScriptStdout, () => $`echo.js \a${'a'}\a b`, 'aaa\nb');178test('$ handles tokens - \\cJ', testScriptStdout, () => $`echo.js \cJ`, 'cJ');179test('$ splits tokens - \\cJ', testScriptStdout, () => $`echo.js a\cJb`, 'acJb');180test('$ splits expressions - \\cJ', testScriptStdout, () => $`echo.js ${'a'}\cJ${'b'}`, 'acJb');181test('$ concatenates tokens - \\cJ', testScriptStdout, () => $`echo.js \cJa\cJ b`, 'cJacJ\nb');182test('$ concatenates expressions - \\cJ', testScriptStdout, () => $`echo.js \cJ${'a'}\cJ b`, 'cJacJ\nb');183test('$ handles tokens - \\.', testScriptStdout, () => $`echo.js \.`, '.');184test('$ splits tokens - \\.', testScriptStdout, () => $`echo.js a\.b`, 'a.b');185test('$ splits expressions - \\.', testScriptStdout, () => $`echo.js ${'a'}\.${'b'}`, 'a.b');186test('$ concatenates tokens - \\.', testScriptStdout, () => $`echo.js \.a\. b`, '.a.\nb');187test('$ concatenates expressions - \\.', testScriptStdout, () => $`echo.js \.${'a'}\. b`, '.a.\nb');188/* eslint-disable unicorn/no-hex-escape */189test('$ handles tokens - \\x63', testScriptStdout, () => $`echo.js \x63`, 'c');190test('$ splits tokens - \\x63', testScriptStdout, () => $`echo.js a\x63b`, 'acb');191test('$ splits expressions - \\x63', testScriptStdout, () => $`echo.js ${'a'}\x63${'b'}`, 'acb');192test('$ concatenates tokens - \\x63', testScriptStdout, () => $`echo.js \x63a\x63 b`, 'cac\nb');193test('$ concatenates expressions - \\x63', testScriptStdout, () => $`echo.js \x63${'a'}\x63 b`, 'cac\nb');194/* eslint-enable unicorn/no-hex-escape */195test('$ handles tokens - \\u0063', testScriptStdout, () => $`echo.js \u0063`, 'c');196test('$ splits tokens - \\u0063', testScriptStdout, () => $`echo.js a\u0063b`, 'acb');197test('$ splits expressions - \\u0063', testScriptStdout, () => $`echo.js ${'a'}\u0063${'b'}`, 'acb');198test('$ concatenates tokens - \\u0063', testScriptStdout, () => $`echo.js \u0063a\u0063 b`, 'cac\nb');199test('$ concatenates expressions - \\u0063', testScriptStdout, () => $`echo.js \u0063${'a'}\u0063 b`, 'cac\nb');200test('$ handles tokens - \\u{1}', testScriptStdout, () => $`echo.js \u{1}`, '\u0001');201test('$ splits tokens - \\u{1}', testScriptStdout, () => $`echo.js a\u{1}b`, 'a\u0001b');202test('$ splits expressions - \\u{1}', testScriptStdout, () => $`echo.js ${'a'}\u{1}${'b'}`, 'a\u0001b');203test('$ concatenates tokens - \\u{1}', testScriptStdout, () => $`echo.js \u{1}a\u{1} b`, '\u0001a\u0001\nb');204test('$ concatenates expressions - \\u{1}', testScriptStdout, () => $`echo.js \u{1}${'a'}\u{1} b`, '\u0001a\u0001\nb');205test('$ handles tokens - \\u{63}', testScriptStdout, () => $`echo.js \u{63}`, 'c');206test('$ splits tokens - \\u{63}', testScriptStdout, () => $`echo.js a\u{63}b`, 'acb');207test('$ splits expressions - \\u{63}', testScriptStdout, () => $`echo.js ${'a'}\u{63}${'b'}`, 'acb');208test('$ concatenates tokens - \\u{63}', testScriptStdout, () => $`echo.js \u{63}a\u{63} b`, 'cac\nb');209test('$ concatenates expressions - \\u{63}', testScriptStdout, () => $`echo.js \u{63}${'a'}\u{63} b`, 'cac\nb');210test('$ handles tokens - \\u{063}', testScriptStdout, () => $`echo.js \u{063}`, 'c');211test('$ splits tokens - \\u{063}', testScriptStdout, () => $`echo.js a\u{063}b`, 'acb');212test('$ splits expressions - \\u{063}', testScriptStdout, () => $`echo.js ${'a'}\u{063}${'b'}`, 'acb');213test('$ concatenates tokens - \\u{063}', testScriptStdout, () => $`echo.js \u{063}a\u{063} b`, 'cac\nb');214test('$ concatenates expressions - \\u{063}', testScriptStdout, () => $`echo.js \u{063}${'a'}\u{063} b`, 'cac\nb');215test('$ handles tokens - \\u{0063}', testScriptStdout, () => $`echo.js \u{0063}`, 'c');216test('$ splits tokens - \\u{0063}', testScriptStdout, () => $`echo.js a\u{0063}b`, 'acb');217test('$ splits expressions - \\u{0063}', testScriptStdout, () => $`echo.js ${'a'}\u{0063}${'b'}`, 'acb');218test('$ concatenates tokens - \\u{0063}', testScriptStdout, () => $`echo.js \u{0063}a\u{0063} b`, 'cac\nb');219test('$ concatenates expressions - \\u{0063}', testScriptStdout, () => $`echo.js \u{0063}${'a'}\u{0063} b`, 'cac\nb');220test('$ handles tokens - \\u{00063}', testScriptStdout, () => $`echo.js \u{00063}`, 'c');221test('$ splits tokens - \\u{00063}', testScriptStdout, () => $`echo.js a\u{00063}b`, 'acb');222test('$ splits expressions - \\u{00063}', testScriptStdout, () => $`echo.js ${'a'}\u{00063}${'b'}`, 'acb');223test('$ concatenates tokens - \\u{00063}', testScriptStdout, () => $`echo.js \u{00063}a\u{00063} b`, 'cac\nb');224test('$ concatenates expressions - \\u{00063}', testScriptStdout, () => $`echo.js \u{00063}${'a'}\u{00063} b`, 'cac\nb');225test('$ handles tokens - \\u{000063}', testScriptStdout, () => $`echo.js \u{000063}`, 'c');226test('$ splits tokens - \\u{000063}', testScriptStdout, () => $`echo.js a\u{000063}b`, 'acb');227test('$ splits expressions - \\u{000063}', testScriptStdout, () => $`echo.js ${'a'}\u{000063}${'b'}`, 'acb');228test('$ concatenates tokens - \\u{000063}', testScriptStdout, () => $`echo.js \u{000063}a\u{000063} b`, 'cac\nb');229test('$ concatenates expressions - \\u{000063}', testScriptStdout, () => $`echo.js \u{000063}${'a'}\u{000063} b`, 'cac\nb');230test('$ handles tokens - \\u{0000063}', testScriptStdout, () => $`echo.js \u{0000063}`, 'c');231test('$ splits tokens - \\u{0000063}', testScriptStdout, () => $`echo.js a\u{0000063}b`, 'acb');232test('$ splits expressions - \\u{0000063}', testScriptStdout, () => $`echo.js ${'a'}\u{0000063}${'b'}`, 'acb');233test('$ concatenates tokens - \\u{0000063}', testScriptStdout, () => $`echo.js \u{0000063}a\u{0000063} b`, 'cac\nb');234test('$ concatenates expressions - \\u{0000063}', testScriptStdout, () => $`echo.js \u{0000063}${'a'}\u{0000063} b`, 'cac\nb');235test('$ handles tokens - \\u{0063}}', testScriptStdout, () => $`echo.js \u{0063}}`, 'c}');236test('$ splits tokens - \\u{0063}}', testScriptStdout, () => $`echo.js a\u{0063}}b`, 'ac}b');237test('$ splits expressions - \\u{0063}}', testScriptStdout, () => $`echo.js ${'a'}\u{0063}}${'b'}`, 'ac}b');238test('$ concatenates tokens - \\u{0063}}', testScriptStdout, () => $`echo.js \u{0063}}a\u{0063}} b`, 'c}ac}\nb');239test('$ concatenates expressions - \\u{0063}}', testScriptStdout, () => $`echo.js \u{0063}}${'a'}\u{0063}} b`, 'c}ac}\nb');Split files (#791)ehmickybefore adoption932fb26
line 240why, one step back240Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 241–242why, one step back241const testScriptErrorStdout = async (t, getSubprocess) => {242 t.throws(getSubprocess, {message: /null bytes/});Add more tests related to using `\0` with `$` (#850)ehmickybefore adoption55800c3
lines 243–244why, one step back243};244Improve process arguments validation (#873)ehmickybefore adoption54b5ea7
lines 245–249why, one step back245test('$ handles tokens - \\0', testScriptErrorStdout, () => $`echo.js \0`);246test('$ splits tokens - \\0', testScriptErrorStdout, () => $`echo.js a\0b`);247test('$ splits expressions - \\0', testScriptErrorStdout, () => $`echo.js ${'a'}\0${'b'}`);248test('$ concatenates tokens - \\0', testScriptErrorStdout, () => $`echo.js \0a\0 b`);249test('$ concatenates expressions - \\0', testScriptErrorStdout, () => $`echo.js \0${'a'}\0 b`);Add more tests related to using `\0` with `$` (#850)ehmickybefore adoption55800c3
line 250why, one step back250Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 251–252why, one step back251const testScriptStdoutSync = (t, getSubprocess, expectedStdout) => {252 const {stdout} = getSubprocess();Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 253–254why, one step back253 t.is(stdout, expectedStdout);254};Split files (#791)ehmickybefore adoption932fb26
line 255why, one step back255Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 256–258why, one step back256test('$.sync', testScriptStdoutSync, () => $.sync`echo.js foo bar`, 'foo\nbar');257test('$.sync can be called $.s', testScriptStdoutSync, () => $.s`echo.js foo bar`, 'foo\nbar');258test('$.sync accepts options', testScriptStdoutSync, () => $({stripFinalNewline: true}).sync`noop.js foo`, 'foo');Split files (#791)ehmickybefore adoption932fb26
line 259why, one step back259Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 260why, one step back260const testReturnInterpolate = async (t, getSubprocess, expectedStdout, options = {}) => {Allow newlines in `$` (#843)ehmickybefore adoption1315486
line 261why, one step back261 const foo = await $(options)`echo.js foo`;Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 262why, one step back262 const {stdout} = await getSubprocess(foo);Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 263–264why, one step back263 t.is(stdout, expectedStdout);264};Split files (#791)ehmickybefore adoption932fb26
line 265why, one step back265Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 266–269why, one step back266test('$ allows execa return value interpolation', testReturnInterpolate, foo => $`echo.js ${foo} bar`, 'foo\nbar');267test('$ allows execa return value buffer interpolation', testReturnInterpolate, foo => $`echo.js ${foo} bar`, 'foo\nbar', {encoding: 'buffer'});268test('$ allows execa return value array interpolation', testReturnInterpolate, foo => $`echo.js ${[foo, 'bar']}`, 'foo\nbar');269test('$ allows execa return value buffer array interpolation', testReturnInterpolate, foo => $`echo.js ${[foo, 'bar']}`, 'foo\nbar', {encoding: 'buffer'});Split files (#791)ehmickybefore adoption932fb26
line 270why, one step back270Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 271why, one step back271const testReturnInterpolateSync = (t, getSubprocess, expectedStdout, options = {}) => {Allow newlines in `$` (#843)ehmickybefore adoption1315486
line 272why, one step back272 const foo = $(options).sync`echo.js foo`;Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 273why, one step back273 const {stdout} = getSubprocess(foo);Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 274–275why, one step back274 t.is(stdout, expectedStdout);275};Split files (#791)ehmickybefore adoption932fb26
line 276why, one step back276Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 277–280why, one step back277test('$.sync allows execa return value interpolation', testReturnInterpolateSync, foo => $.sync`echo.js ${foo} bar`, 'foo\nbar');278test('$.sync allows execa return value buffer interpolation', testReturnInterpolateSync, foo => $.sync`echo.js ${foo} bar`, 'foo\nbar', {encoding: 'buffer'});279test('$.sync allows execa return value array interpolation', testReturnInterpolateSync, foo => $.sync`echo.js ${[foo, 'bar']}`, 'foo\nbar');280test('$.sync allows execa return value buffer array interpolation', testReturnInterpolateSync, foo => $.sync`echo.js ${[foo, 'bar']}`, 'foo\nbar', {encoding: 'buffer'});Split files (#791)ehmickybefore adoption932fb26
line 281why, one step back281Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 282–283why, one step back282const testInvalidSequence = (t, getSubprocess) => {283 t.throws(getSubprocess, {message: /Invalid backslash sequence/});Allow newlines in `$` (#843)ehmickybefore adoption1315486
line 284why, one step back284};Split files (#791)ehmickybefore adoption932fb26
line 285why, one step back285Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 286–299why, one step back286test('$ handles invalid escape sequence - \\1', testInvalidSequence, () => $`echo.js \1`);287test('$ handles invalid escape sequence - \\u', testInvalidSequence, () => $`echo.js \u`);288test('$ handles invalid escape sequence - \\u0', testInvalidSequence, () => $`echo.js \u0`);289test('$ handles invalid escape sequence - \\u00', testInvalidSequence, () => $`echo.js \u00`);290test('$ handles invalid escape sequence - \\u000', testInvalidSequence, () => $`echo.js \u000`);291test('$ handles invalid escape sequence - \\ug', testInvalidSequence, () => $`echo.js \ug`);292test('$ handles invalid escape sequence - \\u{', testInvalidSequence, () => $`echo.js \u{`);293test('$ handles invalid escape sequence - \\u{0000', testInvalidSequence, () => $`echo.js \u{0000`);294test('$ handles invalid escape sequence - \\u{g}', testInvalidSequence, () => $`echo.js \u{g}`);295/* eslint-disable unicorn/no-hex-escape */296test('$ handles invalid escape sequence - \\x', testInvalidSequence, () => $`echo.js \x`);297test('$ handles invalid escape sequence - \\x0', testInvalidSequence, () => $`echo.js \x0`);298test('$ handles invalid escape sequence - \\xgg', testInvalidSequence, () => $`echo.js \xgg`);299/* eslint-enable unicorn/no-hex-escape */Split files (#791)ehmickybefore adoption932fb26
line 300why, one step back300Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 301–302why, one step back301const testEmptyScript = (t, getSubprocess) => {302 t.throws(getSubprocess, {message: /Template script must not be empty/});Allow newlines in `$` (#843)ehmickybefore adoption1315486
line 303why, one step back303};Split files (#791)ehmickybefore adoption932fb26
line 304why, one step back304Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 305–310why, one step back305test('$``', testEmptyScript, () => $``);306test('$` `', testEmptyScript, () => $` `);307test('$` ` (2 spaces)', testEmptyScript, () => $` `);308test('$`\\t`', testEmptyScript, () => $` `);309test('$`\\n`', testEmptyScript, () => $`310`);Split files (#791)ehmickybefore adoption932fb26
line 311why, one step back311Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 312–313why, one step back312test('$.sync must be used after options binding, not before', t => {313 t.throws(() => $.sync({})`noop.js`, {message: /Please use/});Split files (#791)ehmickybefore adoption932fb26
lines 314–315why, one step back314});315Improve input validation (#838)ehmickybefore adoption8ee137c
lines 316–321why, one step back316test('$ must only use options or templates', t => {317 t.throws(() => $(true)`noop.js`, {message: /Please use either/});318});319320test('$.sync must only templates', t => {321 t.throws(() => $.sync(true)`noop.js`, {message: /A template string must be used/});Split files (#791)ehmickybefore adoption932fb26
lines 322–323why, one step back322});323Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 324–330why, one step back324const testInvalidExpression = (t, invalidExpression, execaMethod) => {325 const expression = typeof invalidExpression === 'function' ? invalidExpression() : invalidExpression;326 t.throws(327 () => execaMethod`echo.js ${expression}`,328 {message: /in template expression/},329 );330};Split files (#791)ehmickybefore adoption932fb26
line 331why, one step back331Allow newlines in `$` (#843)ehmickybefore adoption1315486
lines 332–353why, one step back332test('$ throws on invalid expression - undefined', testInvalidExpression, undefined, $);333test('$ throws on invalid expression - null', testInvalidExpression, null, $);334test('$ throws on invalid expression - true', testInvalidExpression, true, $);335test('$ throws on invalid expression - {}', testInvalidExpression, {}, $);336test('$ throws on invalid expression - {foo: "bar"}', testInvalidExpression, {foo: 'bar'}, $);337test('$ throws on invalid expression - {stdout: undefined}', testInvalidExpression, {stdout: undefined}, $);338test('$ throws on invalid expression - {stdout: 1}', testInvalidExpression, {stdout: 1}, $);339test('$ throws on invalid expression - Promise.resolve()', testInvalidExpression, Promise.resolve(), $);340test('$ throws on invalid expression - Promise.resolve({stdout: "foo"})', testInvalidExpression, Promise.resolve({foo: 'bar'}), $);341test('$ throws on invalid expression - $', testInvalidExpression, () => $`noop.js`, $);342test('$ throws on invalid expression - $(options).sync', testInvalidExpression, () => $({stdio: 'ignore'}).sync`noop.js`, $);343test('$ throws on invalid expression - [undefined]', testInvalidExpression, [undefined], $);344test('$ throws on invalid expression - [null]', testInvalidExpression, [null], $);345test('$ throws on invalid expression - [true]', testInvalidExpression, [true], $);346test('$ throws on invalid expression - [{}]', testInvalidExpression, [{}], $);347test('$ throws on invalid expression - [{foo: "bar"}]', testInvalidExpression, [{foo: 'bar'}], $);348test('$ throws on invalid expression - [{stdout: undefined}]', testInvalidExpression, [{stdout: undefined}], $);349test('$ throws on invalid expression - [{stdout: 1}]', testInvalidExpression, [{stdout: 1}], $);350test('$ throws on invalid expression - [Promise.resolve()]', testInvalidExpression, [Promise.resolve()], $);351test('$ throws on invalid expression - [Promise.resolve({stdout: "foo"})]', testInvalidExpression, [Promise.resolve({stdout: 'foo'})], $);352test('$ throws on invalid expression - [$]', testInvalidExpression, () => [$`noop.js`], $);353test('$ throws on invalid expression - [$(options).sync]', testInvalidExpression, () => [$({stdio: 'ignore'}).sync`noop.js`], $);Split files (#791)ehmickybefore adoption932fb26
lines 354–367why, one step back354355test('$ stdin defaults to "inherit"', async t => {356 const {stdout} = await $({input: 'foo'})`stdin-script.js`;357 t.is(stdout, 'foo');358});359360test('$.sync stdin defaults to "inherit"', t => {361 const {stdout} = $({input: 'foo'}).sync`stdin-script.js`;362 t.is(stdout, 'foo');363});364365test('$ stdin has no default value when stdio is set', t => {366 t.true(isStream($({stdio: 'pipe'})`noop.js`.stdin));367});