| 1 | package Module::Setup::Test::Utils; | ||||||||||
| 2 | 46 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 46 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 46 | ▶ | use File::Temp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 46 | ▶ | use Module::Setup; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | # chdir HOME to avoid "Cannot remove current directory" warning | ||||||||||
| 10 | 46 | ▶ | END{ chdir } | ||||||||
|
Subroutine
END: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 46 | my $stdout = []; | |||||||||
| 13 | 34 | ▶ | sub stdout { $stdout } | ||||||||
|
Subroutine
stdout: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | |||||||||||
| 15 | 47 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=3 SCAR=11.0
| |||||||||||
| 16 | 47 | my $class = shift; | |||||||||
| 17 | 47 | my $caller = caller; | |||||||||
| 18 | 47 | my %args = @_; | |||||||||
| 19 | |||||||||||
| 20 | 47 | for my $func (qw/ context module_setup stdout dialog default_dialog setup_dir target_dir clear_tempdir flavors_dir template_dir additional_dir additional_config_file plugins_dir config_file /) { | |||||||||
| 21 | 46 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 658 | *{"$caller\::$func"} = \&{ $func }; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 47 | strict->import; | |||||||||
| 26 | 47 | warnings->import; | |||||||||
| 27 | |||||||||||
| 28 | 47 | ▶ | unless ($args{without_stdout}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 46 | ▶ | no warnings 'redefine'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | 46 | ▶ | *Module::Setup::stdout = sub { push @{ $stdout }, $_[1] }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 31 | } | ||||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 338 | ▶ | sub _path_dir (@) { | ||||||||
|
Subroutine
_path_dir: called CC=1 SCAR=0.0
| |||||||||||
| 35 | 338 | Module::Setup::Path::Dir->new(@_); | |||||||||
| 36 | } | ||||||||||
| 37 | 46 | my $setup_dir; | |||||||||
| 38 | 188 | ▶ | sub setup_dir (@) { | ||||||||
|
Subroutine
setup_dir: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 39 | 188 | ▶ | $setup_dir = File::Temp->newdir unless $setup_dir; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 188 | _path_dir($setup_dir, @_); | |||||||||
| 41 | } | ||||||||||
| 42 | 71 | ▶ | sub flavors_dir { | ||||||||
|
Subroutine
flavors_dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 43 | 71 | setup_dir('flavors', @_); | |||||||||
| 44 | } | ||||||||||
| 45 | 11 | ▶ | sub template_dir { | ||||||||
|
Subroutine
template_dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 46 | 11 | my $flavor = shift; | |||||||||
| 47 | 11 | flavors_dir($flavor, 'template', @_); | |||||||||
| 48 | } | ||||||||||
| 49 | 42 | ▶ | sub additional_dir { | ||||||||
|
Subroutine
additional_dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 50 | 42 | my $flavor = shift; | |||||||||
| 51 | 42 | flavors_dir($flavor, 'additional', @_); | |||||||||
| 52 | } | ||||||||||
| 53 | 15 | ▶ | sub additional_config_file { | ||||||||
|
Subroutine
additional_config_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 54 | 15 | my $flavor = shift; | |||||||||
| 55 | 15 | additional_dir($flavor)->file('config.yaml'); | |||||||||
| 56 | } | ||||||||||
| 57 | 5 | ▶ | sub plugins_dir { | ||||||||
|
Subroutine
plugins_dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 58 | 5 | my $flavor = shift; | |||||||||
| 59 | 5 | flavors_dir($flavor, 'plugins', @_); | |||||||||
| 60 | } | ||||||||||
| 61 | 9 | ▶ | sub config_file { | ||||||||
|
Subroutine
config_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 62 | 9 | my $flavor = shift; | |||||||||
| 63 | 9 | flavors_dir($flavor)->file('config.yaml'); | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | my $target_dir; | ||||||||||
| 67 | 150 | ▶ | sub target_dir (@) { | ||||||||
|
Subroutine
target_dir: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 68 | 150 | ▶ | $target_dir = File::Temp->newdir unless $target_dir; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | 150 | _path_dir($target_dir, @_); | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 16 | ▶ | sub clear_tempdir { | ||||||||
|
Subroutine
clear_tempdir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 73 | 16 | $setup_dir = undef; | |||||||||
| 74 | 16 | $target_dir = undef; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 46 | my $context; | |||||||||
| 78 | 19 | ▶ | sub context { $context } | ||||||||
|
Subroutine
context: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 79 | 95 | ▶ | sub module_setup ($@) { | ||||||||
|
Subroutine
module_setup: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 80 | 95 | $stdout = []; | |||||||||
| 81 | 95 | my($options, @argv) = @_; | |||||||||
| 82 | 95 | ▶ | @argv = @{ $argv[0] } if ref $argv[0] eq 'ARRAY'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 83 | |||||||||||
| 84 | 95 | ▶ | $options->{module_setup_dir} = setup_dir unless $options->{module_setup_dir}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | 95 | ▶ | if ($options->{target}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 86 | 53 | $options->{target} = target_dir; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 95 | $context = Module::Setup->new( | |||||||||
| 90 | options => $options, | ||||||||||
| 91 | argv => \@argv, | ||||||||||
| 92 | ); | ||||||||||
| 93 | 95 | $context->run; | |||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | 35 | ▶ | sub dialog (;&) { | ||||||||
|
Subroutine
dialog: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 97 | 35 | my $code = shift; | |||||||||
| 98 | 46 | ▶ | no warnings 'redefine'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 99 | 35 | *Module::Setup::dialog = $code; | |||||||||
| 100 | } | ||||||||||
| 101 | |||||||||||
| 102 | 16 | ▶ | sub default_dialog { | ||||||||
|
Subroutine
default_dialog: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 103 | 139 | ▶ | dialog { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||
| 104 | 139 | my($self, $msg, $default) = @_; | |||||||||
| 105 | 139 | ▶ | return 'n' if $msg =~ /Check Makefile.PL\?/i; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 106 | 120 | ▶ | return 'n' if $msg =~ /Subversion friendly\?/i; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 107 | 119 | return $default; | |||||||||
| 108 | 16 | }; | |||||||||
| 109 | } | ||||||||||
| 110 | |||||||||||
| 111 | 46 | 1; | |||||||||
| 112 | |||||||||||
| 113 | =head1 NAME | ||||||||||
| 114 | |||||||||||
| 115 | Module::Setup::Test::Utils - Test utils | ||||||||||
| 116 | |||||||||||
| 117 | =head1 METHODS | ||||||||||
| 118 | |||||||||||
| 119 | =head2 module_setup | ||||||||||
| 120 | |||||||||||
| 121 | =head2 context | ||||||||||
| 122 | |||||||||||
| 123 | =head2 stdout | ||||||||||
| 124 | |||||||||||
| 125 | =head2 clear_tempdir | ||||||||||
| 126 | |||||||||||
| 127 | |||||||||||
| 128 | =head2 dialog | ||||||||||
| 129 | |||||||||||
| 130 | =head2 default_dialog | ||||||||||
| 131 | |||||||||||
| 132 | |||||||||||
| 133 | =head2 target_dir | ||||||||||
| 134 | |||||||||||
| 135 | =head2 setup_dir | ||||||||||
| 136 | |||||||||||
| 137 | =head2 flavors_dir | ||||||||||
| 138 | |||||||||||
| 139 | =head2 template_dir | ||||||||||
| 140 | |||||||||||
| 141 | =head2 plugins_dir | ||||||||||
| 142 | |||||||||||
| 143 | =head2 config_file | ||||||||||
| 144 | |||||||||||
| 145 | =head2 additional_dir | ||||||||||
| 146 | |||||||||||
| 147 | =head2 additional_config_file | ||||||||||
| 148 | |||||||||||
| 149 | =cut | ||||||||||