@@ -334,6 +334,18 @@ function suite(moduleName) {
334334 base : dir + '/fixtures' ,
335335 path : dir + '/fixtures/stuff/test.dmc' ,
336336 } ,
337+ {
338+ cwd : dir ,
339+ base : dir + '/fixtures' ,
340+ path : dir + '/fixtures/symlinks/symlink-dest/test.js' ,
341+ } ,
342+ {
343+ cwd : dir ,
344+ base : dir + '/fixtures' ,
345+ path :
346+ dir +
347+ '/fixtures/symlinks/symlink-dest/hey/isaidhey/whatsgoingon/test.txt' ,
348+ } ,
337349 ] ;
338350
339351 var globs = [
@@ -344,12 +356,14 @@ function suite(moduleName) {
344356 ] ;
345357
346358 function assert ( pathObjs ) {
347- expect ( pathObjs . length ) . toEqual ( 5 ) ;
359+ expect ( pathObjs . length ) . toEqual ( 7 ) ;
348360 expect ( pathObjs ) . toContainEqual ( expected [ 0 ] ) ;
349361 expect ( pathObjs ) . toContainEqual ( expected [ 1 ] ) ;
350362 expect ( pathObjs ) . toContainEqual ( expected [ 2 ] ) ;
351363 expect ( pathObjs ) . toContainEqual ( expected [ 3 ] ) ;
352364 expect ( pathObjs ) . toContainEqual ( expected [ 4 ] ) ;
365+ expect ( pathObjs ) . toContainEqual ( expected [ 5 ] ) ;
366+ expect ( pathObjs ) . toContainEqual ( expected [ 6 ] ) ;
353367 }
354368
355369 stream . pipeline ( [ globStream ( globs , { cwd : dir } ) , concat ( assert ) ] , done ) ;
@@ -736,6 +750,37 @@ function suite(moduleName) {
736750 done
737751 ) ;
738752 } ) ;
753+
754+ it ( 'traverses symlinked directories' , function ( done ) {
755+ var expected = [
756+ {
757+ cwd : dir ,
758+ base : dir + '/fixtures/symlinks' ,
759+ path : dir + '/fixtures/symlinks/file-a.txt' ,
760+ } ,
761+ {
762+ cwd : dir ,
763+ base : dir + '/fixtures/symlinks' ,
764+ path :
765+ dir +
766+ '/fixtures/symlinks/symlink-dest/hey/isaidhey/whatsgoingon/test.txt' ,
767+ } ,
768+ ] ;
769+
770+ function assert ( pathObjs ) {
771+ expect ( pathObjs . length ) . toBe ( 2 ) ;
772+ expect ( pathObjs ) . toContainEqual ( expected [ 0 ] ) ;
773+ expect ( pathObjs ) . toContainEqual ( expected [ 1 ] ) ;
774+ }
775+
776+ stream . pipeline (
777+ [
778+ globStream ( [ './fixtures/symlinks/**/*.txt' ] , { cwd : dir } ) ,
779+ concat ( assert ) ,
780+ ] ,
781+ done
782+ ) ;
783+ } ) ;
739784 } ) ;
740785
741786 describe ( 'options' , function ( ) {
@@ -1039,6 +1084,28 @@ function suite(moduleName) {
10391084 stream . pipeline ( [ gs , concat ( ) ] , assert ) ;
10401085 } ) ;
10411086
1087+ it ( 'destroys the stream if walker errors when following symlink' , function ( done ) {
1088+ var expectedError = new Error ( 'Stubbed error' ) ;
1089+
1090+ var gs = globStream ( './fixtures/**/*.dmc' , { cwd : dir } ) ;
1091+
1092+ function stubError ( dirpath , cb ) {
1093+ cb ( expectedError ) ;
1094+ }
1095+
1096+ var spy = sinon . spy ( gs , 'destroy' ) ;
1097+ sinon . stub ( fs , 'stat' ) . callsFake ( stubError ) ;
1098+
1099+ function assert ( err ) {
1100+ sinon . restore ( ) ;
1101+ expect ( spy . called ) . toEqual ( true ) ;
1102+ expect ( err ) . toBe ( expectedError ) ;
1103+ done ( ) ;
1104+ }
1105+
1106+ stream . pipeline ( [ gs , concat ( ) ] , assert ) ;
1107+ } ) ;
1108+
10421109 it ( 'does not emit an error if stream is destroyed without an error' , function ( done ) {
10431110 var gs = globStream ( './fixtures/**/*.dmc' , { cwd : dir } ) ;
10441111
0 commit comments