1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
use strict;
use warnings;
use Dist::Zilla 1.093250;
use Test::DZil;
use Path::Tiny 0.012 qw( path );
use Test::More tests => 6;
use lib 't/lib';
use Util;
# Mock HOME to avoid ~/.gitexcludes from causing problems
my $homedir = clean_environment;
my $cwd = Path::Tiny->cwd();
for my $test (
{
name => 'default',
config => simple_ini('Git::GatherDir'),
files => [ qw(lib/DZT/Sample.pm share/tracked tracked) ],
},
{
name => 'include_dotfiles',
config => simple_ini([ 'Git::GatherDir', { include_dotfiles => 1 } ]),
files => [ qw(.gitignore .tracked lib/DZT/Sample.pm share/tracked tracked) ],
},
{
name => 'include_untracked',
min_git=> '1.5.4',
config => simple_ini([ 'Git::GatherDir', { include_untracked => 1 } ]),
files => [ qw(dist.ini lib/DZT/Sample.pm share/tracked tracked untracked) ],
},
{
name => 'include both',
min_git=> '1.6.5.2',
config => simple_ini([ 'Git::GatherDir',
{ include_dotfiles => 1, include_untracked => 1 } ]),
files => [ qw(.gitignore .tracked .untracked dist.ini lib/DZT/Sample.pm
share/tracked tracked untracked) ],
},
{
name => 'exclude_filename',
config => simple_ini([ 'Git::GatherDir', { exclude_filename => 'tracked' } ]),
files => [ qw(lib/DZT/Sample.pm share/tracked) ],
},
{
name => 'prune_directory',
config => simple_ini([ 'Git::GatherDir', { prune_directory => '^share$' } ]),
files => [ qw(lib/DZT/Sample.pm tracked) ],
},
) {
SKIP: {
skip_unless_git_version($test->{min_git}, 1) if $test->{min_git};
my $tzil = Builder->from_config(
{ dist_root => $cwd->child('corpus/gatherdir')->absolute },
{
add_files => {
'source/ignored' => "This is ignored.\n",
'source/untracked' => "This is not tracked.\n",
'source/tracked' => "This is tracked.\n",
'source/share/tracked' => "This is tracked, in a subdir.\n",
'source/.tracked' => "This is a tracked dotfile.\n",
'source/.ignored' => "This is an ignored dotfile.\n",
'source/.untracked' => "This is an untracked dotfile.\n",
'source/.gitignore' => "*ignore*\n",
'source/dist.ini' => $test->{config},
},
},
);
my $git = init_repo( path($tzil->tempdir)->child('source')->stringify,
qw(lib share tracked .tracked .gitignore) );
$tzil->build;
is_deeply(
[ sort map {; $_->name } @{ $tzil->files } ],
$test->{files},
"the right files were gathered with $test->{name}",
);
} # end SKIP
} # end for my $test
|