1 package Gitolite
::Test
;
3 # functions for the test code to use
4 # ----------------------------------------------------------------------
19 use Exporter
'import';
20 use File
::Path
qw(mkpath);
21 use Carp
qw(carp cluck croak confess);
22 use Digest
::MD5
qw(md5_hex);
27 require Gitolite
::Test
::Tsh
;
28 *{'try'} = \
&Tsh
::try
;
29 *{'put'} = \
&Tsh
::put
;
30 *{'text'} = \
&Tsh
::text
;
31 *{'lines'} = \
&Tsh
::lines
;
32 *{'cmp'} = \
&Tsh
::cmp;
38 # ----------------------------------------------------------------------
40 # make sure the user is ready for it
41 if ( not $ENV{GITOLITE_TEST
} or $ENV{GITOLITE_TEST
} ne 'y' ) {
42 print "Bail out! See t/README for information on how to run the tests.\n";
46 # required preamble for all tests
48 DEF gsh = /TRACE: gsh.SOC=/
49 DEF reject = /hook declined to update/; /remote rejected.*hook declined/; /error: failed to push some refs to/
51 DEF AP_1 = cd ../gitolite-admin; ok or die cant find admin repo clone;
52 DEF AP_2 = AP_1; git add conf ; ok; git commit -m %1; ok; /master.* %1/
53 DEF ADMIN_PUSH = AP_2 %1; glt push admin origin; ok; gsh; /master -> master/
55 DEF CS_1 = pwd; //tmp/tsh_tempdir.*gitolite-admin/; git remote -v; ok; /file:///gitolite-admin/
56 DEF CHECK_SETUP = CS_1; git log; ok; /fa7564c1b903ea3dce49314753f25b34b9e0cea0/
58 DEF CLONE = glt clone %1 file:///%2
59 DEF PUSH = glt push %1 origin
62 mkdir -p $ENV{HOME}/bin
63 ln -sf $ENV{PWD}/t/glt ~/bin
65 cd; rm -vrf .gito* repositories
66 git config --file $ENV{HOME}/.gitconfig.local user.name \"gitolite tester\"
67 git config --file $ENV{HOME}/.gitconfig.local user.email \"tester\@example.com\"
68 git config --global include.path \"~/.gitconfig.local\"
71 gitolite setup -a admin
75 glt clone admin --progress file:///gitolite-admin
77 " or die "could not setup the test environment; errors:\n\n" . text
() . "\n\n";
82 print STDERR
"DBG: " . Dumper
($i);
87 return @_ if ( $_[1] );
88 return 'gitolite.conf', $_[0];
92 chdir("../gitolite-admin") or die "in `pwd`, could not cd ../g-a";
93 system( "rm", "-rf", "conf" );
95 system("mv ~/repositories/gitolite-admin.git ~/repositories/.ga");
96 system("mv ~/repositories/testing.git ~/repositories/.te");
97 system("find ~/repositories -name '*.git' |xargs rm -rf");
98 system("mv ~/repositories/.ga ~/repositories/gitolite-admin.git");
99 system("mv ~/repositories/.te ~/repositories/testing.git ");
100 put
"|cut -c9- > conf/gitolite.conf", '
109 chdir("../gitolite-admin") or die "in `pwd`, could not cd ../g-a";
110 my ( $file, $string ) = _confargs
(@_);
111 put
"|cat >> conf/$file", $string;
117 $out .= md5_hex
( slurp
($file) ) . " $file\n";