Boost logo

Boost Users :

From: Helge Penne (penne_at_[hidden])
Date: 2002-02-26 03:39:47


Hi. I'm working on a project where some of the unit test are very
inconvenient to implement with CppUnit and Mock classes or stubs alone,
but would be very simple to implement by having them print messages to
standard output, pipe this to a log file and diff this against a
reference file.

I added the following to our Jamrules file (most of it is stolen from
the standard unit-test rule and run action):

rule unit-test-diff
{
    local files = [ exe $(<) : $(2) : $(3) : $(4) : EXE ] ;
    type-DEPENDS test : $(files) ;
    local file ;

    for file in $(files)
    {
        run-and-diff $(file) ;
    }
}

actions run-and-diff
{
    $(SHELL_SET)PATH=$(RUN_PATH)
    $(SHELL_EXPORT)PATH

    $(<) > $(<:D=:S=.log)
    diff $(<:S=.log) $(<:S=.ref)
# diff $(<:D=:S=.log) $(<:D=:S=.ref)
}

This runs the unit test program, pipes the output to <targetname>.log
and
diffs agains <targetname>.ref. There is only one problem: I cannot get
Boost.build to locate these files in the correct folder.

The Jamfile for the unit test is located in the same folder as the unit
test source code. This is the only natural place for the ref-file as
well.

The action above has three different alternatives for the actual diff
operation. The first uses the full path of the executable, but replaces

the last part of the file name with .log and .ref. This places them in
the binary folder of the unit test program, which isn't not very
convenient.

The second strips away the path, but since the currect folder always is
the project root (not the folder where the Jamfile is), this places the
log and ref files on the project root, which is almost as bad as the
first alternative. I also experimented briefly with :G but this has no
effect as the file path did not seem to contain grist. One possible
solution might be to add a path feature to the target and set this to
the reference file name, but I'm not quite sure how to implement this
for rules that are not part of a tools.jam-file

I really need the unit test rule to place these files in the folder
where the rest of the test source code is. Does anyone know how to do
this?

- Helge Penne


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net