[Scons-users] HOWTO model a test suite using SCons
Carnë Draug
carandraug+dev at gmail.com
Fri Jan 1 15:18:15 EST 2016
On 31 December 2015 at 22:56, Stefan Seefeld <stefan at seefeld.name> wrote:
> Hello,
>
> I'd like to drive a test suite run with SCons, and I wonder whether
> there already is prior art for this.
> In particular, I'd like to invoke the test suite as a single target,
> such that all the tests contained in it are executed, and at the end a
> summary (number of passed / failed tests, names of failed tests) is
> printed. I'm not quite sure how to achieve this.
> Any suggestions ?
>
On my current project I have several perl modules and a test suite
for each of them. The relevant perl details are that each test is
a .t file (a perl script) in t/.
## TARGET check
##
## Only runs if specified from command line.
if "check" in COMMAND_LINE_TARGETS:
test_suite = []
for test_file in env.Glob("t/*.t"):
unit = env.PerlScript(source=test_file, target=None, action=[])
test_suite.append(unit)
check = Alias ("check", [test_suite])
Note how target is None (it doesn't generate any file). It simply executes
those test scripts (they are just perl scripts). The PerlScript is a
builder I wrote but shouldn't be too different from calling:
env.Command(source=test_file, target=None, action='perl PERLFLAGS $SOURCES')
The displayed output is what comes out of the tests, and it's like this
$ scons check
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
$ perl '-Ilib-perl5' 't/CanonicalHistoneGene.t'
ok 1 - retrieval of UID
ok 2 - retrieval of gene type
ok 3 - retrieval of gene symbol
[...]
1..12
$ perl '-Ilib-perl5' 't/Gene.t'
ok 1 - retrieval of UID
ok 2 - retrieval of gene symbol
[...]
ok 37 - Fails with an empty transcript
1..37
$ perl '-Ilib-perl5' 't/HistoneCatalogue.t'
[...]
scons: done building targets.
which seems to match what you're looking for.
Carnë
More information about the Scons-users
mailing list