lines-max-buffer.js
This file
Path
test/stdio/lines-max-buffer.js
50 lines · 2.3 KiB · JavaScript
Last changed by
Upgrade xo (#980)ehmickybefore adoptionccfa412
History of this fileTake it
Split files into smaller ones (#976)ehmickybefore adoptiond7c6853
lines 1–2why, one step back1import test from 'ava';2import {execa, execaSync} from '../../index.js';Upgrade xo (#980)ehmickybefore adoptionccfa412
line 3why, one step back3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';Split files into smaller ones (#976)ehmickybefore adoptiond7c6853
lines 4–6why, one step back4import {simpleLines, noNewlinesChunks, getSimpleChunkSubprocessAsync} from '../helpers/lines.js';5import {assertErrorMessage} from '../helpers/max-buffer.js';6Upgrade xo (#980)ehmickybefore adoptionccfa412
line 7why, one step back7setFixtureDirectory();Split files into smaller ones (#976)ehmickybefore adoptiond7c6853
lines 8–50why, one step back89const maxBuffer = simpleLines.length - 1;1011const testBelowMaxBuffer = async (t, lines) => {12 const {isMaxBuffer, stdout} = await getSimpleChunkSubprocessAsync({lines, maxBuffer: maxBuffer + 1});13 t.false(isMaxBuffer);14 t.deepEqual(stdout, noNewlinesChunks);15};1617test('"lines: true" can be below "maxBuffer"', testBelowMaxBuffer, true);18test('"lines: true" can be below "maxBuffer", fd-specific', testBelowMaxBuffer, {stdout: true});1920const testAboveMaxBuffer = async (t, lines) => {21 const {isMaxBuffer, shortMessage, stdout} = await t.throwsAsync(getSimpleChunkSubprocessAsync({lines, maxBuffer}));22 t.true(isMaxBuffer);23 assertErrorMessage(t, shortMessage, {length: maxBuffer, unit: 'lines'});24 t.deepEqual(stdout, noNewlinesChunks.slice(0, maxBuffer));25};2627test('"lines: true" can be above "maxBuffer"', testAboveMaxBuffer, true);28test('"lines: true" can be above "maxBuffer", fd-specific', testAboveMaxBuffer, {stdout: true});2930const testMaxBufferUnit = async (t, lines) => {31 const {isMaxBuffer, shortMessage, stdout} = await t.throwsAsync(execa('noop-repeat.js', ['1', '...\n'], {lines, maxBuffer}));32 t.true(isMaxBuffer);33 assertErrorMessage(t, shortMessage, {length: maxBuffer, unit: 'lines'});34 t.deepEqual(stdout, ['...', '...']);35};3637test('"maxBuffer" is measured in lines with "lines: true"', testMaxBufferUnit, true);38test('"maxBuffer" is measured in lines with "lines: true", fd-specific', testMaxBufferUnit, {stdout: true});3940const testMaxBufferUnitSync = (t, lines) => {41 const {isMaxBuffer, shortMessage, stdout} = t.throws(() => {42 execaSync('noop-repeat.js', ['1', '...\n'], {lines, maxBuffer});43 }, {code: 'ENOBUFS'});44 t.true(isMaxBuffer);45 assertErrorMessage(t, shortMessage, {execaMethod: execaSync, length: maxBuffer});46 t.deepEqual(stdout, ['..']);47};4849test('"maxBuffer" is measured in bytes with "lines: true", sync', testMaxBufferUnitSync, true);50test('"maxBuffer" is measured in bytes with "lines: true", fd-specific, sync', testMaxBufferUnitSync, {stdout: true});