App-Sqitch
view release on metacpan or search on metacpan
. __('Name: ') . " lolz\n"
. __('Project: ') . " logit\n"
. __('Planner: ') . " damian <damian\@example.com>\n"
. __('Committer:') . " larry <larry\@example.com>\n\n"
. " For the LOLZ.\n \n You know, funny stuff and cute kittens, right?\n"
],
[ medium => __('Deploy') . " 000011112222333444\n"
. __('Name: ') . " lolz\n"
. __('Committer:') . " larry <larry\@example.com>\n"
. __('Date: ') . " __CDATE__\n\n"
. " For the LOLZ.\n \n You know, funny stuff and cute kittens, right?\n"
],
[ short => __('Deploy') . " 000011112222333444\n"
. __('Name: ') . " lolz\n"
. __('Committer:') . " larry <larry\@example.com>\n\n"
. " For the LOLZ.\n",
],
[ oneline => '000011112222333444 ' . __('deploy') . ' logit:lolz For the LOLZ.' ],
) {
local $ENV{ANSI_COLORS_DISABLED} = 1;
my $configured = $CLASS->configure( $config, { format => $spec->[0] } );
my $format = $configured->{format};
ok my $log = $CLASS->new( sqitch => $sqitch, %{ $configured } ),
qq{Instantiate with format "$spec->[0]"};
(my $exp = $spec->[1]) =~ s/__CDATE__/$ciso/;
$exp =~ s/__PDATE__/$piso/;
is $log->formatter->format( $log->format, $event ), $exp,
qq{Format "$spec->[0]" should output correctly};
if ($spec->[1] =~ /__CDATE__/) {
# Test different date formats.
for my $date_format (qw(rfc long medium)) {
ok my $log = $CLASS->new(
sqitch => $sqitch,
format => $format,
formatter => App::Sqitch::ItemFormatter->new(date_format => $date_format),
), qq{Instantiate with format "$spec->[0]" and date format "$date_format"};
my $date = $cdt->as_string( format => $date_format );
(my $exp = $spec->[1]) =~ s/__CDATE__/$date/;
$date = $pdt->as_string( format => $date_format );
$exp =~ s/__PDATE__/$date/;
is $log->formatter->format( $log->format, $event ), $exp,
qq{Format "$spec->[0]" and date format "$date_format" should output correctly};
}
}
if ($spec->[1] =~ s/\s+[(]?[@]beta,\s+[@]gamma[)]?//) {
# Test without tags.
local $event->{tags} = [];
(my $exp = $spec->[1]) =~ s/__CDATE__/$ciso/;
$exp =~ s/__PDATE__/$piso/;
is $log->formatter->format( $log->format, $event ), $exp,
qq{Format "$spec->[0]" should output correctly without tags};
}
}
###############################################################################
# Test all formatting characters.
my $local_cdt = $cdt->clone;
$local_cdt->set_time_zone('local');
$local_cdt->set_locale($LC::TIME);
my $local_pdt = $pdt->clone;
$local_pdt->set_time_zone('local');
$local_pdt->set_locale($LC::TIME);
my $formatter = $log->formatter;
for my $spec (
['%e', { event => 'deploy' }, 'deploy' ],
['%e', { event => 'revert' }, 'revert' ],
['%e', { event => 'fail' }, 'fail' ],
['%L', { event => 'deploy' }, __ 'Deploy' ],
['%L', { event => 'revert' }, __ 'Revert' ],
['%L', { event => 'fail' }, __ 'Fail' ],
['%l', { event => 'deploy' }, __ 'deploy' ],
['%l', { event => 'revert' }, __ 'revert' ],
['%l', { event => 'fail' }, __ 'fail' ],
['%{event}_', {}, __ 'Event: ' ],
['%{change}_', {}, __ 'Change: ' ],
['%{committer}_', {}, __ 'Committer:' ],
['%{planner}_', {}, __ 'Planner: ' ],
['%{by}_', {}, __ 'By: ' ],
['%{date}_', {}, __ 'Date: ' ],
['%{committed}_', {}, __ 'Committed:' ],
['%{planned}_', {}, __ 'Planned: ' ],
['%{name}_', {}, __ 'Name: ' ],
['%{email}_', {}, __ 'Email: ' ],
['%{requires}_', {}, __ 'Requires: ' ],
['%{conflicts}_', {}, __ 'Conflicts:' ],
['%H', { change_id => '123456789' }, '123456789' ],
['%h', { change_id => '123456789' }, '123456789' ],
['%{5}h', { change_id => '123456789' }, '12345' ],
['%{7}h', { change_id => '123456789' }, '1234567' ],
['%n', { change => 'foo' }, 'foo'],
['%n', { change => 'bar' }, 'bar'],
['%o', { project => 'foo' }, 'foo'],
['%o', { project => 'bar' }, 'bar'],
['%c', { committer_name => 'larry', committer_email => 'larry@example.com' }, 'larry <larry@example.com>'],
['%{n}c', { committer_name => 'damian' }, 'damian'],
['%{name}c', { committer_name => 'chip' }, 'chip'],
['%{e}c', { committer_email => 'larry@example.com' }, 'larry@example.com'],
['%{email}c', { committer_email => 'damian@example.com' }, 'damian@example.com'],
['%{date}c', { committed_at => $cdt }, $cdt->as_string( format => 'iso' ) ],
['%{date:rfc}c', { committed_at => $cdt }, $cdt->as_string( format => 'rfc' ) ],
['%{d:long}c', { committed_at => $cdt }, $cdt->as_string( format => 'long' ) ],
["%{d:cldr:HH'h' mm'm'}c", { committed_at => $cdt }, $local_cdt->format_cldr( q{HH'h' mm'm'} ) ],
["%{d:strftime:%a at %H:%M:%S}c", { committed_at => $cdt }, $local_cdt->strftime('%a at %H:%M:%S') ],
['%p', { planner_name => 'larry', planner_email => 'larry@example.com' }, 'larry <larry@example.com>'],
['%{n}p', { planner_name => 'damian' }, 'damian'],
['%{name}p', { planner_name => 'chip' }, 'chip'],
['%{e}p', { planner_email => 'larry@example.com' }, 'larry@example.com'],
['%{email}p', { planner_email => 'damian@example.com' }, 'damian@example.com'],
['%{date}p', { planned_at => $pdt }, $pdt->as_string( format => 'iso' ) ],
['%{date:rfc}p', { planned_at => $pdt }, $pdt->as_string( format => 'rfc' ) ],
['%{d:long}p', { planned_at => $pdt }, $pdt->as_string( format => 'long' ) ],
["%{d:cldr:HH'h' mm'm'}p", { planned_at => $pdt }, $local_pdt->format_cldr( q{HH'h' mm'm'} ) ],
( run in 0.804 second using v1.01-cache-2.11-cpan-5511b514fd6 )