@@ -6,7 +6,7 @@ import { generateGcovCoverageFiles } from '../../src/helpers/gcov'
66describe ( 'generateGcovCoverageFiles()' , ( ) => {
77 afterEach ( ( ) => {
88 td . reset ( )
9- } )
9+ } )
1010
1111 it ( 'should find and run on test/fixtures/gcov/main.gcno' , ( ) => {
1212 const projectRoot = process . cwd ( )
@@ -21,18 +21,30 @@ Lines executed:0.00% of 11`)
2121 } )
2222 it ( 'should find no gcno files and return an error' , ( ) => {
2323 const projectRoot = process . cwd ( )
24- expect ( ( ) => { generateGcovCoverageFiles ( projectRoot , [ ] , [ 'test' ] ) } ) . toThrowError ( / N o g c o v f i l e s f o u n d / )
24+ expect ( ( ) => { generateGcovCoverageFiles ( projectRoot , [ ] , [ 'test' ] ) } ) . toThrowError ( / N o g c o v f i l e s f o u n d / )
2525
2626
2727 } )
2828
2929 it ( 'should pass gcov arguments directly through' , ( ) => {
3030 const spawnSync = td . replace ( childProcess , 'spawnSync' )
31+ td . when ( spawnSync ( 'gcov' ) ) . thenReturn ( {
32+ stdout : 'gcov installed' ,
33+ error : null
34+ } )
3135 td . when ( spawnSync ( 'gcov' , td . matchers . contains ( 'NEWGCOVARG' ) ) ) . thenReturn ( {
32- stdout : 'Matched' ,
36+ stdout : 'Matched' ,
3337 } )
3438
3539 const projectRoot = process . cwd ( )
36- expect ( generateGcovCoverageFiles ( projectRoot , [ ] , [ ] , 'NEWGCOVARG' ) ) . toEqual ( "Matched" )
40+ expect ( generateGcovCoverageFiles ( projectRoot , [ ] , [ ] , 'NEWGCOVARG' ) ) . toEqual ( "Matched" )
41+ } )
42+
43+ it ( 'should return an error when gcov is not installed' , ( ) => {
44+ const spawnSync = td . replace ( childProcess , 'spawnSync' )
45+ td . when ( spawnSync ( 'gcov' ) ) . thenReturn ( { error : "Command 'gcov' not found" } )
46+
47+ const projectRoot = process . cwd ( )
48+ expect ( ( ) => generateGcovCoverageFiles ( projectRoot , [ ] , [ ] , 'NEWGCOVARG' ) ) . toThrowError ( / g c o v i s n o t i n s t a l l e d / )
3749 } )
3850} )
0 commit comments