line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::Mutator::Command::Mutate; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
64395
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
49
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use File::Find (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
7
|
1
|
|
|
1
|
|
897
|
use File::Slurp (); |
|
1
|
|
|
|
|
17336
|
|
|
1
|
|
|
|
|
41
|
|
8
|
1
|
|
|
1
|
|
12
|
use File::Path (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
9
|
1
|
|
|
1
|
|
6
|
use File::Basename (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
10
|
1
|
|
|
1
|
|
7
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
11
|
1
|
|
|
1
|
|
681
|
use Devel::Mutator::Generator; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
473
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
2
|
|
|
2
|
1
|
5431
|
my $class = shift; |
15
|
2
|
|
|
|
|
8
|
my (%params) = @_; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
4
|
my $self = {}; |
18
|
2
|
|
|
|
|
6
|
bless $self, $class; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
100
|
|
|
16
|
$self->{recursive} = $params{recursive} || 0; |
21
|
2
|
|
50
|
|
|
12
|
$self->{verbose} = $params{verbose} || 0; |
22
|
2
|
|
50
|
|
|
9
|
$self->{root} = $params{root} || '.'; |
23
|
2
|
|
33
|
|
|
40
|
$self->{generator} = $params{generator} || Devel::Mutator::Generator->new; |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
|
|
5
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub run { |
29
|
2
|
|
|
2
|
1
|
12
|
my $self = shift; |
30
|
2
|
|
|
|
|
5
|
my (@files) = @_; |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
3
|
my $mutated = 0; |
33
|
2
|
|
|
|
|
2
|
my $mutants = 0; |
34
|
2
|
|
|
|
|
6
|
foreach my $file (@files) { |
35
|
2
|
100
|
66
|
|
|
31
|
if (-d $file && $self->{recursive}) { |
|
|
50
|
|
|
|
|
|
36
|
1
|
|
|
|
|
22
|
my @subfiles; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
File::Find::find( |
39
|
2
|
100
|
|
2
|
|
144
|
sub { push @subfiles, $File::Find::name if /\.p(?:m|l)$/; }, |
40
|
1
|
|
|
|
|
41
|
$file); |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
5
|
foreach my $subfile (@subfiles) { |
43
|
1
|
|
|
|
|
4
|
$mutants += $self->_mutate_file($subfile); |
44
|
1
|
|
|
|
|
4
|
$mutated++; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
elsif (-f $file) { |
48
|
1
|
|
|
|
|
5
|
$mutants += $self->_mutate_file($file); |
49
|
1
|
|
|
|
|
2
|
$mutated++; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
71
|
print "Mutated files: $mutated, mutants: $mutants\n"; |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
12
|
return $self; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _mutate_file { |
59
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
60
|
2
|
|
|
|
|
19
|
my ($file) = @_; |
61
|
|
|
|
|
|
|
|
62
|
2
|
50
|
|
|
|
6
|
print "Reading $file ... \n" if $self->{verbose}; |
63
|
2
|
|
|
|
|
10
|
my $content = File::Slurp::read_file($file); |
64
|
|
|
|
|
|
|
|
65
|
2
|
50
|
|
|
|
124
|
print "Generating mutants ... " if $self->{verbose}; |
66
|
2
|
|
|
|
|
9
|
my @mutants = $self->{generator}->generate($content); |
67
|
|
|
|
|
|
|
|
68
|
2
|
50
|
|
|
|
114
|
print scalar(@mutants), "\n" if $self->{verbose}; |
69
|
|
|
|
|
|
|
|
70
|
2
|
50
|
|
|
|
5
|
print "Saving mutants ... " if $self->{verbose}; |
71
|
2
|
|
|
|
|
4
|
foreach my $mutant (@mutants) { |
72
|
2
|
|
|
|
|
28
|
my $new_path = |
73
|
|
|
|
|
|
|
File::Spec->catfile($self->{root}, 'mutants', $mutant->{id}, $file); |
74
|
|
|
|
|
|
|
|
75
|
2
|
|
|
|
|
854
|
File::Path::make_path(File::Basename::dirname($new_path)); |
76
|
|
|
|
|
|
|
|
77
|
2
|
|
|
|
|
14
|
File::Slurp::write_file($new_path, $mutant->{content}); |
78
|
|
|
|
|
|
|
} |
79
|
2
|
50
|
|
|
|
345
|
print "ok\n" if $self->{verbose}; |
80
|
|
|
|
|
|
|
|
81
|
2
|
|
|
|
|
6
|
return scalar @mutants; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
__END__ |