@@ -616,18 +616,20 @@ def withenv_utf8(&block)
616
616
fds . each do |fd |
617
617
if fd == '.' || fd == '..'
618
618
next
619
- elsif [ '0' , '1' , '2' ] . include? fd
619
+ elsif [ '0' , '1' , '2' , '5' ] . include? fd
620
620
expect ( IO ) . not_to receive ( :new ) . with ( fd . to_i )
621
621
else
622
622
expect ( IO ) . to receive ( :new ) . with ( fd . to_i ) . and_return ( double ( 'io' , close : nil ) )
623
623
end
624
624
end
625
625
626
- dir_expectation = receive ( :foreach ) . with ( '/proc/self/fd' )
626
+ dir = double ( Dir , fileno : '5' )
627
+ dir_expectation = receive ( :each_child )
627
628
fds . each do |fd |
628
629
dir_expectation = dir_expectation . and_yield ( fd )
629
630
end
630
- allow ( Dir ) . to dir_expectation
631
+ allow ( dir ) . to dir_expectation
632
+ allow ( Dir ) . to receive ( :new ) . with ( '/proc/self/fd' ) . and_return ( dir )
631
633
Puppet ::Util . safe_posix_fork
632
634
end
633
635
@@ -636,7 +638,7 @@ def withenv_utf8(&block)
636
638
# letting it actually close fds, which seems risky
637
639
( 0 ..2 ) . each { |n | expect ( IO ) . not_to receive ( :new ) . with ( n ) }
638
640
( 3 ..256 ) . each { |n | expect ( IO ) . to receive ( :new ) . with ( n ) . and_return ( double ( 'io' , close : nil ) ) }
639
- allow ( Dir ) . to receive ( :foreach ) . with ( '/proc/self/fd' ) . and_raise ( Errno ::ENOENT )
641
+ allow ( Dir ) . to receive ( :new ) . with ( '/proc/self/fd' ) . and_raise ( Errno ::ENOENT )
640
642
641
643
Puppet ::Util . safe_posix_fork
642
644
end
@@ -646,7 +648,7 @@ def withenv_utf8(&block)
646
648
# letting it actually close fds, which seems risky
647
649
( 0 ..2 ) . each { |n | expect ( IO ) . not_to receive ( :new ) . with ( n ) }
648
650
( 3 ..256 ) . each { |n | expect ( IO ) . to receive ( :new ) . with ( n ) . and_return ( double ( 'io' , close : nil ) ) }
649
- allow ( Dir ) . to receive ( :foreach ) . with ( '/proc/self/fd' ) . and_raise ( Errno ::ENOTDIR )
651
+ allow ( Dir ) . to receive ( :new ) . with ( '/proc/self/fd' ) . and_raise ( Errno ::ENOTDIR )
650
652
651
653
Puppet ::Util . safe_posix_fork
652
654
end
0 commit comments