-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #729 from gabrielrussoc/100mb-spawnSync
fix: increase maxBuffer of spawnSync
- Loading branch information
Showing
4 changed files
with
52 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export const DEFAULT_UPLOAD_HOST = 'https://codecov.io' | ||
|
||
export const SPAWNPROCESSBUFFERSIZE = 1_048_576 * 100 // 100 MiB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,60 @@ | ||
import childProcess from 'child_process' | ||
import td from 'testdouble' | ||
import { | ||
isProgramInstalled, | ||
runExternalProgram, | ||
SPAWNPROCESSBUFFERSIZE, | ||
} from '../../src/helpers/util' | ||
import { isProgramInstalled, runExternalProgram } from '../../src/helpers/util' | ||
import { SPAWNPROCESSBUFFERSIZE } from '../../src/helpers/constansts' | ||
|
||
describe('isProgramInstalled()', () => { | ||
afterEach(() => { | ||
td.reset() | ||
}) | ||
|
||
it('should throw an error when program is not found', () => { | ||
const spawnSync = td.replace(childProcess, 'spawnSync') | ||
td.when(spawnSync('fooProg')).thenReturn({ | ||
error: 'Huh?', | ||
}) | ||
expect(isProgramInstalled('fooProg')).toBeFalsy() | ||
|
||
afterEach(() => { | ||
td.reset() | ||
}) | ||
|
||
it('should throw an error when program is not found', () => { | ||
const spawnSync = td.replace(childProcess, 'spawnSync') | ||
td.when(spawnSync('fooProg')).thenReturn({ | ||
error: 'Huh?', | ||
}) | ||
expect(isProgramInstalled('fooProg')).toBeFalsy() | ||
}) | ||
}) | ||
|
||
describe('runExternalProgram()', () => { | ||
afterEach(() => { | ||
td.reset() | ||
afterEach(() => { | ||
td.reset() | ||
}) | ||
|
||
it('should throw an error when program is not found', () => { | ||
const spawnSync = td.replace(childProcess, 'spawnSync') | ||
td.when( | ||
spawnSync('ls', ['-geewhiz'], { maxBuffer: SPAWNPROCESSBUFFERSIZE }), | ||
).thenReturn({ | ||
error: 'Huh?', | ||
}) | ||
|
||
it('should throw an error when program is not found', () => { | ||
const spawnSync = td.replace(childProcess, 'spawnSync') | ||
td.when(spawnSync('ls', ['-geewhiz'], { maxBuffer: SPAWNPROCESSBUFFERSIZE })).thenReturn({ | ||
error: 'Huh?', | ||
}) | ||
expect(() => runExternalProgram('ls', ['-geewhiz'])).toThrowError(/Huh\?/) | ||
|
||
expect(() => runExternalProgram('ls', ['-geewhiz'])).toThrowError(/Huh\?/) | ||
}) | ||
|
||
it('should return stdout on success', () => { | ||
const spawnSync = td.replace(childProcess, 'spawnSync') | ||
td.when( | ||
spawnSync('ls', ['-geewhiz'], { maxBuffer: SPAWNPROCESSBUFFERSIZE }), | ||
).thenReturn({ | ||
stdout: 'I am output', | ||
}) | ||
expect(runExternalProgram('ls', ['-geewhiz'])).toEqual('I am output') | ||
}) | ||
|
||
it('should return stdout on success', () => { | ||
const spawnSync = td.replace(childProcess, 'spawnSync') | ||
td.when(spawnSync('ls', ['-geewhiz'], { maxBuffer: SPAWNPROCESSBUFFERSIZE })).thenReturn({ | ||
stdout: 'I am output', | ||
}) | ||
expect(runExternalProgram('ls', ['-geewhiz'])).toEqual("I am output") | ||
|
||
}) | ||
|
||
it('should return a trimmed string with no newlines', () => { | ||
const spawnSync = td.replace(childProcess, 'spawnSync') | ||
td.when(spawnSync('ls', ['-geewhiz'], { maxBuffer: SPAWNPROCESSBUFFERSIZE })).thenReturn({ | ||
stdout: ` | ||
it('should return a trimmed string with no newlines', () => { | ||
const spawnSync = td.replace(childProcess, 'spawnSync') | ||
td.when( | ||
spawnSync('ls', ['-geewhiz'], { maxBuffer: SPAWNPROCESSBUFFERSIZE }), | ||
).thenReturn({ | ||
stdout: ` | ||
I am output | ||
`, | ||
}) | ||
expect(runExternalProgram('ls', ['-geewhiz'])).toEqual("I am output") | ||
|
||
}) | ||
expect(runExternalProgram('ls', ['-geewhiz'])).toEqual('I am output') | ||
}) | ||
}) |