#!/usr/local/bin/perl -w
=head1 NAME
identity.t - test VCP::Filter::identity
=cut
use strict ;
use Carp ;
use File::Spec ;
use Test ;
use VCP::TestUtils ;
my %seen ;
my @perl = ( $^X, map {
my $s = $_ ;
$s = File::Spec->rel2abs( $_ ) ;
"-I$s" ;
} grep ! $seen{$_}++, @INC
) ;
## We always run vcp by doing a @perl, vcp, to make sure that vcp runs under
## the same version of perl that we are running under.
my $vcp = 'vcp' ;
$vcp = "bin/$vcp" if -e "bin/$vcp" ;
$vcp = "../bin/$vcp" if -e "../bin/$vcp" ;
$vcp = File::Spec->rel2abs( $vcp ) ;
my @vcp = ( @perl, $vcp ) ;
my $t = -d 't' ? 't/' : '' ;
my @tests = (
##
## Empty imports, used here just to see if commad line parsing is ok and
## that a really simple file can make it through the XML parser ok.
##
sub {
run [ @vcp, qw( - identity: - ) ], \"" ;
ok $?, 0, "`vcp revml:- identiry: revml:` return value" ;
},
sub {
run [ @vcp, qw( - identity: - ) ], \"" ;
ok $?, 0, "`vcp revml:- identiry: revml:` return value" ;
},
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, $infile, qw( identity: - ), "--sort-by=name,rev_id" ],
\undef, \$out;
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, $infile, qw( identity: identity: - ), "--sort-by=name,rev_id"],
\undef, \$out;
my $in = slurp( $infile ) ;
assert_eq $infile, $in, $out ;
} ;
ok $@ || '', '', 'diff' ;
},
) ;
plan tests => scalar( @tests ) ;
unless ( -e $vcp ) {
print STDERR "# '$vcp' not found\n" ;
skip( 1, '' ) for @tests ;
exit ;
}
$_->() for @tests ;