@@ -770,6 +770,48 @@ describe('Processor', function() {
770770 } )
771771 . saveToFile ( testFile ) ;
772772 } ) ;
773+
774+ it ( 'should pass input stream errors through to error handler' , function ( done ) {
775+ var testFile = path . join ( __dirname , 'assets' , 'testConvertFromStream.avi' )
776+
777+ const readError = new Error ( 'Read Error' )
778+ const instream = new ( require ( 'stream' ) . Readable ) ( {
779+ read ( ) {
780+ process . nextTick ( ( ) => this . emit ( 'error' , readError ) )
781+ }
782+ } )
783+
784+ const command = this . getCommand ( { source : instream , logger : testhelper . logger } )
785+
786+ let startCalled = false
787+ const self = this
788+
789+ command
790+ . usingPreset ( 'divx' )
791+ . on ( 'start' , function ( ) {
792+ startCalled = true
793+ command . ffmpegProc . on ( 'exit' , function ( ) {
794+ fs . exists ( testFile , ( exists ) => {
795+ exists . should . be . false ( )
796+ done ( )
797+ } )
798+ } )
799+ } )
800+ . on ( 'error' , function ( err , stdout , stderr ) {
801+ self . saveOutput ( stdout , stderr )
802+ startCalled . should . be . true ( )
803+ assert . ok ( err )
804+ err . message . indexOf ( 'Input stream error: ' ) . should . equal ( 0 )
805+ assert . strictEqual ( err . inputStreamError , readError )
806+ } )
807+ . on ( 'end' , function ( stdout , stderr ) {
808+ testhelper . logOutput ( stdout , stderr )
809+ console . log ( 'end was called, expected a error' )
810+ assert . ok ( false )
811+ done ( )
812+ } )
813+ . saveToFile ( testFile )
814+ } )
773815 } ) ;
774816
775817 describe ( 'mergeToFile' , function ( ) {
0 commit comments