git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] t9400: Add test cases for config file handling
@ 2007-05-20 22:31 Frank Lichtenheld
  2007-05-20 22:31 ` [PATCH 2/3] t9400: Add some more cvs update tests Frank Lichtenheld
  2007-05-21  0:57 ` [PATCH 1/3] t9400: Add test cases for config file handling Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Frank Lichtenheld @ 2007-05-20 22:31 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Martin Langhoff, Frank Lichtenheld

Add a few test cases for the config file parsing
done by git-cvsserver.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
---
 t/t9400-git-cvsserver-server.sh |   69 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

 Note that this currently has one failing test. This will need
 to be fixed in git-cvsserver though.

diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index d406a88..1b63435 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -47,6 +47,75 @@ test_expect_success 'basic checkout' \
   'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master &&
    test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
 
+#--------------
+# CONFIG TESTS
+#--------------
+
+test_expect_success 'gitcvs.enabled = false' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
+   if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
+   then
+     echo unexpected cvs success
+     false
+   else
+     true
+   fi &&
+   cat cvs.log | grep -q "GITCVS emulation disabled" &&
+   test ! -d cvswork2'
+
+rm -fr cvswork2
+test_expect_success 'gitcvs.ext.enabled = true' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
+   GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
+   GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
+   diff -q cvswork cvswork2'
+
+rm -fr cvswork2
+test_expect_success 'gitcvs.ext.enabled = false' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false &&
+   GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
+   if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
+   then
+     echo unexpected cvs success
+     false
+   else
+     true
+   fi &&
+   cat cvs.log | grep -q "GITCVS emulation disabled" &&
+   test ! -d cvswork2'
+
+rm -fr cvswork2
+test_expect_success 'gitcvs.dbname' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
+   GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite &&
+   GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
+   diff -q cvswork cvswork2 &&
+   test -f "$SERVERDIR/gitcvs.ext.master.sqlite" &&
+   cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs.ext.master.sqlite"'
+
+rm -fr cvswork2
+test_expect_success 'gitcvs.ext.dbname' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
+   GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
+   GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
+   GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
+   diff -q cvswork cvswork2 &&
+   test -f "$SERVERDIR/gitcvs1.ext.master.sqlite" &&
+   test ! -f "$SERVERDIR/gitcvs2.ext.master.sqlite" &&
+   cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs1.ext.master.sqlite"'
+
+
+#------------
+# CVS UPDATE
+#------------
+
+rm -fr "$SERVERDIR"
+cd "$WORKDIR" &&
+git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
+GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
+GIT_DIR="$SERVERDIR" git config --bool gitcvs.logfile "$SERVERDIR/gitcvs.log" ||
+exit 1
+
 test_expect_success 'cvs update (create new file)' \
   'echo testfile1 >testfile1 &&
    git add testfile1 &&
-- 
1.5.2-rc3.GIT

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] t9400: Add some more cvs update tests
  2007-05-20 22:31 [PATCH 1/3] t9400: Add test cases for config file handling Frank Lichtenheld
@ 2007-05-20 22:31 ` Frank Lichtenheld
  2007-05-20 22:31   ` [PATCH 3/3] t9400: Add some basic pserver tests Frank Lichtenheld
  2007-05-21  0:57 ` [PATCH 1/3] t9400: Add test cases for config file handling Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Frank Lichtenheld @ 2007-05-20 22:31 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Martin Langhoff, Frank Lichtenheld

Add some cvs update tests that include various merge
situations. Also add a basic test for update -C
since it fits so well in there.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
---
 t/t9400-git-cvsserver-server.sh |   69 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 1b63435..e42943e 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -192,4 +192,73 @@ test_expect_success 'cvs update (re-add deleted file)' \
    test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
    diff -q testfile1 ../testfile1'
 
+cd "$WORKDIR"
+test_expect_success 'cvs update (merge)' \
+  'echo Line 0 >expected &&
+   for i in 1 2 3 4 5 6 7
+   do
+     echo Line $i >>merge
+     echo Line $i >>expected
+   done &&
+   echo Line 8 >>expected &&
+   git add merge &&
+   git commit -q -m "Merge test (pre-merge)" &&
+   git push gitcvs.git >/dev/null &&
+   cd cvswork &&
+   GIT_CONFIG="$git_config" cvs -Q update &&
+   test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" &&
+   diff -q merge ../merge &&
+   ( echo Line 0; cat merge ) >merge.tmp &&
+   mv merge.tmp merge &&
+   cd "$WORKDIR" &&
+   echo Line 8 >>merge &&
+   git add merge &&
+   git commit -q -m "Merge test (merge)" &&
+   git push gitcvs.git >/dev/null &&
+   cd cvswork &&
+   GIT_CONFIG="$git_config" cvs -Q update &&
+   diff -q merge ../expected'
+
+cd "$WORKDIR"
+
+cat >expected.C <<EOF
+<<<<<<< merge.mine
+Line 0
+=======
+LINE 0
+>>>>>>> merge.3
+EOF
+
+for i in 1 2 3 4 5 6 7 8
+do
+  echo Line $i >>expected.C
+done
+
+test_expect_success 'cvs update (conflict merge)' \
+  '( echo LINE 0; cat merge ) >merge.tmp &&
+   mv merge.tmp merge &&
+   git add merge &&
+   git commit -q -m "Merge test (conflict)" &&
+   git push gitcvs.git >/dev/null &&
+   cd cvswork &&
+   GIT_CONFIG="$git_config" cvs -Q update &&
+   diff -q merge ../expected.C'
+
+cd "$WORKDIR"
+test_expect_success 'cvs update (-C)' \
+  'cd cvswork &&
+   GIT_CONFIG="$git_config" cvs -Q update -C &&
+   diff -q merge ../merge'
+
+cd "$WORKDIR"
+test_expect_success 'cvs update (merge no-op)' \
+   'echo Line 9 >>merge &&
+    cp merge cvswork/merge &&
+    git add merge &&
+    git commit -q -m "Merge test (no-op)" &&
+    git push gitcvs.git >/dev/null &&
+    cd cvswork &&
+    GIT_CONFIG="$git_config" cvs -Q update &&
+    diff -q merge ../merge'
+
 test_done
-- 
1.5.2-rc3.GIT

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] t9400: Add some basic pserver tests
  2007-05-20 22:31 ` [PATCH 2/3] t9400: Add some more cvs update tests Frank Lichtenheld
