bin/sel2wiki

filter: Statementstmt 94.1% 32 / 34 Branchbran 88.8% 16 / 18 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 84.6% 55 / 65 CC 7 SCAR 18.1
CC
7
Cov
88%
parse_row
7.5
BEGIN
1.0
BEGIN
1.0
CRAP 6.1
« lib/WWW/Selenium/Utils.pm ↑ Summary blib/lib/WWW/Selenium/Utils/PostResults.pm »
1 #!/usr/bin/perl
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 my $title;
6 my @rows;
7 3 ▶while (<>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline ARGV)) 27 3 30
8 27 ▶ if (m#<title>([^<]+)</title>#) {
Branch: 1 branch
BranchTrueFalseTotal
if (m[<title>([^<]+)</title>]) 2 25 27
9 2 $title = $1;
10 2 next;
11 }
12 25 ▶ if (m#^<tr>#) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^<tr>/) 8 17 25
13 8 push @rows, grep {defined} parse_row();
14 8 next;
15 }
16 }
17  
18 3 ▶unless ($title and @rows) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($title and @rows) 1 2 3
Condition66%2/3
$title and @rows
!ll&&!rl&&r
102
MC/DC50%1/2
$title and @rows
$title @rows
Truth table66%2/3
A and B
A= $titleB= @rows
ABresult
0X0
100
111
19 1 print STDERR <<EOUSAGE;
20 USAGE: $0 [source html]
21  
22 $0 will read the given file, or STDIN for selenium HTML,
23 as generated by Selenium Recorder.
24  
25 The output will be selenium wiki syntax, compatible with
26 selenium-regen.
27  
28 Example:
29  
30 $0 foo.html > foo.wiki
31  
32 EOUSAGE
33 }
34  
35 3 print "| $title |\n";
36 3 foreach my $r (@rows) {
37 8 print "| ", join(' | ', @$r), " |\n";
38 }
39  
40 8 ▶sub parse_row {
Subroutine parse_row: called CC=7 SCAR=20.2
41 8 my ($cmd, @opts);
42 8 my $row = '';
43 8 ▶ while (<>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline ARGV)) 36 0 36
44 36 $row .= $_;
45 36 ▶ last if m#^</tr>#;
Branch: 1 branch
BranchTrueFalseTotal
if m[^</tr>] 8 28 36
46 28 ▶ if (m#\s*<td>([^<]+)</td>#) {
Branch: 1 branch
BranchTrueFalseTotal
if (m[\s*<td>([^<]+)</td>]) 18 10 28
47 18 ▶ if (defined $cmd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cmd) { } 10 8 18
48 10 push @opts, $1;
49 }
50 else {
51 8 $cmd = $1;
52 }
53 18 next;
54 }
55 }
56 8 ▶ unless (defined $cmd and @opts) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $cmd and @opts) 0 8 8
Condition33%1/3
defined $cmd and @opts
!ll&&!rl&&r
008
MC/DC0%0/2
defined $cmd and @opts
defined $cmd @opts
Truth table33%1/3
A and B
A= defined $cmdB= @opts
ABresult
0X0
100
111
57 0 warn "Could not parse row: $row\n";
58 0 return;
59 }
60 8 return [ $cmd, @opts ];
61 }
« lib/WWW/Selenium/Utils.pm ↑ Summary blib/lib/WWW/Selenium/Utils/PostResults.pm »