Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use mkfifo, not bash

  • Loading branch information...
commit 437f6c1dfa84973e2c6971adb1da170439834c24 1 parent 059e4ea
@petdance authored
Showing with 24 additions and 8 deletions.
  1. +3 −0  Changes
  2. +21 −8 t/process-substitution.t
View
3  Changes
@@ -7,6 +7,9 @@ problems at http://github.com/petdance/file-next/issues.
[FIXES]
from_file() should return undef if the file can't be opened.
+ Trying to make the named pipe test more portable by not requiring
+ bash.
+
1.09_01 Sat Jun 9 22:57:33 CDT 2012
No new features. This only fixes test failures on some platforms.
View
29 t/process-substitution.t
@@ -5,20 +5,33 @@ use warnings;
use Test::More;
-system 'bash', '-c', 'exit';
+plan skip_all => q{Windows doesn't have named pipes} if $^O =~ /MSWin32/;
+plan tests => 4;
-if ( $? ) {
- plan skip_all => 'You need bash to run this test';
-}
+use POSIX ();
-my $perl = $^X;
+my $pipename = POSIX::tmpnam();
+POSIX::mkfifo $pipename, 0666;
-plan tests => 4;
+my $pid = fork();
+if ( $pid == 0 ) {
+ open my $fifo, '>', $pipename or die "Couldn't create named pipe $pipename: $!";
+ open my $f, '<', 'Changes' or die "Couldn't open Changes: $!";
+ while (my $line = <$f>) {
+ print {$fifo} $line;
+ }
+ close $fifo;
+ close $f;
+ exit 0;
+}
+
+my @output = qx{$^X -Mblib t/first-and-last-lines-via-process-pipe.pl $pipename};
+is( $?, 0, 'No errors in executing our little named pipe tester' );
+unlink $pipename;
-my @output = qx{bash -c "$perl -Mblib t/first-and-last-lines-via-process-pipe.pl <(cat Changes)"};
chomp @output;
is( scalar @output, 2, 'Get exactly 2 lines back' );
is( $output[0], 'Revision history for File-Next' );
is( $output[-1], ' First version, released on an unsuspecting world.' );
-is( $?, 0, 'passing a named pipe created by a bash process substitution should yield that filename' );
+
done_testing();
Please sign in to comment.
Something went wrong with that request. Please try again.