From 8df94d9879bfbc0d59bbf3d26779ecf286108ad7 Mon Sep 17 00:00:00 2001 From: Luke Tomlinson Date: Thu, 3 Jun 2021 09:31:48 -0400 Subject: [PATCH] Add test for large stdline output (#827) * Add test for large stdline output * Format/Lint * Update stdlineoutput.js * Update stdlineoutput.js --- packages/exec/__tests__/exec.test.ts | 25 +++++++++++++++++++ .../exec/__tests__/scripts/stdlineoutput.js | 5 ++++ 2 files changed, 30 insertions(+) create mode 100644 packages/exec/__tests__/scripts/stdlineoutput.js diff --git a/packages/exec/__tests__/exec.test.ts b/packages/exec/__tests__/exec.test.ts index 054d2690..e2f6fc37 100644 --- a/packages/exec/__tests__/exec.test.ts +++ b/packages/exec/__tests__/exec.test.ts @@ -286,6 +286,31 @@ describe('@actions/exec', () => { expect(stderrCalled).toBeTruthy() }) + it('Handles large stdline', async () => { + const stdlinePath: string = path.join( + __dirname, + 'scripts', + 'stdlineoutput.js' + ) + const nodePath: string = await io.which('node', true) + + const _testExecOptions = getExecOptions() + let largeLine = '' + _testExecOptions.listeners = { + stdline: (line: string) => { + largeLine = line + } + } + + const exitCode = await exec.exec( + `"${nodePath}"`, + [stdlinePath], + _testExecOptions + ) + expect(exitCode).toBe(0) + expect(Buffer.byteLength(largeLine)).toEqual(2 ** 16 + 1) + }) + it('Handles stdin shell', async () => { let command: string if (IS_WINDOWS) { diff --git a/packages/exec/__tests__/scripts/stdlineoutput.js b/packages/exec/__tests__/scripts/stdlineoutput.js new file mode 100644 index 00000000..1cea8276 --- /dev/null +++ b/packages/exec/__tests__/scripts/stdlineoutput.js @@ -0,0 +1,5 @@ +//Default highWaterMark for readable stream buffers us 64K (2^16) +//so we go over that to get more than a buffer's worth +const os = require('os') + +process.stdout.write('a'.repeat(2**16 + 1) + os.EOL);