[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Test cases broken when builddir != srcdir

From: Mo DeJong <supermo_at_bayarea.net>
Date: 2001-11-14 05:47:06 CET

Here is a repost of the patch I wrote to fix running of test cases in
a build dir that is not the src dir. This patch has been floating around
for a couple of months now. If there is something wrong that
is keeping that patch from being committed could someone say something?
I had to learn Python to write this patch so I don't want it to go
to waste.

thanks
Mo

2001-11-13 Mo DeJong <supermo@bayarea.net>

        Fix make check when srcdir != builddr.

        * Makefile.in:
        Remove nasty chmod +x hack. Run .py and .sh scripts
        out of the srcdir. Save the relative srcdir in a
        file named srcdir while test is running. Programs can
        use this fully qualified path to find needed files
        in the srcdir.
        * subversion/tests/clients/cmdline/xmltests/svn-test.sh:
        * subversion/tests/clients/cmdline/xmltests/svn-test2.sh:
        Pull in the relative srcdir from a file named srcdir
        when setting the path to XML test files.

Index: ./Makefile.in
===================================================================
--- ./.svn/text-base/Makefile.in Tue Nov 6 14:12:43 2001
+++ ./Makefile.in Tue Nov 6 14:12:43 2001
@@ -110,34 +110,40 @@
 
 local-install: @INSTALL_RULES@
 
-### the chmod really sucks, but some repository files don't have it like
-### they should ...
 check: $(TEST_DEPS) @FS_TEST_DEPS@
         @logfile=`pwd`/tests.log ; \
         echo > $$logfile ; \
         failed=no ; \
         list='$(TEST_PROGRAMS) @FS_TEST_PROGRAMS@'; for prog in $$list; do \
- chmod a+x $$prog ; \
             progbase=`echo $$prog | sed 's?.*/??'` ; \
             progdir=`echo $$prog | sed 's?/[^/]*$$??'` ; \
             echo -n "Running all tests in $$progbase..." ; \
             echo "START: $$progbase" >> $$logfile ; \
- if echo $$prog | grep \.py > /dev/null; then \
- runprog="$(PYTHON) $$progbase" ; \
- else \
+ if echo $$progbase | grep \\.py$$ > /dev/null; then \
+ runprog="$(PYTHON) $(top_srcdir)/$$prog" ; \
+ elif echo $$progbase | grep \\.sh$$ > /dev/null; then \
+ runprog="$(SHELL) $(top_srcdir)/$$prog" ; \
+ elif test -x $$prog ; then \
                 runprog="./$$progbase" ; \
+ else \
+ echo "Don't know what to do about $$progbase" ; \
+ exit 1 ; \
+ fi ; \
+ if test ! -d $$progdir ; then \
+ $(MKDIR) $$progdir > /dev/null 2>&1 ; \
             fi ; \
- if ( cd $$progdir && $$runprog ) >> $$logfile ; then \
+ if ( cd $$progdir && echo $(top_srcdir)/$$progdir > srcdir && \
+ $$runprog && rm srcdir ) >> $$logfile 2>&1 ; then \
                 echo "SUCCESS" ; \
             else \
                 failed=yes; \
                 echo "FAILED" ; \
- echo "--- at least one test FAILED, check tests.log." ; \
             fi; \
             echo "END: $$progbase" >> $$logfile ; \
             echo >> $$logfile ; \
         done ; \
         if test "$$failed" = "yes"; then \
+ echo "at least one test FAILED, checking tests.log." ; \
             grep FAIL $$logfile || true ; \
         fi
 
Index: ./subversion/tests/clients/cmdline/xmltests/svn-test.sh
===================================================================
--- ./subversion/tests/clients/cmdline/xmltests/.svn/text-base/svn-test.sh Thu Oct 25 16:01:37 2001
+++ ./subversion/tests/clients/cmdline/xmltests/svn-test.sh Thu Oct 25 16:29:28 2001
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 SVN_PROG=../../../../clients/cmdline/svn
-XML_DIR=../../../xml
+XML_DIR=`cat srcdir`/../../../xml
 TEST_DIR_1=t1
 TEST_DIR_2=t2
 COMMIT_RESULTFILE_NAME=commit
Index: ./subversion/tests/clients/cmdline/xmltests/svn-test2.sh
===================================================================
--- ./subversion/tests/clients/cmdline/xmltests/.svn/text-base/svn-test2.sh Thu Oct 25 16:01:37 2001
+++ ./subversion/tests/clients/cmdline/xmltests/svn-test2.sh Thu Oct 25 16:29:28 2001
@@ -3,7 +3,7 @@
 # Testing merging and conflict resolution.
 
 SVN_PROG=../../../../clients/cmdline/svn
-XML_DIR=../../../xml
+XML_DIR=`cat srcdir`/../../../xml
 TEST_DIR_1=t1
 TEST_DIR_2=t2
 COMMIT_RESULTFILE_NAME=commit2
@@ -38,14 +38,14 @@
 ### Give t1/iota some file-properties via update.
 echo "Updating t1/iota with properties. (up2.xml)"
 (cd ${TEST_DIR_1}; \
- ../${SVN_PROG} update --xml-file ../$XML_DIR/up2.xml --revision 17)
+ ../${SVN_PROG} update --xml-file $XML_DIR/up2.xml --revision 17)
 
 check_status 2
 
 ### Give t1/A some dir-properties via update.
 echo "Updating t1/A/ with properties. (up5.xml)"
 (cd ${TEST_DIR_1}; \
- ../${SVN_PROG} update --xml-file ../$XML_DIR/up5.xml --revision 18)
+ ../${SVN_PROG} update --xml-file $XML_DIR/up5.xml --revision 18)
 
 check_status 3
 
