automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tests in subdirectories


From: Bob Friesenhahn
Subject: tests in subdirectories
Date: Fri, 10 Sep 2004 15:13:29 -0500 (CDT)

I spent quite a bit of time this past weekend getting the tests used by my project's non-recursive build to pass 'make distcheck'. The problem is that tests are in subdirectories, are expected to write any output into the subdirectory under the build directory associated with the test, and access input files located in the same source directory where the test script is located. This seems to be a quite common scenario, particularly for projects converted from a recursive build, or ones that just like to be tidy.

The hacks I am currently using are entirely outside of Automake. Once the issues are fully understood and agreed to, it would be nice to see some support make it into Automake, perhaps triggered by an Automake option (e.g. subdir-tests).

There are a number of things that Automake can do to help "traditional" script-based tests:

 1) Ensure that the definition of $srcdir is well-rooted so that it
    is still useful after a directory change.  A path like "." is
    nice and short but not very helpful.
 2) Provide another variable which is a well-rooted path to the
    directory where the test script (or source to the test
    program if the test is compiled) resides.  $srcdir could be
    used if it reflects the path to where the script or program
    source resides.  If $srcdir is used, then it is possible
    for existing test scripts to not need to be altered at all.
 3) Automatically change directory to the appropriate subdirectory
    under the build tree so that the script doesn't need to do its
    own directory change.

As an example, this is what I did to implement tests in a subdirectory called 'tests'. The tests subdirectory contains a script named common.shi which is included first into all test scripts in order to make sense of things.

========= Fragment (common.shi) included into all Test scripts
SRCDIR=`dirname $0`
SRCDIR=`cd $SRCDIR && pwd`
TOPSRCDIR=`cd $srcdir && pwd`
cd tests || exit 1

========= Test script:
# Copyright (C) 2004 GraphicsMagick Group
#
# This program is covered by multiple licenses, which are described in
# Copyright.txt. You should have received a copy of Copyright.txt with this # package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.

. ${srcdir}/tests/common.shi
${RUNENV} ${MEMCHECK} ./rwfile ${SRCDIR}/input_pallette.miff GIF

In the above, ${RUNENV} and ${MEMCHECK} are environment variables passed down from the Makefile to the tests.

Thoughts?

Bob
======================================
Bob Friesenhahn
address@hidden
http://www.simplesystems.org/users/bfriesen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]