From 8251af3c716333224508d7a181df23ec8c150320 Mon Sep 17 00:00:00 2001 From: Luke Tomlinson Date: Wed, 2 Jun 2021 16:55:00 -0400 Subject: [PATCH 1/4] Add test for large stdline output --- packages/exec/__tests__/exec.test.ts | 28 +++++++++++++++++++ .../exec/__tests__/scripts/stdlineoutput.js | 3 ++ 2 files changed, 31 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 054d269084..b67469637a 100644 --- a/packages/exec/__tests__/exec.test.ts +++ b/packages/exec/__tests__/exec.test.ts @@ -286,6 +286,34 @@ 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 + + } + } + + let 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 0000000000..9f455e7980 --- /dev/null +++ b/packages/exec/__tests__/scripts/stdlineoutput.js @@ -0,0 +1,3 @@ +//Default highWaterMark for readable stream buffers us 64K (2^16) +//so we go over that to get more than a buffer's worth +process.stdout.write('a'.repeat(2**16 + 1) + '\n'); From 89e2bb4998bb264b1256a54f0e0639ae3edeab20 Mon Sep 17 00:00:00 2001 From: Luke Tomlinson Date: Wed, 2 Jun 2021 17:17:28 -0400 Subject: [PATCH 2/4] Format/Lint --- packages/exec/__tests__/exec.test.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/exec/__tests__/exec.test.ts b/packages/exec/__tests__/exec.test.ts index b67469637a..e2f6fc37b3 100644 --- a/packages/exec/__tests__/exec.test.ts +++ b/packages/exec/__tests__/exec.test.ts @@ -287,7 +287,6 @@ describe('@actions/exec', () => { }) it('Handles large stdline', async () => { - const stdlinePath: string = path.join( __dirname, 'scripts', @@ -300,18 +299,16 @@ describe('@actions/exec', () => { _testExecOptions.listeners = { stdline: (line: string) => { largeLine = line - } } - let exitCode = await exec.exec( + const exitCode = await exec.exec( `"${nodePath}"`, [stdlinePath], _testExecOptions ) expect(exitCode).toBe(0) - expect(Buffer.byteLength(largeLine)).toEqual(2**16 + 1) - + expect(Buffer.byteLength(largeLine)).toEqual(2 ** 16 + 1) }) it('Handles stdin shell', async () => { From 089185db68e5dce2ec6fa099c04ea23d3dd5a60c Mon Sep 17 00:00:00 2001 From: Luke Tomlinson Date: Wed, 2 Jun 2021 17:25:53 -0400 Subject: [PATCH 3/4] Update stdlineoutput.js --- packages/exec/__tests__/scripts/stdlineoutput.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/exec/__tests__/scripts/stdlineoutput.js b/packages/exec/__tests__/scripts/stdlineoutput.js index 9f455e7980..675591c30b 100644 --- a/packages/exec/__tests__/scripts/stdlineoutput.js +++ b/packages/exec/__tests__/scripts/stdlineoutput.js @@ -1,3 +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 -process.stdout.write('a'.repeat(2**16 + 1) + '\n'); +import * as os from 'os' + +process.stdout.write('a'.repeat(2**16 + 1) + os.EOL); From f29f1061b3114a00650c549eec236e0c108df7f4 Mon Sep 17 00:00:00 2001 From: Luke Tomlinson Date: Wed, 2 Jun 2021 17:32:36 -0400 Subject: [PATCH 4/4] Update stdlineoutput.js --- packages/exec/__tests__/scripts/stdlineoutput.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/exec/__tests__/scripts/stdlineoutput.js b/packages/exec/__tests__/scripts/stdlineoutput.js index 675591c30b..1cea8276b2 100644 --- a/packages/exec/__tests__/scripts/stdlineoutput.js +++ b/packages/exec/__tests__/scripts/stdlineoutput.js @@ -1,5 +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 -import * as os from 'os' +const os = require('os') process.stdout.write('a'.repeat(2**16 + 1) + os.EOL);