[Scons-users] HOWTO model a test suite using SCons

William Blevins wblevins001 at gmail.com
Sun Jan 3 10:52:57 EST 2016


On Sun, Jan 3, 2016 at 7:00 AM, Stefan Seefeld <stefan at seefeld.name> wrote:

> Hi,
>
> thanks all for the helpful replies.
>
> On 01.01.2016 15:12, William Blevins wrote:
> > Stefan,
> >
> > I have always used something simple
> > like https://bitbucket.org/scons/scons/wiki/UnitTests
> >
> > I just compile my test suite and create a target for running the
> > suite. Obviously passing parameters to the suite via commandline is
> > hard, but depending on the scale of the tests, that is usually
> > irrelevant. You can of course make a whole pipeline using SCons
> > targets which may include piping the test outputs to a file and using
> > that file as a target to a document generator, etc.
>
> Yes, I think this is precisely what I'm looking for: while I already can
> run tests "normally" (even generate some simple output like "PASS" and
> "FAIL"), the output is typically very noisy due to various reasons
> (compiler warnings, say), so I'd like to add a "reporter" that
> post-processes the test results (such as to print a nice summary to
> stdout).
> While I'm able to set things up manually, I would like to find a way to
> do this automatically:
>
> My SConscript file contains a bunch of "Test(...)" declarations (each
> defining a test that produces a specific <name>.result test-result
> file). Is there a way to pre-define a "Report" generator such that all
> the above *.result files are automatically added as sources for it, such
> that when I run `scons test`, it runs all tests, followed by the report
> generator ?
>
> Is this a sensible approach at all ?
>

You can make a Command or Builder for the report generator action:
https://bitbucket.org/scons/scons/wiki/ToolsForFools

Then just pass the output of Test calls (the targets) as sources to the
ReportGenerator builder. This makes all the *.result entries into Nodes and
the output report as a Node which means that SCons will handle all
dependencies when you generate a new report. If done correctly, you should
be able to request SCons to build the report from a clean repo, then SCons
will build all the dependencies (nothing more and nothing less) and give
you a report.

As a rule of thumb, do all tasks as Actions (EG Commands or Builders). Use
SCons power as a DAG tool; this is what SCons does best.

V/R,
William




>
> Thanks,
>         Stefan
>
> --
>
>       ...ich hab' noch einen Koffer in Berlin...
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20160103/a3cae34e/attachment.html>


More information about the Scons-users mailing list