lines-max-buffer.js
This file
Path
test/stdio/lines-max-buffer.js
52 lines · 2.5 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–3why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';3import {assertThrows, assertRejects} from '../helpers/assert.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 4–12why, one step back4import {execa, execaSync} from '../../index.js';5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {simpleLines, noNewlinesChunks, getSimpleChunkSubprocessAsync} from '../helpers/lines.js';7import {assertErrorMessage} from '../helpers/max-buffer.js';89setFixtureDirectory();1011const maxBuffer = simpleLines.length - 1;12TweaksSindre Sorhusbefore adoption698a1b8
line 13why, one step back13const testBelowMaxBuffer = async lines => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 14why, one step back14 const {isMaxBuffer, stdout} = await getSimpleChunkSubprocessAsync({lines, maxBuffer: maxBuffer + 1});TweaksSindre Sorhusbefore adoption698a1b8
lines 15–16why, one step back15 assert.equal(isMaxBuffer, false);16 assert.deepEqual(stdout, noNewlinesChunks);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 17–18why, one step back17};18TweaksSindre Sorhusbefore adoption698a1b8
lines 19–20why, one step back19test('"lines: true" can be below "maxBuffer"', () => testBelowMaxBuffer(true));20test('"lines: true" can be below "maxBuffer", fd-specific', () => testBelowMaxBuffer({stdout: true}));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 21why, one step back21TweaksSindre Sorhusbefore adoption698a1b8
lines 22–26why, one step back22const testAboveMaxBuffer = async lines => {23 const {isMaxBuffer, shortMessage, stdout} = await assertRejects(getSimpleChunkSubprocessAsync({lines, maxBuffer}));24 assert.equal(isMaxBuffer, true);25 assertErrorMessage(shortMessage, {length: maxBuffer, unit: 'lines'});26 assert.deepEqual(stdout, noNewlinesChunks.slice(0, maxBuffer));100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 27–28why, one step back27};28TweaksSindre Sorhusbefore adoption698a1b8
lines 29–30why, one step back29test('"lines: true" can be above "maxBuffer"', () => testAboveMaxBuffer(true));30test('"lines: true" can be above "maxBuffer", fd-specific', () => testAboveMaxBuffer({stdout: true}));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 31why, one step back31TweaksSindre Sorhusbefore adoption698a1b8
lines 32–36why, one step back32const testMaxBufferUnit = async lines => {33 const {isMaxBuffer, shortMessage, stdout} = await assertRejects(execa('noop-repeat.js', ['1', '...\n'], {lines, maxBuffer}));34 assert.equal(isMaxBuffer, true);35 assertErrorMessage(shortMessage, {length: maxBuffer, unit: 'lines'});36 assert.deepEqual(stdout, ['...', '...']);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 37–38why, one step back37};38TweaksSindre Sorhusbefore adoption698a1b8
lines 39–40why, one step back39test('"maxBuffer" is measured in lines with "lines: true"', () => testMaxBufferUnit(true));40test('"maxBuffer" is measured in lines with "lines: true", fd-specific', () => testMaxBufferUnit({stdout: true}));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 41why, one step back41TweaksSindre Sorhusbefore adoption698a1b8
lines 42–43why, one step back42const testMaxBufferUnitSync = lines => {43 const {isMaxBuffer, shortMessage, stdout} = assertThrows(() => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 44–45why, one step back44 execaSync('noop-repeat.js', ['1', '...\n'], {lines, maxBuffer});45 }, {code: 'ENOBUFS'});TweaksSindre Sorhusbefore adoption698a1b8
lines 46–48why, one step back46 assert.equal(isMaxBuffer, true);47 assertErrorMessage(shortMessage, {execaMethod: execaSync, length: maxBuffer});48 assert.deepEqual(stdout, ['..']);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 49–50why, one step back49};50TweaksSindre Sorhusbefore adoption698a1b8
lines 51–52why, one step back51test('"maxBuffer" is measured in bytes with "lines: true", sync', () => testMaxBufferUnitSync(true));52test('"maxBuffer" is measured in bytes with "lines: true", fd-specific, sync', () => testMaxBufferUnitSync({stdout: true}));