@@ -91,14 +91,14 @@
 ### Update again. This update should create conflicting properties.
 echo "Updating with (conflicting) properties. (up-props.xml)"
 (cd ${TEST_DIR_1}; \
- ../${SVN_PROG} update --xml-file ../$XML_DIR/up-props.xml --revision 20)
+ ../${SVN_PROG} update --xml-file $XML_DIR/up-props.xml --revision 20)
 
 check_status 9
 
 ### Update again. This update should create conflicting text.
 echo "Updating with (conflicting) text. (pipatch.xml)"
 (cd ${TEST_DIR_1}; \
- ../${SVN_PROG} update --xml-file ../$XML_DIR/pipatch.xml --revision 21)
+ ../${SVN_PROG} update --xml-file $XML_DIR/pipatch.xml --revision 21)
 
 check_status 10
 
Index: ./subversion/tests/clients/cmdline/update_tests.py
===================================================================
--- ./subversion/tests/clients/cmdline/.svn/text-base/update_tests.py Thu Oct 25 16:01:31 2001
+++ ./subversion/tests/clients/cmdline/update_tests.py Thu Oct 25 16:29:28 2001
@@ -86,8 +86,14 @@
   if svntest.actions.make_repo_and_wc(sbox):
     return 1
 
- # Add a binary file to the project.
- fp = open("theta.png")
+ # Add a binary file to the project from the srcdir.
+ fp = open("srcdir")
+ srcdir = fp.readline()
+ fp.close()
+ # Strip \n off end since it hoses os.path.join()
+ srcdir = string.rstrip(srcdir)
+ theta_path = os.path.join(srcdir, 'theta.png')
+ fp = open(theta_path)
   theta_contents = fp.read() # suck up contents of a test .png file
   fp.close()
 
@@ -215,8 +221,14 @@
     return 1
 
   # Suck up contents of a test .png file.
- fp = open("theta.png")
- theta_contents = fp.read()
+ fp = open("srcdir")
+ srcdir = fp.readline()
+ fp.close()
+ # Strip \n off end since it hoses os.path.join()
+ srcdir = string.rstrip(srcdir)
+ theta_path = os.path.join(srcdir, 'theta.png')
+ fp = open(theta_path)
+ theta_contents = fp.read()
   fp.close()
 
   # 102400 is svn_txdelta_window_size. We're going to make sure we

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:48 2006

This is an archived mail posted to the Subversion Dev mailing list.