{"thread":{"id":"7897","subject":"[PATCH/RFC] git-cvsserver: Add a basic test file for cvsserver","startedAt":"2007-04-29T20:10:27Z","lastAt":"2007-05-02T00:45:22Z","messageCount":4,"participants":["Frank Lichtenheld","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"40711","messageId":"11778774271937-git-send-email-frank@lichtenheld.de","threadId":"7897","inReplyTo":null,"subject":"[PATCH/RFC] git-cvsserver: Add a basic test file for cvsserver","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2007-04-29T20:10:27Z","receivedAt":"2007-04-29T20:10:27Z","isPatch":true,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"Contains only one test (checkout) at this point and is\nmostly indented to be used as a RFC to discuss\nhow to properly implement tests for git-cvsserver.\n\nCurrently the test uses netcat to run git-cvsserver\npserver on a unprivilegded port.\n\nSigned-off-by: Frank Lichtenheld <frank@lichtenheld.de>\n---\n t/t9400-git-cvsserver-read.sh |   56 +++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 56 insertions(+), 0 deletions(-)\n create mode 100644 t/t9400-git-cvsserver-read.sh\n\n Since this is my first test script for git I would welcome comments\n and suggestions. Especially if someone has a simpler method of\n testing it than the somewhat fragile netcat hack I used.\n\ndiff --git a/t/t9400-git-cvsserver-read.sh b/t/t9400-git-cvsserver-read.sh\nnew file mode 100644\nindex 0000000..311d6c5\n--- /dev/null\n+++ b/t/t9400-git-cvsserver-read.sh\n@@ -0,0 +1,56 @@\n+#!/bin/sh\n+# \n+# Copyright (c) 2007 Frank Lichtenheld\n+#\n+\n+test_description='git-cvsserver read access\n+\n+tests read access to a git repository with the\n+cvs CLI client via git-cvsserver pserver'\n+\n+. ./test-lib.sh\n+\n+cvs >/dev/null 2>&1\n+if test $? -ne 1\n+then\n+    test_expect_success 'skipping git-cvsserver tests, cvs not found' :\n+    test_done\n+    exit\n+fi\n+netcat -h >/dev/null 2>&1\n+if test $? -ne 1\n+then\n+    test_expect_success 'skipping git-cvsserver tests, netcat not found' :\n+    test_done\n+    exit\n+fi\n+\n+unset GIT_DIR GIT_CONFIG\n+WORKDIR=$(pwd)\n+SERVERDIR=$(pwd)/gitcvs.git\n+CVSROOT=\":pserver:anonymous@localhost:12345$SERVERDIR\"\n+CVSWORK=$(pwd)/cvswork\n+export CVSROOT CVSWORK\n+\n+rm -rf \"$CVSWORK\" \"$SERVERDIR\"\n+echo >empty &&\n+  git add empty &&\n+  git commit -q -m \"First Commit\" &&\n+  git clone -q --local --bare \"$WORKDIR/.git\" \"$SERVERDIR\" >/dev/null 2>&1 &&\n+  GIT_DIR=\"$SERVERDIR\" git config --bool gitcvs.enabled true ||\n+  exit 1\n+\n+start_pserver () {\n+   netcat -l -p 12345 -c \"git-cvsserver pserver\" localhost &\n+   echo $! >nc.pid\n+}\n+start_pserver\n+\n+# note that cvs doesn't accept absolute pathnames\n+# as argument to co -d\n+test_expect_success 'basic checkout' \\\n+  \"cvs -Q co -d cvswork master\"\n+\n+kill $(cat nc.pid) 2>/dev/null\n+\n+test_done\n-- \n1.5.1.2\n"},{"id":"40805","messageId":"7vfy6h7wsb.fsf@assigned-by-dhcp.cox.net","threadId":"7897","inReplyTo":"11778774271937-git-send-email-frank@lichtenheld.de","subject":"Re: [PATCH/RFC] git-cvsserver: Add a basic test file for cvsserver","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-01T08:50:12Z","receivedAt":"2007-05-01T08:50:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Frank Lichtenheld <frank@lichtenheld.de> writes:\n\n> Contains only one test (checkout) at this point and is\n> mostly indented to be used as a RFC to discuss\n> how to properly implement tests for git-cvsserver.\n>\n> Currently the test uses netcat to run git-cvsserver\n> pserver on a unprivilegded port.\n>\n> Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>\n> ---\n>  t/t9400-git-cvsserver-read.sh |   56 +++++++++++++++++++++++++++++++++++++++++\n>  1 files changed, 56 insertions(+), 0 deletions(-)\n>  create mode 100644 t/t9400-git-cvsserver-read.sh\n>\n>  Since this is my first test script for git I would welcome comments\n>  and suggestions. Especially if someone has a simpler method of\n>  testing it than the somewhat fragile netcat hack I used.\n\nYes, before reading this three-line paragraph, use of netcat and\nhardcoded port number made my eyebrows raise.\n\nBut a git-cvsserver test suite that can be run from \"make test\"\nis a really good thing to have for us.\n\nI haven't pursued this but have you considered :fork: connect\nmethod instead of :ext:, so that you do not have to use pserver\nnor ssh connection?\n"},{"id":"40818","messageId":"20070501112943.GP7085@planck.djpig.de","threadId":"7897","inReplyTo":"7vfy6h7wsb.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH/RFC] git-cvsserver: Add a basic test file for cvsserver","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2007-05-01T11:29:43Z","receivedAt":"2007-05-01T11:29:43Z","isPatch":true,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"On Tue, May 01, 2007 at 01:50:12AM -0700, Junio C Hamano wrote:\n> But a git-cvsserver test suite that can be run from \"make test\"\n> is a really good thing to have for us.\n> \n> I haven't pursued this but have you considered :fork: connect\n> method instead of :ext:, so that you do not have to use pserver\n> nor ssh connection?\n\nOk, I have to confess I never heard of :fork: before :| (or forgot about\nit again)\nThanks for the tip...\n\nGruesse,\n-- \nFrank Lichtenheld <frank@lichtenheld.de>\nwww: http://www.djpig.de/\n"},{"id":"40876","messageId":"1178066722390-git-send-email-frank@lichtenheld.de","threadId":"7897","inReplyTo":"7vfy6h7wsb.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] cvsserver: Add test cases for git-cvsserver","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2007-05-02T00:45:22Z","receivedAt":"2007-05-02T00:45:22Z","isPatch":true,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"Use the :fork: access method to force cvs to\ncall \"$CVS_SERVER server\" even when accessing a local\nrepository.\n\nAdd a basic test for checkout and some tests for update.\n\nSigned-off-by: Frank Lichtenheld <frank@lichtenheld.de>\n---\n t/t9400-git-cvsserver-server.sh |  120 +++++++++++++++++++++++++++++++++++++++\n 1 files changed, 120 insertions(+), 0 deletions(-)\n create mode 100644 t/t9400-git-cvsserver-server.sh\n\n Still my first test cases so careful review and comments\n on style and implementation would be very welcome :)\n\ndiff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh\nnew file mode 100644\nindex 0000000..19b504b\n--- /dev/null\n+++ b/t/t9400-git-cvsserver-server.sh\n@@ -0,0 +1,120 @@\n+#!/bin/sh\n+# \n+# Copyright (c) 2007 Frank Lichtenheld\n+#\n+\n+test_description='git-cvsserver access\n+\n+tests read access to a git repository with the\n+cvs CLI client via git-cvsserver server'\n+\n+. ./test-lib.sh\n+\n+cvs >/dev/null 2>&1\n+if test $? -ne 1\n+then\n+    test_expect_success 'skipping git-cvsserver tests, cvs not found' :\n+    test_done\n+    exit\n+fi\n+\n+unset GIT_DIR GIT_CONFIG\n+WORKDIR=$(pwd)\n+SERVERDIR=$(pwd)/gitcvs.git\n+CVSROOT=\":fork:$SERVERDIR\"\n+CVSWORK=$(pwd)/cvswork\n+CVS_SERVER=git-cvsserver\n+export CVSROOT CVS_SERVER\n+\n+rm -rf \"$CVSWORK\" \"$SERVERDIR\"\n+echo >empty &&\n+  git add empty &&\n+  git commit -q -m \"First Commit\" &&\n+  git clone -q --local --bare \"$WORKDIR/.git\" \"$SERVERDIR\" >/dev/null 2>&1 &&\n+  GIT_DIR=\"$SERVERDIR\" git config --bool gitcvs.enabled true &&\n+  GIT_DIR=\"$SERVERDIR\" git config --bool gitcvs.logfile \"$SERVERDIR/gitcvs.log\" ||\n+  exit 1\n+\n+# note that cvs doesn't accept absolute pathnames\n+# as argument to co -d\n+test_expect_success 'basic checkout' \\\n+  'cvs -Q co -d cvswork master &&\n+   test \"$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))\" = \"empty/1.1/\"'\n+\n+test_expect_success 'cvs update (create new file)' \\\n+  'echo testfile1 >testfile1 &&\n+   git add testfile1 &&\n+   git commit -q -m \"Add testfile1\" &&\n+   git push gitcvs.git >/dev/null &&\n+   cd cvswork &&\n+   cvs -Q update &&\n+   test \"$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))\" = \"testfile1/1.1/\" &&\n+   diff -q testfile1 ../testfile1'\n+\n+cd \"$WORKDIR\"\n+test_expect_success 'cvs update (update existing file)' \\\n+  'echo line 2 >>testfile1 &&\n+   git add testfile1 &&\n+   git commit -q -m \"Append to testfile1\" &&\n+   git push gitcvs.git >/dev/null &&\n+   cd cvswork &&\n+   cvs -Q update &&\n+   test \"$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))\" = \"testfile1/1.2/\" &&\n+   diff -q testfile1 ../testfile1'\n+\n+cd \"$WORKDIR\"\n+#TODO: cvsserver doesn't support update w/o -d\n+test_expect_failure \"cvs update w/o -d doesn't create subdir (TODO)\" \\\n+  'mkdir test &&\n+   echo >test/empty &&\n+   git add test &&\n+   git commit -q -m \"Single Subdirectory\" &&\n+   git push gitcvs.git >/dev/null &&\n+   cd cvswork &&\n+   cvs -Q update &&\n+   test ! -d test'\n+\n+cd \"$WORKDIR\"\n+test_expect_success 'cvs update (subdirectories)' \\\n+  '(for dir in A A/B A/B/C A/D E; do\n+      mkdir $dir &&\n+      echo \"test file in $dir\" >\"$dir/file_in_$(echo $dir|sed -e \"s#/# #g\")\"  &&\n+      git add $dir;\n+   done) && \n+   git commit -q -m \"deep sub directory structure\" &&\n+   git push gitcvs.git >/dev/null &&\n+   cd cvswork &&\n+   cvs -Q update -d &&\n+   (for dir in A A/B A/B/C A/D E; do\n+      filename=\"file_in_$(echo $dir|sed -e \"s#/# #g\")\" &&\n+      if test \"$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))\" = \"$filename/1.1/\" &&\n+           diff -q \"$dir/$filename\" \"../$dir/$filename\"; then\n+        :\n+      else\n+        echo >failure\n+      fi\n+    done) &&\n+   test ! -f failure'\n+\n+cd \"$WORKDIR\"\n+test_expect_success 'cvs update (delete file)' \\\n+  'git rm testfile1 &&\n+   git commit -q -m \"Remove testfile1\" &&\n+   git push gitcvs.git >/dev/null &&\n+   cd cvswork &&\n+   cvs -Q update &&\n+   test -z \"$(grep testfile1 CVS/Entries)\" &&\n+   test ! -f testfile1'\n+\n+cd \"$WORKDIR\"\n+test_expect_success 'cvs update (re-add deleted file)' \\\n+  'echo readded testfile >testfile1 &&\n+   git add testfile1 &&\n+   git commit -q -m \"Re-Add testfile1\" &&\n+   git push gitcvs.git >/dev/null &&\n+   cd cvswork &&\n+   cvs -Q update &&\n+   test \"$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))\" = \"testfile1/1.4/\" &&\n+   diff -q testfile1 ../testfile1'\n+\n+test_done\n-- \n1.5.1.2\n"}]}