90revml2p4_1.t #8

  • //
  • guest/
  • perforce_software/
  • revml/
  • t/
  • 90revml2p4_1.t
  • View
  • Commits
  • Open Download .zip Download (2 KB)
#!/usr/local/bin/perl -w

=head1 NAME

p4.t - testing of vcp p4 i/o

=cut

use strict ;

use Carp ;
use File::Path ;
use File::Spec ;
use POSIX ':sys_wait_h' ;
use Test ;
use VCP::TestUtils ;

# use eq_or_diff from Test::Differences if available,
# else just use ok.
eval "use Test::Differences";
sub ok_or_diff {
   goto &eq_or_diff if defined &eq_or_diff;
   goto &Test::ok;
}


my @vcp = vcp_cmd ;

my $t = -d 't' ? 't/' : '' ;

my $p4root_1  = "${t}p4root_1";
my $p4state_1 = "${t}p4state_1";
my $p4_rev_root = "//depot/foo/";
my $p4_spec = "p4:revml2p4\@$p4root_1:$p4_rev_root";
my $p4_repo_id = "p4:test_repository";

my @tests = (
## copy p4root_0 to p4root_1
sub {
   my $p4root_0  = "${t}p4root_0";
   my $p4state_0 = "${t}p4state_0";
   rmtree [ grep -e, $p4root_1, $p4state_1 ];
   copy_dir_tree $p4root_0, $p4root_1;
   copy_dir_tree $p4state_0, $p4state_1;
   ok 1;
},

## revml -> p4 
sub {
   my $infile  = $t . "test-p4-in-1.revml" ;
   ok run [ @vcp, "revml:$infile", $p4_spec,
            "--run-p4d",
            "--db-dir=$p4state_1",
            "--repo-id=$p4_repo_id",
            "--change-branch-rev-1",
          ], \undef;
},


## slurp revml files and analyze with regexps to count number of
## unique named files and the highest change number for each file,
## then look at the head_revs_db to see if the repository really
## contains all that.

## detailed analysis of this import is left to 91p42revml.t             

sub {
   my $infile0  = $t . "test-p4-in-0.revml" ;
   my $infile1  = $t . "test-p4-in-1.revml" ;

   # my $p4_options = launch_p4d "p4_", { 
   #    repo_dir      => "${t}p4root_1",
   # } ;

   #my $revs1 = parse_files_and_revids_from_p4_files $p4_rev_root, $p4_options, "//..." ;
   my $revs1 = parse_files_and_revids_from_head_revs_db
      { state_dir => $p4state_1, repo_id => $p4_repo_id, remove_rev_root => "/ignored/" };
   my $revs2 = parse_files_and_revids_from_revml $infile0, $infile1 ;

   ok_or_diff $revs1, $revs2;
},

) ;  # end @tests



plan tests => scalar @tests ;

my $p4d_borken = p4d_borken ;

my $why_skip ;
$why_skip .= "p4 command not found\n"  unless ( `p4 -V`  || 0 ) =~ /^Perforce/ ;
$why_skip .= "$p4d_borken\n"           if $p4d_borken ;

$why_skip ? skip( $why_skip, '' ) : $_->() for @tests ;
# Change User Description Committed
#11 5403 Barrie Slaymaker - Misc logging, maintainability & debugging improvements
#10 3970 Barrie Slaymaker - VCP::Source handles rev queing, uses disk to reduce RAM
- Lots of other fixes
#9 3422 Barrie Slaymaker - Factor some common code in to VCP::Utils::p4.
- Add error when a p4 filespec ends in a '/' or '\'
- Clean up revml2p4 test scripts
#8 2961 John Fetkovich small fixup to previous change
#7 2959 John Fetkovich added dump method to lib/VCP/DB_File/sdbm.pm to dump keys => values
       from a sdbm file.  removed similar code from bin/dump_head_revs,
       bin/dump_rev_map and bin/dump_main_branch_id and called this method
       instead.  also made parse_files_and_revids_from_head_revs_db sub
       in TestUtils to use in test suites instead of
       parse_files_and_revids_from_p4_files et. al.
#6 2926 John Fetkovich remove --state-location switch
       add --db-dir and --repo-id switches
       build state location from concatenation of those two.
#5 2915 Barrie Slaymaker Default to *not* changing the first rev of a branch,
       add --change-branch-rev-1 to enable the non-default
       behavior (which is what is used by most of the test suite).
#4 2721 Barrie Slaymaker VCP::Dest::p4 now uses RevMapDB
#3 2599 John Fetkovich Changed parse_files_and_revids_from_p4_files to accept
file_spec argument to p4 files command.  Modified test suites
to use it.  Various documentation changes to TestUtils.pm.
#2 2591 John Fetkovich Changed 90revml2p4_1.t to use improvements previously done to
       90revml2p4_0.t.  Factored out parse_files_and_revids_from_p4_files
       common to both into TestUtils.pm.
#1 2589 John Fetkovich Split 90p4.t into 90revml2p4_0.t, 90revml2p4_1.t, 91p42revml.t, 95p42cvs.t.
       Added some utilities to the library files listed.