#!/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 $p4_options ; my $p4_spec_base ; my $p4_rev_root ; my $p4_spec ; my @tests = ( ### # create empty p4 repository sub { $ENV{P4USER} = "foobar_user" ; $ENV{P4PORT} = "foobar_port" ; $ENV{P4CLIENT} = "foobar_client" ; $ENV{P4PASSWD} = "foobar_passwd" ; $p4_options = launch_p4d "p4_", { repo_dir => "${t}p4root_0", rm_repo_dir => 1, } ; $p4_spec_base = "p4:$p4_options->{user}:\@$p4_options->{port}:" ; $p4_rev_root = "//depot/foo/" ; $p4_spec = "$p4_spec_base$p4_rev_root" ; ok 1 ; }, ## ## Empty import ## sub { run [ @vcp, "revml:-", $p4_spec ], \"<revml/>" ; #"# de-confuse emacs cperl-mode ok $?, 0, "`vcp revml:- $p4_spec` return value" ; }, ## revml -> p4 bootstrap export sub { my $infile = $t . "test-p4-in-0.revml" ; ok run [ @vcp, "revml:$infile", $p4_spec ], \undef; }, ## slurp $infile and analyze with regexps to count ## number of unique named files and the highest change ## number for each file, then use the p4 files command line ## client to see if the repository really contains all that. ## detailed analysis of this import is left to 91p42revml.t sub { my $infile = $t . "test-p4-in-0.revml" ; #print map "$_ => $p4_options->{$_}, ", keys %$p4_options; #print "\n"; my $revs1 = parse_files_and_revids_from_revml $infile ; my $output; run_p4 [ "files", "//..." ], \undef, \$output, $p4_options; my $h = {}; while ( $output =~ m{(.*)#(\d+) - }g ) { die "'p4 files' output lines weren't preceeded by $p4_rev_root as expected" if index( $1, $p4_rev_root ) < 0 ; my $name = substr $1, length $p4_rev_root ; die "duplicate file names in p4 files output" if exists $h->{$name}; $h->{$name} = $2 ; } my $revs2 = join "", map { "$_ => $h->{$_}\n" } sort keys %$h; ok_or_diff $revs1, $revs2; }, ) ; 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 | |
---|---|---|---|---|---|
#12 | 5403 | Barrie Slaymaker | - Misc logging, maintainability & debugging improvements | ||
#11 | 3970 | Barrie Slaymaker |
- VCP::Source handles rev queing, uses disk to reduce RAM - Lots of other fixes |
||
#10 | 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 |
||
#9 | 2960 | John Fetkovich | small fixup to previous change | ||
#8 | 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. |
||
#7 | 2926 | John Fetkovich |
remove --state-location switch add --db-dir and --repo-id switches build state location from concatenation of those two. |
||
#6 | 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). |
||
#5 | 2721 | Barrie Slaymaker | VCP::Dest::p4 now uses RevMapDB | ||
#4 | 2623 | John Fetkovich | added TODO: comments | ||
#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. |