[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-09-15 20:43:26 CEST

On Sat, 15 Sep 2001 02:54:45 -0700
Greg Stein <gstein@lyra.org> wrote:

> On Fri, Sep 14, 2001 at 05:12:56PM -0700, Mo DeJong wrote:
> > Hi all.
> >
> > I tried to run the automated test cases in a builddir that is not the srcdir
> > and hit a wall. Some of the test case shell scripts are written to assume
> > that the builddir is the same as the srcdir. In addition, there are some
> > really nasty chmod hacks in the toplevel Makefile that don't work.
> > How should we fix this? There are a couple of approaches we could try.
> >
> > 1. Leave the .sh scripts in the srcdir and pass in the builddir.
> > 2. Copy the .sh scripts into the builddir and pass in the srcdir.
> > 3. Do some cute trick like storing the srcdir or builddir in a file
> > that the scripts know how to access with a relative path.
> >
> > I took a quick hack at option #2 minus the changes to the actual .sh
> > files. Does this look reasonable to folks?
>
> I don't think we should be needlessly copying things around.
>
> IMO, we should always pass in the source directory to the scripts/programs.
> It was doing that at one point, but Ben ripped it out. He didn't like some
> part of parsing the cmdline args, if I recall correctly.
>
> The builddir should always be the cwd. That is what the "cd" is in there
> for.
>
> Granted, maybe it is buggy :-) ... but the idea of copying stuff around just
> to deal with this feels wonky.
>
> Cheers,
> -g

Ok, how does this strike folks? A file named srcdir is created in the builddir
while the test is being run. A .sh script that needs to pull in other files from
the srcdir can use this path to find its helper file. No files are copied and
that nasty chmod +x stuff is history. With this patch, I was able to run
the tests from the build dir with one exception. The Python tests just
print [SKIPPED], me thinks this is because the svntest module does
not load. I am no python expert so if someone else could take a look
at that problem it would really help.

cheers
Mo DeJong

2001-09-15 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.
        Add Makefile rule so that the generated Makefile is
        automatically regenerated when Makefile.in changes.
        * 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 Mon Sep 10 09:49:53 2001
+++ Makefile.in Sat Sep 15 11:21:15 2001
@@ -104,24 +104,27 @@
 
 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 -n "Running all tests in $$progbase ..." ; \
             echo "START: $$progbase" >> $$logfile ; \
- if echo $$prog | grep \.py > /dev/null; then \
- runprog="$(PYTHON) $$progbase" ; \
- else \
- runprog="./$$progbase" ; \
+ 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 ( cd $$progdir && $$runprog ) >> $$logfile ; then \
+ if ( cd $$progdir && echo $(top_srcdir)/$$progdir > srcdir && \
+ $$runprog && rm srcdir ) >> $$logfile ; then \
                 echo "SUCCESS" ; \
             else \
                 failed=yes; \
@@ -134,6 +137,9 @@
         if test "$$failed" = "yes"; then \
             grep FAIL $$logfile || /bin/true ; \
         fi
+
+Makefile: $(top_srcdir)/Makefile.in
+ $(SHELL) config.status
 
 mkdir-init:
         @list='$(BUILD_DIRS) $(DOC_DIRS)'; for i in $$list doc; do \
Index: subversion/tests/clients/cmdline/xmltests/svn-test.sh
===================================================================
--- subversion/tests/clients/cmdline/xmltests/SVN/text-base/svn-test.sh Mon Sep 10 09:50:30 2001
+++ subversion/tests/clients/cmdline/xmltests/svn-test.sh Sat Sep 15 11:04:06 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 Mon Sep 10 09:50:30 2001
+++ subversion/tests/clients/cmdline/xmltests/svn-test2.sh Sat Sep 15 11:02:34 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
 

---------------------------------------------------------------------
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:41 2006

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.