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