#!/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 ; # what change number to start incremental export at my $first_import_1_change; # was called $incr_change my @tests = ( ### # create p4 repository p4root_1 as copy of p4root_0 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_1", copy_from_dir => "${t}p4root_0", } ; $p4_spec_base = "p4:$p4_options->{user}:\@$p4_options->{port}:" ; $p4_rev_root = "//depot/foo/" ; # $p4_spec = "$p4_spec_base" ; ??? $p4_spec = "$p4_spec_base$p4_rev_root" ; ok 1 ; }, # determine next change number that p4d will use this will become the # change number of the first change in t/test-p4-in-1.revml when it is # imported. sub { # get counter change run_p4 [ qw( counter change ) ], \undef, \$first_import_1_change, $p4_options ; chomp $first_import_1_change ; die "Invalid change counter value: '$first_import_1_change'" unless $first_import_1_change =~ /^\d+$/ ; ++$first_import_1_change ; ok 1; }, ## revml -> p4 sub { my $infile = $t . "test-p4-in-1.revml" ; ok run [ @vcp, "revml:$infile", $p4_spec ], \undef; }, ## slurp revml files 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 $infile0 = $t . "test-p4-in-0.revml" ; my $infile1 = $t . "test-p4-in-1.revml" ; my $revs1 = parse_files_and_revids_from_revml $infile0, $infile1 ; my $revs2 = parse_files_and_revids_from_p4_files $p4_rev_root, $p4_options ; ok_or_diff $revs1, $revs2; }, ### replaced by preceding sub # sub { # # # --- replace with p4 commands (number 5 in diagram) # # --- also needs to be copied over to 91revml2p4.t # # --- see also code like this in 90revml2p4_0.t (to (to here) ) # # # see if got the right # of files, changes # # p42revml will do detailed checking (the following code) # my $in = slurp $infile ; # my $out = get_vcp_output "${p4_spec}...\@$first_import_1_change,#head" ; # # $in =~ s{</rev_root>}{/foo</rev_root>} ; # s_content qw( rep_desc time user_id p4_info ), \$in, \$out ; # s_content qw( rev_root ), \$in, "depot/foo" ; # rm_elts qw( label ), qr/r_\w+|ch_\w+/, \$in, \$out ; # # rm_elts qw( branches ), \$in ; # # ## TODO: This is an incremental export and perforce does not give us # ## a trivial way to figure out what branch a file is on (since # ## multiple branch views can cover the same file), so we bail # ## on that for now. # rm_elts qw( branch_id ), \$in ; # # $in =~ s{(id="|_id>)/+ignored}{$1//depot/foo}g; # # assert_eq $infile, $in, $out ; # # --- (to here) # # # } ; # ok $@ || '', '', 'diff' ; # # --- replace # }, ) ; 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. |