1use 5.10.0; 2use warnings; 3use strict; 4use Test::More; 5use FindBin qw( $RealBin ); 6use File::Spec::Functions qw( catfile ); 7 8BEGIN { 9 if ( $^O eq 'MSWin32' ) { 10 plan skip_all => "MSWin32: Expect not available."; 11 } 12 #if ( ! $ENV{TESTS_USING_EXPECT_OK} ) { 13 # plan skip_all => "Environment variable 'TESTS_USING_EXPECT_OK' not enabled."; 14 #} 15} 16 17eval "use Expect"; 18if ( $@ ) { 19 plan skip_all => $@; 20} 21 22my $exp; 23eval { 24 $exp = Expect->new(); 25 $exp->raw_pty( 1 ); 26 $exp->log_stdout( 0 ); 27 $exp->slave->set_winsize( 24, 80, undef, undef ); 28 29 my $command = $^X; 30 my $script = catfile $RealBin, 'Y_choose_function_arguments.pl'; 31 my @parameters = ( $script ); 32 33 -r $script or die "$script is NOT readable"; 34 $exp->spawn( $command, @parameters ) or die "Spawn '$command @parameters' NOT ok $!"; 35 1; 36} 37or plan skip_all => $@; 38 39 40my $expected = '<End_fc_va>'; 41my $ret = $exp->expect( 2, [ qr/(?:<End|choose).+/ ] ); 42 43ok( $ret, 'matched something' ); 44my $result = $exp->match(); 45$result = '' if ! defined $result; 46ok( $result =~ $expected, "expected: '$expected', got: '$result'" ); 47 48$exp->hard_close(); 49 50done_testing(); 51