@ 2007-05-20 22:31   ` Frank Lichtenheld
  0 siblings, 0 replies; 7+ messages in thread
From: Frank Lichtenheld @ 2007-05-20 22:31 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Martin Langhoff, Frank Lichtenheld

While we can easily test the cvs <-> git-cvsserver
communication with :fork: and git-cvsserver server
there are some pserver specifics we should test, too.

Currently this are two tests of the pserver authentication.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
---
 t/t9400-git-cvsserver-server.sh |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index e42943e..7f9c6e2 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -47,6 +47,40 @@ test_expect_success 'basic checkout' \
   'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master &&
    test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
 
+#------------------------
+# PSERVER AUTHENTICATION
+#------------------------
+
+cat >request-anonymous  <<EOF
+BEGIN AUTH REQUEST
+$SERVERDIR
+anonymous
+
+END AUTH REQUEST
+EOF
+
+cat >request-git  <<EOF
+BEGIN AUTH REQUEST
+$SERVERDIR
+git
+
+END AUTH REQUEST
+EOF
+
+test_expect_success 'pserver authentication' \
+  'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
+   tail -n1 log | grep -q "^I LOVE YOU$"'
+
+test_expect_success 'pserver authentication failure (non-anonymous user)' \
+  'if cat request-git | git-cvsserver pserver >log 2>&1
+   then
+       false
+   else
+       true
+   fi &&
+   tail -n1 log | grep -q "^I HATE YOU$"'
+
+
 #--------------
 # CONFIG TESTS
 #--------------
-- 
1.5.2-rc3.GIT

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] t9400: Add test cases for config file handling
  2007-05-20 22:31 [PATCH 1/3] t9400: Add test cases for config file handling Frank Lichtenheld
  2007-05-20 22:31 ` [PATCH 2/3] t9400: Add some more cvs update tests Frank Lichtenheld
@ 2007-05-21  0:57 ` Junio C Hamano
  2007-05-21 16:31   ` Frank Lichtenheld
  1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2007-05-21  0:57 UTC (permalink / raw)
  To: Frank Lichtenheld; +Cc: Git Mailing List, Martin Langhoff

This part seems to fail for me and gets an "unexpected cvs success".

+rm -fr cvswork2
+test_expect_success 'gitcvs.ext.enabled = false' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false &&
+   GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
+   if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
+   then
+     echo unexpected cvs success
+     false
+   else
+     true
+   fi &&
+   cat cvs.log | grep -q "GITCVS emulation disabled" &&
+   test ! -d cvswork2'
+

I think the per-method enablement logic is not quite right.

-- >8 --
git-cvsserver: ignore global config when per-method config disables an access.

When the per-method enable logic disables the access, we should
not even look at the global one.

 git-cvsserver.perl |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index fcfb99d..1de5177 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -192,11 +192,9 @@ sub req_Root
         }
     }
 
-    unless ( ($cfg->{gitcvs}{$state->{method}}{enabled}
-	      and $cfg->{gitcvs}{$state->{method}}{enabled} =~ /^\s*(1|true|yes)\s*$/i)
-	     or ($cfg->{gitcvs}{enabled}
-	      and $cfg->{gitcvs}{enabled} =~ /^\s*(1|true|yes)\s*$/i) )
-    {
+    my $enabled = ($cfg->{gitcvs}{$state->{method}}{enabled}
+		   || $cfg->{gitcvs}{enabled});
+    unless ($enabled && $enabled =~ /^\s*(1|true|yes)\s*$/i) {
         print "E GITCVS emulation needs to be enabled on this repo\n";
         print "E the repo config file needs a [gitcvs] section added, and the parameter 'enabled' set to 1\n";
         print "E \n";

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] t9400: Add test cases for config file handling
  2007-05-21  0:57 ` [PATCH 1/3] t9400: Add test cases for config file handling Junio C Hamano
@ 2007-05-21 16:31   ` Frank Lichtenheld
  2007-05-21 16:38     ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Frank Lichtenheld @ 2007-05-21 16:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Martin Langhoff

On Sun, May 20, 2007 at 05:57:27PM -0700, Junio C Hamano wrote:
> This part seems to fail for me and gets an "unexpected cvs success".

Note the note in the patch ;)

