line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Expect; |
2
|
1
|
|
|
1
|
|
1235
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
4
|
1
|
|
|
1
|
|
428
|
use Class::Accessor::Chained::Fast; |
|
1
|
|
|
|
|
3040
|
|
|
1
|
|
|
|
|
7
|
|
5
|
1
|
|
|
1
|
|
426
|
use Expect::Simple; |
|
1
|
|
|
|
|
53205
|
|
|
1
|
|
|
|
|
36
|
|
6
|
1
|
|
|
1
|
|
11
|
use Exporter; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
7
|
1
|
|
|
1
|
|
619
|
use Test::Builder; |
|
1
|
|
|
|
|
7772
|
|
|
1
|
|
|
|
|
31
|
|
8
|
1
|
|
|
1
|
|
6
|
use base qw(Class::Accessor::Chained::Fast Exporter); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
450
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(program)); |
10
|
|
|
|
|
|
|
our $VERSION = "0.32"; |
11
|
|
|
|
|
|
|
our @EXPORT = qw( |
12
|
|
|
|
|
|
|
expect_run |
13
|
|
|
|
|
|
|
expect_handle |
14
|
|
|
|
|
|
|
expect_is |
15
|
|
|
|
|
|
|
expect_like |
16
|
|
|
|
|
|
|
expect_send |
17
|
|
|
|
|
|
|
expect_quit |
18
|
|
|
|
|
|
|
expect |
19
|
|
|
|
|
|
|
END |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $Test = Test::Builder->new; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $expect; |
25
|
|
|
|
|
|
|
my $sent; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub import { |
28
|
1
|
|
|
1
|
|
4
|
my $self = shift; |
29
|
1
|
50
|
|
|
|
3
|
if (@_) { |
30
|
0
|
|
|
|
|
0
|
die @_; |
31
|
0
|
|
|
|
|
0
|
my $package = caller; |
32
|
0
|
|
|
|
|
0
|
$Test->exported_to($package); |
33
|
0
|
|
|
|
|
0
|
$Test->plan(@_); |
34
|
|
|
|
|
|
|
} |
35
|
1
|
|
|
|
|
3
|
$Test->no_ending(0); |
36
|
1
|
|
|
|
|
359
|
$self->export_to_level( 1, $self, $_ ) foreach @EXPORT; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub expect_run { |
40
|
2
|
|
|
2
|
1
|
1684
|
my (%conf) = @_; |
41
|
2
|
|
|
|
|
32
|
$expect = Expect::Simple->new( |
42
|
|
|
|
|
|
|
{ Cmd => "PERL_RL=\" o=0\" " . $conf{command}, |
43
|
|
|
|
|
|
|
Prompt => $conf{prompt}, |
44
|
|
|
|
|
|
|
DisconnectCmd => $conf{quit}, |
45
|
|
|
|
|
|
|
Verbose => 0, |
46
|
|
|
|
|
|
|
Debug => 0, |
47
|
|
|
|
|
|
|
Timeout => 100 |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
); |
50
|
2
|
50
|
|
|
|
19537
|
die $expect->error if $expect->error; |
51
|
2
|
|
|
|
|
1056
|
$Test->ok( 1, "expect_run" ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
2
|
1
|
1140
|
sub expect_handle { return $expect->expect_handle(); } |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub before { |
57
|
6
|
|
|
6
|
0
|
21
|
my $before = $expect->before; |
58
|
6
|
|
|
|
|
174
|
$before =~ s/\r//g; |
59
|
6
|
100
|
|
|
|
30
|
$before =~ s/^\Q$sent\E// if $sent; |
60
|
6
|
|
|
|
|
9
|
$before =~ s/^\n+//; |
61
|
6
|
|
|
|
|
17
|
$before =~ s/\n+$//; |
62
|
6
|
|
|
|
|
29
|
return $before; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub expect_like { |
66
|
2
|
|
|
2
|
1
|
638
|
my ( $like, $comment ) = @_; |
67
|
2
|
|
|
|
|
6
|
$Test->like( before(), $like, $comment ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub expect_is { |
71
|
4
|
|
|
4
|
1
|
708
|
my ( $is, $comment ) = @_; |
72
|
4
|
|
|
|
|
8
|
$Test->is_eq( before(), $is, $comment ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub expect_send { |
76
|
4
|
|
|
4
|
1
|
658
|
my ( $send, $comment ) = @_; |
77
|
4
|
|
|
|
|
17
|
$expect->send($send); |
78
|
4
|
|
|
|
|
1469
|
$sent = $send; |
79
|
4
|
|
|
|
|
14
|
$Test->ok( 1, $comment ); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub expect { |
83
|
2
|
|
|
2
|
1
|
449
|
my ( $send, $is, $label ) = @_; |
84
|
2
|
|
|
|
|
6
|
expect_send( $send, $label ); |
85
|
2
|
|
|
|
|
552
|
expect_is( $is, $label ); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub expect_quit { |
89
|
1
|
|
|
1
|
1
|
7
|
undef $expect; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub END { |
93
|
1
|
|
|
1
|
0
|
338
|
expect_quit; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |