#!/usr/local/bin/perl -w =head1 NAME 61labelmap.t - test VCP::Filter::map =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::map; use VCP::Rev; enable_debug( split /,/, $ENV{VCPDEBUG} ) if defined $ENV{VCPDEBUG} ; my @vcp = vcp_cmd ; sub r { my ( $name, $branch_id ) = $_[0] =~ /\A(?:(.+?))?(?:<(.*)>)?\z/ or die "Couldn't parse '$_[0]'"; VCP::Rev->new( id => $_[0], name => $name, branch_id => $branch_id, ) } my $sub; my $r_out; # HACK sub VCP::Filter::map::dest { return "main"; } sub handle_rev { my $self = shift; my ( $rev ) = @_; $r_out = join "", $rev->name || "", "<", $rev->branch_id || "", ">"; } sub t { return skip "compilation failed", 1 unless $sub; my ( $expr, $expected ) = @_; $r_out = undef; $sub->( "VCP::Filter::map", r $expr ); @_ = ( $r_out || "<<deleted>>", $expected || "<<deleted>>" ); goto &ok; } my @tests = ( ## In vitro tests sub { $sub = eval { VCP::Filter::map->_compile_rules( [ '<b>', '<B>' ], [ 'a', 'A' ], [ 'a', 'NONONO' ], [ 'c<d>', 'C<D>' ], [ 'xyz', '<<keep>>' ], [ 'x*', '<<delete>>' ], [ 's(*)v<(...)>', 'S$1V${2}Y<>' ], [ 's(*)v<>', 'NONONO' ], ) }; ok defined $sub || $@, 1; }, sub { t "a<b>", "a<B>" }, sub { t "a<c>", "A<c>" }, sub { t "c<d>", "C<D>" }, sub { t "c<e>", "c<e>" }, sub { t "e<d>", "e<d>" }, sub { t "xab", undef }, sub { t "xyz", "xyz<>" }, sub { t "Z<Z>", "Z<Z>" }, sub { t "stuv<wx>", "StuVwxY<>" }, ## 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 avoid 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 | |
---|---|---|---|---|---|
#7 | 5404 | Barrie Slaymaker |
- SVN support added - Makefile gives clearer notices about missing optional prereqs. - VCP::Filter::labelmap and VCP::Filter::map: <<skip>> replaces deprecated <<delete>> to be clearer that no revisions are deleted from either repository but some just are skipped and not inserted. - VCP::Filter::map: support added for SVN-like branch labels - VCP::Source: support added for ISO8601 timestamps emitted by SVN. |
||
#6 | 5087 | Barrie Slaymaker | - VCPDEBUG=1 can be used when running tests | ||
#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 | 3091 | Barrie Slaymaker |
Factor out rules list parsing; it's useful elsewhere and should not have been copy & edited in to two files in the first place. |
||
#2 | 3027 | Barrie Slaymaker | VCP::Filter::labelmap | ||
#1 | 3025 | Barrie Slaymaker | Prepare to add LabelMap directive (VCP::Filter::labelmap) |