Skip to contentSkip to conversation

cvsserver: Add test cases for config file handling

PATCH/RFC In review Frank Lichtenheld 2 participants 7 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

---
 t/t9420-git-cvsserver-config.sh |  108 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 108 insertions(+), 0 deletions(-)
 create mode 100755 t/t9420-git-cvsserver-config.sh

The RFC part is test 4 (gitcvs.ext.enabled = false). With the current code it fails, with my GITCVS::config patch it succeeds. I think the documentation currently states ('method specific options "override" general options') it should succeed and I guess that would be the more intuitive behaviour. Anyone disagree?

t/t9420-git-cvsserver-config.sh new file +108 -0
new file mode 100755
index 0000000..53550e8
@@ -0,0 +1,108 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Frank Lichtenheld
+#
+
+test_description='git-cvsserver configuration handling
+
+tests the parsing and handling of the git configuration
+by git-cvsserver'
+
+. ./test-lib.sh
+
+cvs >/dev/null 2>&1
+if test $? -ne 1
+then
+    test_expect_success 'skipping git-cvsserver tests, cvs not found' :
+    test_done
+    exit
+fi
+perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
+    test_expect_success 'skipping git-cvsserver tests, Perl SQLite interface unavailable' :
+    test_done
+    exit
+}
+
+unset GIT_DIR GIT_CONFIG
+WORKDIR=$(pwd)
+SERVERDIR=$(pwd)/gitcvs.git
+CVSROOT=":fork:$SERVERDIR"
+CVSWORK=$(pwd)/cvswork
+CVS_SERVER=git-cvsserver
+export CVSROOT CVS_SERVER
+
+rm -rf "$CVSWORK" "$SERVERDIR"
+echo >empty &&
+  git add empty &&
+  git commit -q -m "First Commit" &&
+  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
+
+# note that cvs doesn't accept absolute pathnames
+# as argument to co -d
+test_expect_success 'basic checkout' \
+  'cvs -Q co -d cvswork master &&
+   test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
+
+test_expect_success 'gitcvs.enabled = false' \
+  'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
+   if 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 &&
+   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 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 &&
+   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
+
+# currently fails due to a git-config bug
+#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 &&
+#   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"'
+
+
+test_done
Signature · 1 line
1.5.1.4
#1 lore raw

PATCH 1/1 cvsserver: Add test cases for config file handling

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

---
 t/t9420-git-cvsserver-config.sh |  109 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 109 insertions(+), 0 deletions(-)
 create mode 100755 t/t9420-git-cvsserver-config.sh

Forgot to copy the changes from Junio's GIT_CONFIG fix.

t/t9420-git-cvsserver-config.sh new file +109 -0
new file mode 100755
index 0000000..e65d093
@@ -0,0 +1,109 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Frank Lichtenheld
+#
+
+test_description='git-cvsserver configuration handling
+
+tests the parsing and handling of the git configuration
+by git-cvsserver'
+
+. ./test-lib.sh
+
+cvs >/dev/null 2>&1
+if test $? -ne 1
+then
+    test_expect_success 'skipping git-cvsserver tests, cvs not found' :
+    test_done
+    exit
+fi
+perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
+    test_expect_success 'skipping git-cvsserver tests, Perl SQLite interface unavailable' :
+    test_done
+    exit
+}
+
+unset GIT_DIR GIT_CONFIG
+WORKDIR=$(pwd)
+SERVERDIR=$(pwd)/gitcvs.git
+git_config="$SERVERDIR/config"
+CVSROOT=":fork:$SERVERDIR"
+CVSWORK=$(pwd)/cvswork
+CVS_SERVER=git-cvsserver
+export CVSROOT CVS_SERVER
+
+rm -rf "$CVSWORK" "$SERVERDIR"
+echo >empty &&
+  git add empty &&
+  git commit -q -m "First Commit" &&
+  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
+
+# note that cvs doesn't accept absolute pathnames
+# as argument to co -d
+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/"'
+
+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
+
+# currently fails due to a git-config bug
+#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"'
+
+
+test_done
Signature · 1 line
1.5.1.4
#2 lore raw
Quoted 8 lines · Frank Lichtenheld

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

---
 t/t9420-git-cvsserver-config.sh |  109 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 109 insertions(+), 0 deletions(-)
 create mode 100755 t/t9420-git-cvsserver-config.sh

Do we really need a separate test script that does quite similar setup?

#3 lore raw
Quoted 5 lines · Junio C Hamano
Quoted 3 lines · Frank Lichtenheld

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

Quoted 7 lines
Quoted 5 lines
---
 t/t9420-git-cvsserver-config.sh |  109 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 109 insertions(+), 0 deletions(-)
 create mode 100755 t/t9420-git-cvsserver-config.sh

Do we really need a separate test script that does quite similar setup?

Right now, probably not.

But I certainly don't intend to do all the tests in one big file which will become rather large over time. If you're concerned with code duplication, maybe I should move the code to a separate file and source it from there?

Gruesse,

Signature · 2 lines
Frank Lichtenheld <[email protected]>
www: http://www.djpig.de/
#4 lore raw
Quoted 12 lines · Frank Lichtenheld
Quoted 11 lines · Junio C Hamano
Quoted 8 lines · Frank Lichtenheld

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

---
 t/t9420-git-cvsserver-config.sh |  109 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 109 insertions(+), 0 deletions(-)
 create mode 100755 t/t9420-git-cvsserver-config.sh
Quoted 8 lines
Quoted 1 line

Do we really need a separate test script that does quite similar setup?

Right now, probably not.

But I certainly don't intend to do all the tests in one big file which will become rather large over time. If you're concerned with code duplication, maybe I should move the code to a separate file and source it from there?

Still waiting on a comment here...

Gruesse,

Signature · 2 lines
Frank Lichtenheld <[email protected]>
www: http://www.djpig.de/
#5 lore raw
Quoted 6 lines · Frank Lichtenheld
Quoted 4 lines

But I certainly don't intend to do all the tests in one big file which will become rather large over time. If you're concerned with code duplication, maybe I should move the code to a separate file and source it from there?

Still waiting on a comment here...

Well, It seems that all of our foreign SCM tests tends to be slower than other tests, so I would be happier if a single run of one test covers everything we would want to cover, when I run "make test", rather than having multiple set-up steps that are identical in two different tests. So in that sense, I was not talking about code duplication which can be solved by splitting the duplicated part into a separate file and sourcing it from two scripts -- that is not a solution.

Another thing we would need to decide (with Eric who has the same issue) is how to structure the tests that try daemons. We worked it around by using :fork: for the first cvsserver test, but we would eventually want the real pserver test as well.

#6 lore raw
Quoted 2 lines · Junio C Hamano

Well, It seems that all of our foreign SCM tests tends to be slower than other tests, so I would be happier if a single run

Which only shows that git is so much faster than anything else ;)

Quoted 6 lines

of one test covers everything we would want to cover, when I run "make test", rather than having multiple set-up steps that are identical in two different tests. So in that sense, I was not talking about code duplication which can be solved by splitting the duplicated part into a separate file and sourcing it from two scripts -- that is not a solution.

Ok, thanks for the clarification. I will merge the two test files for now and resubmit.

Gruesse,

Signature · 2 lines
Frank Lichtenheld <[email protected]>
www: http://www.djpig.de/