⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testsvncopy.pl.in

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 IN
📖 第 1 页 / 共 3 页
字号:
#! /usr/bin/perl##  testsvncopy.pl  --  test script for svncopy.pl.##  This program is free software; you can redistribute  it and/or modify it#  under  the terms of  the GNU General  Public License as published by the#  Free Software Foundation;  either version 2 of the  License, or (at your#  option) any later version.##  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS  OR  IMPLIED#  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN#  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT,  INDIRECT,#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT#  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF#  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON#  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF#  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ##  You should have received a copy of the  GNU General Public License along#  with this program; if not, write  to the Free Software Foundation, Inc.,#  59 Temple Place - Suite 330, Boston MA 02111-1307 USA.##  This product makes use of software developed by #  CollabNet (http://www.Collab.Net/), see http://subversion.tigris.org/.##  This software consists of voluntary contributions made by many#  individuals.  For exact contribution history, see the revision#  history and logs, available at http://subversion.tigris.org/.#------------------------------------------------------------------------------#------------------------------------------------------------------------------##  This script tests the operation of svncopy.pl.##  For more information see the pod documentation at the foot of the file,#  or run testsvncopy.pl -?.##------------------------------------------------------------------------------## Include files#use Cwd;use File::Temp   0.12   qw(tempdir tempfile);use Getopt::Long 2.25;use Pod::Usage;use URI          1.17;## Global definitions## Specify the location of the svn command.my $svn = '@SVN_BINDIR@/svn';# The scratch repository location for the testsmy $testroot = '@SVN_TEST_REPOSITORY@';# Input parametersmy $verbose = 0;my @svn_options = ();# Internal informationmy %externals_hash;my $temp_dir;# Error handlingmy @errors = ();my @warnings = ();# Testing-specific variablesmy $hideerrors = 0;#------------------------------------------------------------------------------# Main execution block### Process arguments#GetOptions( "verbose!" => sub { $verbose = 1; push( @svn_options, "--verbose" ) },            "quiet|q" => sub { $verbose = 0; push( @svn_options, "--quiet" ) },            "username=s" => sub { push( @svn_options, "--username", $_[1] ) },            "password=s" => sub { push( @svn_options, "--password", $_[1] ) },            "no_auth_cache" => sub { push( @svn_options, "--no-auth-cache" ) },            "force-log" => sub { push( @svn_options, "--force-log" ) },            "encoding=s" => sub { push( @svn_options, "--encoding", $_[1] ) },            "config-dir=s" => sub { push( @svn_options, "--config-dir", $_[1] ) },            "test-repository|t=s" => \$testroot,            "help|?" => sub{ Usage() },            ) or Usage();# Put in a signal handler to clean up any temporary directories.sub catch_signal {  my $signal = shift;  warn "$0: caught signal $signal.  Quitting now.\n";  exit 1;}$SIG{HUP}  = \&catch_signal;$SIG{INT}  = \&catch_signal;$SIG{TERM} = \&catch_signal;$SIG{PIPE} = \&catch_signal;# Make sure we're in the correct directory, saving current before we movemy $startDir = cwd;if ( $0 =~ m"(.*[\\/])[^\\/]+$" ){    my $programDir = $1;    chdir( $programDir );}# Run the teststestUpdateExternals();# Check whether they passedif ( 0 != scalar( @errors ) ){  print "\n*****************************************************************\n";  print "Errors:\n";  print @errors;}else{  print "*** Script passed tests ***\n";}# Return to the original directorychdir( $startDir );exit( scalar( @errors ) );#------------------------------------------------------------------------------# Function:    testUpdateExternals## Tests the script, pushing any errors onto @errors.## Parameters:#       none## Returns:     none#------------------------------------------------------------------------------sub testUpdateExternals{  my $failed = 0;  my $retval;  my $testsubdir = "svncopy-update";  my $testURL = "$testroot/$testsubdir";  my @testdirs = (      "source/dirA/dir1",      "source/dirA/dir2",      "source/dirB/dir3",      "wibble/dirA/dir2",  );  my $dirWithExternals = $testdirs[0];  my $pinnedDir = $testdirs[1];  my $dest = "$testURL/dest";  my $old_verbose = $verbose;  my %revisions = {};  my $testRev;      my $test_externals =                   "DIR2 $testURL/source/dirA/dir2\n".     # 1 space                  "DIR2Pin -r __PINREV__ $testURL/source/dirA/dir2\n".                  "DIR3     $testURL/source/dirB/dir3\n". # 5 spaces                  "DIR4		$testURL/wibble/dirA/dir2";   # 2 tabs  my @tests = (        # Updating with nothing to update        { sources => [ "$testURL/source/dirA/dir1", ],          pin => 0,          update => 1,          ext_dir => "dir1",          expected_externals => [                    "DIR2 $testURL/source/dirA/dir2",                    "DIR2Pin -r __PINREV__ $testURL/source/dirA/dir2",                    "DIR3     $testURL/source/dirB/dir3",                    "DIR4		$testURL/wibble/dirA/dir2"                    ],          expected_tree => [                    "dir1/",                    ],        },        # Updating a tree - enclosed should change, unless pinned        { sources => [ "$testURL/source/dirA", ],          pin => 0,          update => 1,          ext_dir => "dirA/dir1",          expected_externals => [                    "DIR2 $testURL/dest/dirA/dir2",                    "DIR2Pin -r __PINREV__ $testURL/source/dirA/dir2",                    "DIR3     $testURL/source/dirB/dir3",                    "DIR4		$testURL/wibble/dirA/dir2"                    ],          expected_tree => [                    "dirA/",                    "dirA/dir1/",                    "dirA/dir2/",                    ],        },        # Updating with no update - no change        { sources => [ "$testURL/source/dirA", ],          pin => 0,          update => 0,          ext_dir => "dirA/dir1",          expected_externals => [                     "DIR2 $testURL/source/dirA/dir2",                    "DIR2Pin -r __PINREV__ $testURL/source/dirA/dir2",                    "DIR3     $testURL/source/dirB/dir3",                    "DIR4		$testURL/wibble/dirA/dir2"                    ],          expected_tree => [                    "dirA/",                    "dirA/dir1/",                    "dirA/dir2/",                    ],        },        # Updating with two sources        { sources => [ "$testURL/source/dirA/dir1",                       "$testURL/source/dirB/dir3" ],          pin => 0,          update => 1,          ext_dir => "dir1",          expected_externals => [                    "DIR2 $testURL/source/dirA/dir2",                    "DIR2Pin -r __PINREV__ $testURL/source/dirA/dir2",                    "DIR3     $testURL/dest/dir3",                    "DIR4		$testURL/wibble/dirA/dir2"                    ],          expected_tree => [                    "dir1/",                    "dir3/",                    ],        },        # Pinning        { sources => [ "$testURL/source/dirA/dir1", ],          pin => 1,          update => 0,          ext_dir => "dir1",          expected_externals => [                    "DIR2 -r __REV__ $testURL/source/dirA/dir2",                    "DIR2Pin -r __PINREV__ $testURL/source/dirA/dir2",                    "DIR3 -r __REV__     $testURL/source/dirB/dir3",                    "DIR4 -r __REV__		$testURL/wibble/dirA/dir2",                    ],          expected_tree => [                    "dir1/",                    ],        },        # Pinning a tree        { sources => [ "$testURL/source/dirA", ],          pin => 1,          update => 0,          ext_dir => "dirA/dir1",          expected_externals => [                    "DIR2 -r __REV__ $testURL/source/dirA/dir2",                    "DIR2Pin -r __PINREV__ $testURL/source/dirA/dir2",                    "DIR3 -r __REV__     $testURL/source/dirB/dir3",                    "DIR4 -r __REV__		$testURL/wibble/dirA/dir2",                    ],          expected_tree => [                    "dirA/",                    "dirA/dir1/",                    "dirA/dir2/",                    ],        },        # Pinning with two sources        { sources => [ "$testURL/source/dirA/dir1",                       "$testURL/source/dirB/dir3" ],          pin => 1,          update => 0,          ext_dir => "dir1",          expected_externals => [                    "DIR2 -r __REV__ $testURL/source/dirA/dir2",                    "DIR2Pin -r __PINREV__ $testURL/source/dirA/dir2",                    "DIR3 -r __REV__     $testURL/source/dirB/dir3",                    "DIR4 -r __REV__		$testURL/wibble/dirA/dir2",                    ],          expected_tree => [                    "dir1/",                    "dir3/",                    ],        },    );      my $auto_temp_dir = Temp::Delete->new();  my $test_temp_dir = $auto_temp_dir->temp_dir();  $temp_dir = $test_temp_dir;  print "\n################################################################\n";  print( "Testing svncopy.pl\n" );  info( "Using temporary directory $test_temp_dir\n" );  print( "Preparing source directory structure...\n" );  #  # Set up the source directory to copy  #      # Kill the directory if it's there  info( " - Deleting '$testURL'\n" );  SVNCall( 'delete', '-m', '"Preparing to test svncopy --update-externals"', $testURL );      # Now create the source directories  foreach my $dir ( @testdirs )    {      if ( !CreateTestDirectory( "$testURL/$dir" ) )        {          $failed = 1;          return;        }    }  # Check out the test root  if ( 0 != SVNCall( "co", $testURL, "$test_temp_dir/$testsubdir" ) )    {      error( "Preparatory checkout failed" );      $failed = 1;      return;    }      # Set an svn:externals on it  # - work our what externals we need to set (get the revision for the  #   pinned directory)  my $pinnedRev = CurrentRevision( "$testURL/$pinnedDir" );  $test_externals =~ s|__PINREV__|$pinnedRev|gi;      # Now write the externals to a temporary file and set them on the dir.  my ($handle, $tmpfile) = tempfile( DIR => $test_temp_dir );  print $handle $test_externals;  close($handle);  if ( 0 != SVNCall( "propset", "svn:externals",                     "--file", $tmpfile,                     "$test_temp_dir/$testsubdir/$dirWithExternals" ) )    {      error( "svn propset of svn:externals failed" );      $failed = 1;      return;    }      # And commit them  if ( 0 != SVNCall( "commit", "-m",                     "\"Testing svncopy --update_externals - adding svn:externals\"",                     "$test_temp_dir/$testsubdir/$dirWithExternals" ) )    {      error( "svn commit failed" );      $failed = 1;      return;    }      #  # Also set a property on the pinned directory to make sure the pinned  # revision isn't the last one.  #  if ( 0 != SVNCall( "propset",                     "svncopyTest",                     "wibble",                     "$test_temp_dir/$testsubdir/$pinnedDir" ) )    {      error( "svn propset of svncopyTest failed" );      $failed = 1;      return;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -