Subject: | suggest =for conditionalized synopsis check |
Date: | Thu, 18 Feb 2010 09:37:55 +1100 |
To: | bug-Test-Synopsis [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
I've got a few modules where the synopsis code will only compile under
certain conditions, such as when an optional extra module is available,
or when an X windows display is available.
As an idea for a feature, it'd be good if there was a way to express the
condition in an "=for test_synopsis", so that checking of such modules
could be skipped under certain conditions.
I thought maybe something like
=for test_synopsis BEGIN { if ('some condition') { die 'Test::Synopsis skip: my explanation here' } }
and have Test::Synopsis watch for $@ starting like that to do a test
skip() thingie, with the explanation, instead of an ok() check.
I wondered alternatively if a BEGIN block could do a return() to stop
the compile, but that doesn't work and I suppose wouldn't communicate a
reason for the skipped test.
(Of course files can be skipped in the .t script, but if the condition
is in the .pm file it's just one place to maintain and will still work
if the .pm is copied around etc.)