Skip to content

Commit

Permalink
Modify tests to not rely on buffer size, but only test larger output
Browse files Browse the repository at this point in the history
  • Loading branch information
luketomlinson committed May 20, 2021
1 parent f844327 commit 69a8751
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions packages/exec/__tests__/exec.test.ts
Expand Up @@ -679,7 +679,6 @@ describe('@actions/exec', () => {
'stdoutoutput.js'
)

let numberOfBuffers = 0
const nodePath: string = await io.which('node', true)
let listenerOut = ''

Expand All @@ -691,7 +690,6 @@ describe('@actions/exec', () => {
listeners: {
stdout: data => {
listenerOut = data.toString()
numberOfBuffers += 1
}
}
}
Expand All @@ -700,7 +698,6 @@ describe('@actions/exec', () => {
expect(exitCodeOut).toBe(0)
expect(stdout).toBe('this is output to stdout')
expect(listenerOut).toBe('this is output to stdout')
expect(numberOfBuffers).toBe(1)

let listenerErr = ''
const {exitCode: exitCodeErr, stderr} = await exec.getExecOutput(
Expand Down Expand Up @@ -732,7 +729,6 @@ describe('@actions/exec', () => {
'stdoutoutputlarge.js'
)

let numFullBuffers = 0
const nodePath: string = await io.which('node', true)
let listenerOut = ''

Expand All @@ -743,17 +739,15 @@ describe('@actions/exec', () => {
...getExecOptions(),
listeners: {
stdout: data => {
numFullBuffers += 1
listenerOut += data.toString()
}
}
}
)

expect(exitCodeOut).toBe(0)
expect(Buffer.byteLength(stdout || '', 'utf8')).toBe(2 ** 32)
expect(Buffer.byteLength(listenerOut, 'utf8')).toBe(2 ** 32)
expect(numFullBuffers).toBeGreaterThan(1)
expect(Buffer.byteLength(stdout || '', 'utf8')).toBe(2 ** 24)
expect(Buffer.byteLength(listenerOut, 'utf8')).toBe(2 ** 24)

let listenerErr = ''
const {exitCode: exitCodeErr, stderr} = await exec.getExecOutput(
Expand Down
2 changes: 1 addition & 1 deletion packages/exec/__tests__/scripts/stdoutoutputlarge.js
@@ -1,3 +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**32));
process.stdout.write('a'.repeat(2**24));

0 comments on commit 69a8751

Please sign in to comment.