script.js
This file
Path
test/methods/script.js
60 lines · 2.2 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–2why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 3–9why, one step back3import {isStream} from 'is-stream';4import {$} from '../../index.js';5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {foobarString} from '../helpers/input.js';78setFixtureDirectory();9TweaksSindre Sorhusbefore adoption698a1b8
line 10why, one step back10const testScriptStdoutSync = (getSubprocess, expectedStdout) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 11why, one step back11 const {stdout} = getSubprocess();TweaksSindre Sorhusbefore adoption698a1b8
line 12why, one step back12 assert.equal(stdout, expectedStdout);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 13–14why, one step back13};14TweaksSindre Sorhusbefore adoption698a1b8
lines 15–18why, one step back15test('$.sync`...`', () => testScriptStdoutSync(() => $.sync`echo.js foo bar`, 'foo\nbar'));16test('$.s`...`', () => testScriptStdoutSync(() => $.s`echo.js foo bar`, 'foo\nbar'));17test('$(options).sync`...`', () => testScriptStdoutSync(() => $({stripFinalNewline: false}).sync`echo.js ${foobarString}`, `${foobarString}\n`));18test('$.sync(options)`...`', () => testScriptStdoutSync(() => $.sync({stripFinalNewline: false})`echo.js ${foobarString}`, `${foobarString}\n`));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 19why, one step back19TweaksSindre Sorhusbefore adoption698a1b8
lines 20–21why, one step back20test('Cannot call $.sync.sync', () => {21 assert.equal('sync' in $.sync, false);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 22–23why, one step back22});23TweaksSindre Sorhusbefore adoption698a1b8
lines 24–25why, one step back24test('Cannot call $.sync(options).sync', () => {25 assert.equal('sync' in $.sync({}), false);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 26–27why, one step back26});27TweaksSindre Sorhusbefore adoption698a1b8
line 28why, one step back28test('$(options)() stdin defaults to "inherit"', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 29why, one step back29 const {stdout} = await $({input: foobarString})('stdin-script.js');TweaksSindre Sorhusbefore adoption698a1b8
line 30why, one step back30 assert.equal(stdout, foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 31–32why, one step back31});32TweaksSindre Sorhusbefore adoption698a1b8
line 33why, one step back33test('$.sync(options)() stdin defaults to "inherit"', () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 34why, one step back34 const {stdout} = $.sync({input: foobarString})('stdin-script.js');TweaksSindre Sorhusbefore adoption698a1b8
line 35why, one step back35 assert.equal(stdout, foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 36–37why, one step back36});37TweaksSindre Sorhusbefore adoption698a1b8
line 38why, one step back38test('$(options).sync() stdin defaults to "inherit"', () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 39why, one step back39 const {stdout} = $({input: foobarString}).sync('stdin-script.js');TweaksSindre Sorhusbefore adoption698a1b8
line 40why, one step back40 assert.equal(stdout, foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 41–42why, one step back41});42TweaksSindre Sorhusbefore adoption698a1b8
line 43why, one step back43test('$(options)`...` stdin defaults to "inherit"', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 44why, one step back44 const {stdout} = await $({input: foobarString})`stdin-script.js`;TweaksSindre Sorhusbefore adoption698a1b8
line 45why, one step back45 assert.equal(stdout, foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 46–47why, one step back46});47TweaksSindre Sorhusbefore adoption698a1b8
line 48why, one step back48test('$.sync(options)`...` stdin defaults to "inherit"', () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 49why, one step back49 const {stdout} = $.sync({input: foobarString})`stdin-script.js`;TweaksSindre Sorhusbefore adoption698a1b8
line 50why, one step back50 assert.equal(stdout, foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 51–52why, one step back51});52TweaksSindre Sorhusbefore adoption698a1b8
line 53why, one step back53test('$(options).sync`...` stdin defaults to "inherit"', () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 54why, one step back54 const {stdout} = $({input: foobarString}).sync`stdin-script.js`;TweaksSindre Sorhusbefore adoption698a1b8
line 55why, one step back55 assert.equal(stdout, foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 56–57why, one step back56});57TweaksSindre Sorhusbefore adoption698a1b8
lines 58–59why, one step back58test('$ stdin has no default value when stdio is set', () => {59 assert.ok(isStream($({stdio: 'pipe'})`noop.js`.stdin));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 60why, one step back60});