[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-16 00:18:45 CET

On 15 Nov 2001 08:52:17 -0600
cmpilato@collab.net wrote:

> Mo DeJong <supermo@bayarea.net> writes:
> > 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.
> Okay, so I'm probably not the best person to be reviewing this patch,
> but I'll give it a shot. Forgive me for doing more asking than
> telling.
> > * 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.
> Log message is fine, but you didn't update_tests.py. And since you
> had to learn Python for this change, it would be a tragedy not to
> mention the one place you used your newfound skillz. :-)

My mistake.

    * subversion/tests/clients/cmdline/update_tests.py:
    Pull in the relative srcdir from a file named srcdir
    before reading a png file.

> > -### 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" ; \
> Is it intentional that the old code calls grep with '\.py' and the new
> one uses '\\.py$$' ? I understand the '$$' portion (matching
> end-of-line, yes?), it's the additional '\' I'm not sure of. Teach me
> what the difference is here.

First, assume that the following is saved in "Makefile":

        @files='ls *'; for file in $$files; do \
        if echo $$file | grep \.py > /dev/null; then \
            echo "Matched $$file" ;\
        fi ; \
        done ;

        @files='ls *'; for file in $$files; do \
        if echo $$file | grep \\.py$$ > /dev/null; then \
            echo "Matched $$file" ;\
        fi ; \
        done ;

Then run:

% touch foo.py
% touch foo_py
% touch foo_python
% touch foo.python

% ls *.py

% make bad
Matched foo.py
Matched foo.python
Matched foo_py
Matched foo_python

% make good
Matched foo.py

This demonstrates that that "\\." is needed so that "\."
makes it to grep. Without the escape the . char would match
any char and a file ending in _py would also match. The
same thing goes for $$, it passed $ to grep but needs to
be escaped with an extra $ so that Make does not hose it.

> From here on out, it looks okay, save for one final concern. You have
> basically rendered useless both XML tests and update_tests.py unless
> someone has previously run 'make check'. To verify this concern, I
> applied you patch, did NOT run 'make check', and got this when I ran
> update_tests.py:
> ~/projects/subversion/subversion/tests/clients/cmdline % ./update_tests.py

It is not a matter of running "make check" before. One simply needs to create a
file named "srcdir" in the current dir before running the test. This file is created
and removed from the build dir by the "make check" rule.

echo . > srcdir

If this really matters to you, then the code could easily be changed to default
to "." if no srcdir file exists. It does not matter to me since I would not
build or run anything in the srcdir, so I am forced to use "make check".
I am not really clear on how just one test or a set of named tests could
be run from the command line via "make check" so this has not really come up.

> Now, I dunno. Maybe it's fair to ask that before someone runs our
> tests individually, he/she/it must have run 'make check' first. But
> it feels wrong to me.
> Now, perhaps if these little 'srcdir' turds were being dropped
> sometime earlier, like during the ./configure step or some other time
> prior to building the source code itself, that wouldn't be so bad.

Well, these srcdir files only live in the build directory so I can't really
see a downside to having them sitting around. The current rule removes
them but you could just as well create them at ./configure time and
just leave them there. If you build inside the srcdir then they would seem
like "extra" files and would show up in a `svn update` and that might
bother folks.


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.