[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-10-03 04:29:46 CEST

Hi all.

Some time ago, I posted a patch to fix running of the test cases when building
outside the srcdir. The problem with that older patch was that it did not include
fixes for the Python tests. I ended up breaking down and learning a little bit
of Python and finally fixed those too. Here is the new patch.

2001-10-02 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. Create the given directory in the
        builddir if it does not exist. Redirect standard
        error to tests.log file so that python stack traces
        appear in the log if something goes wrong. Print
        warning about a failed test after all of the test
        have been run.
        * 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.
        * subversion/tests/clients/cmdline/update_tests.py:
        Pull in the relative srcdir from a file named srcdir
        before reading a png file.

Index: ./Makefile.in
===================================================================
--- ./SVN/text-base/Makefile.in Thu Sep 27 13:10:12 2001
+++ ./Makefile.in Tue Oct 2 13:27:13 2001
@@ -104,34 +104,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 Sep 27 13:12:45 2001
+++ ./subversion/tests/clients/cmdline/xmltests/svn-test.sh Tue Oct 2 13:50:19 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 Sep 27 13:12:45 2001
+++ ./subversion/tests/clients/cmdline/xmltests/svn-test2.sh Tue Oct 2 13:51:13 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 Tue Oct 2 12:14:39 2001
+++ ./subversion/tests/clients/cmdline/update_tests.py Tue Oct 2 14:40:04 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:44 2006

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