#!/usr/local/bin/perl -w =head1 NAME addlabels.t - test VCP::Filter::addlabels =cut use strict ; use Carp ; use File::Spec ; use Test ; use VCP::TestUtils ; ## These next few are for in vitro testing use VCP::Debug qw( :debug ); use VCP::Filter::addlabels; use VCP::Rev; enable_debug( split /,/, $ENV{VCPDEBUG} ) if defined $ENV{VCPDEBUG} ; my @vcp = vcp_cmd ; sub r { my ( $name, $rev_id, $change_id, $branch_id ) = split ",", $_[0]; VCP::Rev->new( id => $_[0], name => $name, rev_id => $rev_id, change_id => $change_id, branch_id => $branch_id, ); } my $sub; my $r_out; # HACK so V:F:a calls main::handle_rev() sub VCP::Filter::addlabels::dest { return "main"; } sub handle_rev { my $self = shift; my ( $rev ) = @_; $r_out = join ",", $rev->labels; } sub t { return skip "compilation failed", 1 unless $sub; my ( $expr, $expected ) = @_; $r_out = undef; $sub->( "VCP::Filter::addlabels", r $expr ); @_ = ( $r_out, $expected ); goto &ok; } my @tests = ( ## In vitro tests sub { $sub = VCP::Filter::addlabels->_compile_label_add_routine( 'rev_$rev_id', 'change_$change_id', 'branch_$branch_id' ); ok defined $sub || $@, 1; }, sub { t "a,r,c,b", "branch_b,change_c,rev_r" }, sub { t "a,r,c", "change_c,rev_r" }, ### In vivo tests sub { eval { my $out ; my $infile = "t/test-revml-in-0-no-big-files.revml"; ## $in and $out allow us to avoide execing diff most of the time. run [ @vcp, "vcp:-" ], \<<'END_VCP', \$out; Source: t/test-revml-in-0-no-big-files.revml Sort: Destination: - AddLabels: END_VCP my $in = slurp $infile; assert_eq $infile, $in, $out ; } ; ok $@ || '', '', 'diff' ; }, sub { my $out ; my $infile = "t/test-revml-in-0-no-big-files.revml"; ## $in and $out allow us to avoide execing diff most of the time. run [ @vcp, "vcp:-" ], \<<'END_VCP', \$out; Source: t/test-revml-in-0-no-big-files.revml Sort: Destination: - AddLabels: rev_$rev_id change_$change_id branch_$branch_id END_VCP my $r_count = () = $out =~ m{<label>rev_}g; my $c_count = () = $out =~ m{<label>change_}g; my $b_count = () = $out =~ m{<label>branch_}g; my $in = slurp $infile; rm_elts branch => \$in; ## Ignore <branch_id> tags in <branch> my $rev_id_count = () = $in =~ m{<rev_id}g; my $change_id_count = () = $in =~ m{<change_id}g; my $branch_id_count = () = $in =~ m{<branch_id}g; ok "$r_count,$c_count,$b_count", "$rev_id_count,$change_id_count,$branch_id_count"; }, ) ; plan tests => scalar( @tests ) ; $_->() for @tests ;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#8 | 3970 | Barrie Slaymaker |
- VCP::Source handles rev queing, uses disk to reduce RAM - Lots of other fixes |
||
#7 | 3800 | Barrie Slaymaker | - <branches> removed from all code | ||
#6 | 3467 | Barrie Slaymaker |
- Config file tokens are now quoted using (the new) VCP::ConfigFileUtils::config_file_quote(), which only quotes if whitespace is detected (for now). - t/61addlabels.t now tests config file section building a bit. |
||
#5 | 3155 | Barrie Slaymaker |
Convert to logging using VCP::Logger to reduce stdout/err spew. Simplify & speed up debugging quite a bit. Provide more verbose information in logs. Print to STDERR progress reports to keep users from wondering what's going on. Breaks test; halfway through upgrading run3() to an inline function for speed and for VCP specific features. |
||
#4 | 3115 | Barrie Slaymaker |
Move sorting function to the new VCP::Filter::sort; it's for testing and reporting only and the code was bloating VCP::Dest and limiting VCP::Rev and VCP::Dest optimizations. Breaks test suite in minor way. |
||
#3 | 3017 | Barrie Slaymaker | Fix second instance of perl not ARRAY reference in cleanup. | ||
#2 | 2697 | Barrie Slaymaker | Add in vivo tests for VCP::Filter::AddLabel | ||
#1 | 2695 | Barrie Slaymaker |
Prepare to make r_... and ch_... labels optional and configurable by demoting them from VCP::Dest::* to tha single, not selected-by-default VCP::Filter::addlabels. This is to increase performance |