> diff --git a/git-cvsserver.perl b/git-cvsserver.perl
> index fcfb99d..1de5177 100755
> --- a/git-cvsserver.perl
> +++ b/git-cvsserver.perl
> @@ -192,11 +192,9 @@ sub req_Root
>          }
>      }
>  
> -    unless ( ($cfg->{gitcvs}{$state->{method}}{enabled}
> -	      and $cfg->{gitcvs}{$state->{method}}{enabled} =~ /^\s*(1|true|yes)\s*$/i)
> -	     or ($cfg->{gitcvs}{enabled}
> -	      and $cfg->{gitcvs}{enabled} =~ /^\s*(1|true|yes)\s*$/i) )
> -    {
> +    my $enabled = ($cfg->{gitcvs}{$state->{method}}{enabled}
> +		   || $cfg->{gitcvs}{enabled});
> +    unless ($enabled && $enabled =~ /^\s*(1|true|yes)\s*$/i) {
>          print "E GITCVS emulation needs to be enabled on this repo\n";
>          print "E the repo config file needs a [gitcvs] section added, and the parameter 'enabled' set to 1\n";
>          print "E \n";


Yeah, should probably have fixed that myself before sending, but the
other patches were already prepared ;)

Gruesse,
-- 
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] t9400: Add test cases for config file handling
  2007-05-21 16:31   ` Frank Lichtenheld
@ 2007-05-21 16:38     ` Junio C Hamano
  2007-05-21 17:31       ` Frank Lichtenheld
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2007-05-21 16:38 UTC (permalink / raw)
  To: Frank Lichtenheld; +Cc: Git Mailing List, Martin Langhoff

Frank Lichtenheld <frank@lichtenheld.de> writes:

> On Sun, May 20, 2007 at 05:57:27PM -0700, Junio C Hamano wrote:
>> This part seems to fail for me and gets an "unexpected cvs success".
>
> Note the note in the patch ;)
>
>> diff --git a/git-cvsserver.perl b/git-cvsserver.perl
>> index fcfb99d..1de5177 100755
>> --- a/git-cvsserver.perl
>> +++ b/git-cvsserver.perl
>> @@ -192,11 +192,9 @@ sub req_Root
>>          }
>>      }
>>  
>> -    unless ( ($cfg->{gitcvs}{$state->{method}}{enabled}
>> -	      and $cfg->{gitcvs}{$state->{method}}{enabled} =~ /^\s*(1|true|yes)\s*$/i)
>> -	     or ($cfg->{gitcvs}{enabled}
>> -	      and $cfg->{gitcvs}{enabled} =~ /^\s*(1|true|yes)\s*$/i) )
>> -    {
>> +    my $enabled = ($cfg->{gitcvs}{$state->{method}}{enabled}
>> +		   || $cfg->{gitcvs}{enabled});
>> +    unless ($enabled && $enabled =~ /^\s*(1|true|yes)\s*$/i) {
>>          print "E GITCVS emulation needs to be enabled on this repo\n";
>>          print "E the repo config file needs a [gitcvs] section added, and the parameter 'enabled' set to 1\n";
>>          print "E \n";
>
> Yeah, should probably have fixed that myself before sending, but the
> other patches were already prepared ;)

Ok, so that's an Ack?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] t9400: Add test cases for config file handling
  2007-05-21 16:38     ` Junio C Hamano
@ 2007-05-21 17:31       ` Frank Lichtenheld
  0 siblings, 0 replies; 7+ messages in thread
From: Frank Lichtenheld @ 2007-05-21 17:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Martin Langhoff

On Mon, May 21, 2007 at 09:38:49AM -0700, Junio C Hamano wrote:
> Frank Lichtenheld <frank@lichtenheld.de> writes:
> > Yeah, should probably have fixed that myself before sending, but the
> > other patches were already prepared ;)
> 
> Ok, so that's an Ack?

Yes.

Gruesse,
-- 
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-05-21 17:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-20 22:31 [PATCH 1/3] t9400: Add test cases for config file handling Frank Lichtenheld
2007-05-20 22:31 ` [PATCH 2/3] t9400: Add some more cvs update tests Frank Lichtenheld
2007-05-20 22:31   ` [PATCH 3/3] t9400: Add some basic pserver tests Frank Lichtenheld
2007-05-21  0:57 ` [PATCH 1/3] t9400: Add test cases for config file handling Junio C Hamano
2007-05-21 16:31   ` Frank Lichtenheld
2007-05-21 16:38     ` Junio C Hamano
2007-05-21 17:31       ` Frank Lichtenheld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).