| 1 | package Test::Analizo; | ||||||||||
| 2 | 21 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 21 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 21 | ▶ | use parent qw( Exporter ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 21 | our @EXPORT = qw( | |||||||||
| 7 | on_dir | ||||||||||
| 8 | on_tmpdir | ||||||||||
| 9 | mock | ||||||||||
| 10 | tmpdir | ||||||||||
| 11 | unpack_sample_git_repository | ||||||||||
| 12 | readfile | ||||||||||
| 13 | ); | ||||||||||
| 14 | |||||||||||
| 15 | 21 | ▶ | use Test::MockObject::Extends; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 21 | ▶ | use File::Path qw(remove_tree); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 17 | ▶ | sub on_dir { | ||||||||
|
Subroutine
on_dir: called CC=2 SCAR=7.5
Pod
undocumented
| |||||||||||
| 19 | 17 | my ($dir, $code) = @_; | |||||||||
| 20 | 17 | my $previous_pwd = `pwd`; | |||||||||
| 21 | 17 | chomp $previous_pwd; | |||||||||
| 22 | 17 | chdir $dir; | |||||||||
| 23 | 17 | ▶ | if (wantarray()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | my @list = &$code(); | |||||||||
| 25 | 0 | chdir $previous_pwd; | |||||||||
| 26 | 0 | return @list; | |||||||||
| 27 | } | ||||||||||
| 28 | 17 | my $result = &$code(); | |||||||||
| 29 | 16 | chdir $previous_pwd; | |||||||||
| 30 | 16 | return $result; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 13 | ▶ | sub mock { | ||||||||
|
Subroutine
mock: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 34 | 13 | my ($object) = @_; | |||||||||
| 35 | 13 | Test::MockObject::Extends->new($object); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 7 | ▶ | sub tmpdir { | ||||||||
|
Subroutine
tmpdir: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 39 | 7 | my ($package, $filename, $line) = caller; | |||||||||
| 40 | 7 | return tmpdir_for($filename); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 21 | ▶ | use Cwd 'abs_path'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 44 | 9 | ▶ | sub tmpdir_for { | ||||||||
|
Subroutine
tmpdir_for: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 45 | 9 | my ($filename) = @_; | |||||||||
| 46 | 9 | $filename = abs_path($filename); | |||||||||
| 47 | 9 | return $filename . '.tmpdir'; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 3 | ▶ | sub on_tmpdir { | ||||||||
|
Subroutine
on_tmpdir: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 51 | 3 | my ($code) = @_; | |||||||||
| 52 | 3 | my $tmpdir = tmpdir; | |||||||||
| 53 | 3 | mkdir $tmpdir; | |||||||||
| 54 | 3 | my $result = on_dir($tmpdir, $code); | |||||||||
| 55 | 3 | remove_tree $tmpdir; | |||||||||
| 56 | 3 | return $result; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | 2 | ▶ | sub unpack_sample_git_repository { | ||||||||
|
Subroutine
unpack_sample_git_repository: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 60 | 2 | my ($code, @repos) = @_; | |||||||||
| 61 | 2 | ▶ | if (!@repos) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 1 | @repos = ('evolution'); | |||||||||
| 63 | } | ||||||||||
| 64 | 2 | my ($package, $filename, $line) = caller; | |||||||||
| 65 | 2 | my $tmpdir = tmpdir_for($filename); | |||||||||
| 66 | 2 | system('mkdir', '-p', $tmpdir); | |||||||||
| 67 | 2 | for my $repo (@repos) { | |||||||||
| 68 | 3 | system('tar', 'xzf', "t/samples/$repo.tar.gz", '-C', $tmpdir, | |||||||||
| 69 | '--no-same-owner'); | ||||||||||
| 70 | } | ||||||||||
| 71 | 2 | &$code(); | |||||||||
| 72 | 2 | system('rm', '-rf', $tmpdir); | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | 0 | ▶ | sub readfile { | ||||||||
|
Subroutine
readfile: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 76 | 0 | my ($filename) = @_; | |||||||||
| 77 | 0 | open INPUT, $filename; | |||||||||
| 78 | 0 | my @lines = <INPUT>; | |||||||||
| 79 | 0 | close INPUT; | |||||||||
| 80 | 0 | chomp @lines; | |||||||||
| 81 | 0 | return @lines; | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 21 | 1; | |||||||||