| 1 |
NAME |
| 2 |
Test::NeedsDisplay - Ensure that tests needing a display have one |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
In your Makefile.PL... |
| 6 |
|
| 7 |
use inc::Module::Install; |
| 8 |
# ... or whatever else you use |
| 9 |
|
| 10 |
# Check for a display |
| 11 |
use Test::NeedsDisplay; |
| 12 |
|
| 13 |
# ... your Makefile.PL content as normal |
| 14 |
|
| 15 |
And again in each test script that loads Wx |
| 16 |
|
| 17 |
#!/usr/bin/perl |
| 18 |
|
| 19 |
use strict; |
| 20 |
|
| 21 |
use Test::NeedsDisplay; |
| 22 |
|
| 23 |
# Test content as normal... |
| 24 |
|
| 25 |
DESCRIPTION |
| 26 |
When testing GUI applications, sometimes applications or modules |
| 27 |
absolutely insist on a display, even just to load a module without |
| 28 |
actually showing any objects. |
| 29 |
|
| 30 |
Regardless, this makes GUI applications pretty much impossible to build |
| 31 |
and test on headless or automated systems. And it fails to the point of |
| 32 |
not even running the Makefile.PL script because a dependency needs a |
| 33 |
display so it can be loaded to find a version. |
| 34 |
|
| 35 |
In these situations, what is needed is a fake display. |
| 36 |
|
| 37 |
The "Test::NeedsDisplay" module will search around and try to find a way |
| 38 |
to load some sort of display that can be used for the testing. |
| 39 |
|
| 40 |
Strategies for Finding a Display |
| 41 |
At this time, only a single method is used (and a very simple one). |
| 42 |
|
| 43 |
Debian Linux has a script called "xvfb-run" which is a wrapper for the |
| 44 |
"xvfb", a virtual X server which uses the linux frame buffer. |
| 45 |
|
| 46 |
When loaded without a viable display, the module will re-exec the same |
| 47 |
script using something like (for example) "xvfb-run test.t". |
| 48 |
|
| 49 |
As such, it should be loaded as early as possible, before anything has a |
| 50 |
chance to change script parameters. These params will be resent through |
| 51 |
to the script again. |
| 52 |
|
| 53 |
METHODS |
| 54 |
There are no methods. You simply use the module as early as possible, |
| 55 |
probably right after "use strict;" and make sure to load it with only |
| 56 |
default params. |
| 57 |
|
| 58 |
Specifically, need must always load it before you set the test plan, |
| 59 |
otherwise the test script will report two plans, and the harness will |
| 60 |
complain about it and die. |
| 61 |
|
| 62 |
# Use it like this ... |
| 63 |
use Test::NeedsDisplay; |
| 64 |
|
| 65 |
# ... not like this ... |
| 66 |
use Test::NeedsDisplay 'anything'; |
| 67 |
|
| 68 |
# ... and not like this. |
| 69 |
use Test::NeedsDisplay (); |
| 70 |
|
| 71 |
And that's all there is to do. The module will take care of the rest. |
| 72 |
|
| 73 |
TO DO |
| 74 |
- Find alternative ways to launch a display on different platforms |
| 75 |
|
| 76 |
SUPPORT |
| 77 |
Bugs should be reported via the CPAN bug tracker at |
| 78 |
|
| 79 |
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-NeedsDisplay> |
| 80 |
|
| 81 |
For other issues, contact the author. |
| 82 |
|
| 83 |
AUTHOR |
| 84 |
Adam Kennedy <[email protected]> |
| 85 |
|
| 86 |
COPYRIGHT |
| 87 |
Copyright 2005 - 2009 Adam Kennedy. |
| 88 |
|
| 89 |
This program is free software; you can redistribute it and/or modify it |
| 90 |
under the same terms as Perl itself. |
| 91 |
|
| 92 |
The full text of the license can be found in the LICENSE file included |
| 93 |
with this module. |
| 94 |
|