#!/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 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->( 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 # #Destination: - --sort-by=name,rev_id # #Map: #END_VCP # # my $in = slurp $infile; # assert_eq $infile, $in, $out ; # } ; # ok $@ || '', '', 'diff' ; #}, # #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 # #Destination: - --sort-by=name,rev_id # #Map: # add/f(1) hey/a$1b # add/f(2) hey/a${1}b # add/f(*) hey/a${1}b #END_VCP # my $in = slurp $infile; # # $in =~ s{(name>)add/f([^<]*)}{$1hey/a$2b}g; # # assert_eq $infile, $in, $out ; # } ; # ok $@ || '', '', 'diff' ; #}, ) ; 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 |