From 141b2ce8970cab434e562b4017ca82beb7438bc5 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Wed, 14 Mar 2012 15:30:05 +0530 Subject: [PATCH] more tests --- src/Gitolite/Test.pm | 5 +++ t/include-subconf.t | 79 +++++++++++++++++++++++++++++++++ t/info.t | 52 ++++++++++++++++++++++ t/m-explode.t | 102 ------------------------------------------- 4 files changed, 136 insertions(+), 102 deletions(-) create mode 100755 t/include-subconf.t create mode 100755 t/info.t delete mode 100755 t/m-explode.t diff --git a/src/Gitolite/Test.pm b/src/Gitolite/Test.pm index e78fe88..df4cc89 100644 --- a/src/Gitolite/Test.pm +++ b/src/Gitolite/Test.pm @@ -77,6 +77,11 @@ sub _confargs { sub confreset { system("rm", "-rf", "conf"); mkdir("conf"); + system("mv ~/repositories/gitolite-admin.git ~/repositories/.ga"); + system("mv ~/repositories/testing.git ~/repositories/.te"); + system("find ~/repositories -name '*.git' |xargs rm -rf"); + system("mv ~/repositories/.ga ~/repositories/gitolite-admin.git"); + system("mv ~/repositories/.te ~/repositories/testing.git "); put "conf/gitolite.conf", ' repo gitolite-admin RW+ = admin diff --git a/t/include-subconf.t b/t/include-subconf.t new file mode 100755 index 0000000..7bb5b04 --- /dev/null +++ b/t/include-subconf.t @@ -0,0 +1,79 @@ +#!/usr/bin/perl +use strict; +use warnings; + +# this is hardcoded; change it if needed +use lib "src"; +use Gitolite::Test; + +try 'plan 37'; + +confreset; confadd ' + include "i1.conf" + @i2 = b1 + subconf "i2.conf" + include "i1.conf" +'; +confadd 'i1.conf', ' + @g1 = a1 a2 + repo foo + RW = u1 + + include "j1.conf" +'; +confadd 'i2.conf', ' + @g2 = b1 b2 + repo bar b1 b2 i1 i2 @i1 @i2 @g2 + RW = u2 +'; +confadd 'j1.conf', ' + @h2 = c1 c2 + repo baz + RW = u3 +'; + +try "ADMIN_PUSH set2; !/FATAL/" or die text(); + +try " + /i1.conf already included/ + /i2.conf attempting to set access for \@i1, b2, bar, i1, locally modified \@g2/ + !/attempting to set access.*i2/ + /Initialized.*empty.*baz.git/ + /Initialized.*empty.*foo.git/ + /Initialized.*empty.*b1.git/ + /Initialized.*empty.*i2.git/ + !/Initialized.*empty.*b2.git/ + !/Initialized.*empty.*i1.git/ + !/Initialized.*empty.*bar.git/ +"; + +confreset;confadd ' + @g2 = i1 i2 i3 + subconf "g2.conf" +'; +confadd 'g2.conf', ' + @g2 = g2 h2 i2 + repo @g2 + RW = u1 +'; + +try "ADMIN_PUSH set3; !/FATAL/" or die text(); +try " + /g2.conf attempting to set access for locally modified \@g2/ + !/Initialized.*empty/ +"; + +confreset;confadd ' + @g2 = i1 i2 i3 + subconf "g2.conf" +'; +confadd 'g2.conf', ' + subconf master + @g2 = g2 h2 i2 + repo @g2 + RW = u1 +'; + +try " + ADMIN_PUSH set3; ok; /FATAL: subconf g2 attempting to run 'subconf'/ +"; diff --git a/t/info.t b/t/info.t new file mode 100755 index 0000000..967f4af --- /dev/null +++ b/t/info.t @@ -0,0 +1,52 @@ +#!/usr/bin/perl +use strict; +use warnings; + +# this is hardcoded; change it if needed +use lib "src"; +use Gitolite::Test; + +try 'plan 35'; + +try "## info"; + +confreset;confadd ' + repo t1 + RW = u1 + R = u2 + repo t2 + RW = u2 + R = u1 + repo t3 + RW = u3 + R = u4 +'; + +try "ADMIN_PUSH info; !/FATAL/" or die text(); +try " + /Initialized.*empty.*t1.git/ + /Initialized.*empty.*t2.git/ + /Initialized.*empty.*t3.git/ +"; +try " + glt info u1; ok; gsh + /R W *\tt1/ + /R *\tt2/ + !/t3/ + / R W *\ttesting/ + glt info u2; ok; gsh + /R *\tt1/ + /R W *\tt2/ + !/t3/ + / R W *\ttesting/ + glt info u3; ok; gsh + /R W *\tt3/ + !/t1/ + !/t2/ + / R W *\ttesting/ + glt info u4; ok; gsh + /R *\tt3/ + !/t1/ + !/t2/ + / R W *\ttesting/ + " or die; diff --git a/t/m-explode.t b/t/m-explode.t deleted file mode 100755 index aef337f..0000000 --- a/t/m-explode.t +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; -use 5.10.0; - -use Test; -BEGIN { plan tests => - 2 -} - -use lib "$ENV{PWD}/src"; -use Gitolite::Test; -use Gitolite::Conf::Explode; - -my @out; -my @out2; - -warn " - <<< expect a couple of warnings about already included files >>> -"; - -# test 1 -- space normalisation - - put "foo", " - foo line 1 - foo=line 2 - - - foo 3 - "; - @out = (); - explode("foo", 'master', \@out); - @out2 = ( - 'foo line 1', - 'foo = line 2', - 'foo 3', - ); - - ok(@out ~~ @out2); - -# test 2 -- include/subconf processing - - put "foo", " - foo line 1 - \@fog=line 2 - include \"bar.conf\" - - foo line=5 - subconf \"subs/baz.conf\" - include \"bar.conf\" - foo line=7 - include \"bazup.conf\" - "; - - put "bar.conf", " - \@brg=line 1 - - bar line 3 - "; - - mkdir("subs"); - - put "subs/baz.conf", " - \@bzg = line 1 - - include \"subs/baz2.conf\" - - baz=line 3 - "; - - put "subs/baz2.conf", " - baz2 line 1 - baz2 line 2 - include \"bazup.conf\" - baz2 line 4 - "; - - put "bazup.conf", " - whatever... - "; - - @out = (); - explode("foo", 'master', \@out); - - @out2 = ( - 'foo line 1', - '@fog = line 2', - '@brg = line 1', - 'bar line 3', - 'foo line = 5', - 'subconf baz', - '@baz.bzg = line 1', - 'baz2 line 1', - 'baz2 line 2', - 'whatever...', - 'baz2 line 4', - 'baz = line 3', - 'subconf master', - 'foo line = 7' - ); - - ok(@out ~~ @out2);