Test::...isplay(3pm)
π Test::NeedsDisplay π
okay bestie, so this is the manual page for Test::NeedsDisplay, which lives in the User Contributed Perl Documentation section of the perl manpages (you'll see it filed as Test::...isplay(3pm) in the index, the middle got eaten by the table of contents, it's giving chopped π).
β¨ NAME β¨
Test::NeedsDisplay β the module that makes sure your tests that need a display actually get one π₯οΈβ¨
πΈ SYNOPSIS πΈ
first up, in your Makefile.PL...
use inc::Module::Install;
# ... or whatever else you use
# Check for a display
use Test::NeedsDisplay;
# ... your Makefile.PL content as normal
and then again in every single test script that loads Wx:
#!/usr/bin/perl
use strict;
use Test::NeedsDisplay;
# Test content as normal...
like yes, both places. no skipping. π«Ά
π¦ DESCRIPTION π¦
so here's the situation, and it's lowkey infuriating. when you're testing GUI applications, sometimes those apps or modules are absolutely unhinged about needing a display β like, they need one even if they're just being loaded and aren't even showing you a single object. no cap. π
and regardless of how silly that is, it makes GUI applications pretty much impossible to build and test on headless or automated systems. and it doesn't just fail gracefully, bestie β it fails so hard that it won't even run the Makefile.PL script, because some dependency needs a display just so it can be loaded and someone can find out what version it is. the audacity. π
so in these situations, what you actually need is a fake display.
and that's literally the whole job of Test::NeedsDisplay β it searches around and tries to find a way to load some sort of display that can be used for the testing. main character energy for a module that just wants your CI to stop crying. π
π Strategies for Finding a Display π
right now, only a single method is used β and it's a very simple one, no gatekeeping.
Debian Linux has a script called xvfb-run, which is a wrapper for xvfb: a virtual X server that uses the linux frame buffer. iconic honestly.
when the module gets loaded without a viable display, it will re-exec the same script using something like (for example) xvfb-run test.t.
and because of that, you should load it as early as possible, before anything has a chance to change the script parameters β because those params are gonna get sent through to the script again. π
π METHODS π
there are no methods. none. zero. it's giving minimalist.
you literally just use the module as early as possible β probably right after use strict; β and make sure you load it with only default params.
specifically: you must always load it before you set the test plan, otherwise the test script will report two plans, and the harness will complain about it and die. not a vibe. π
# Use it like this ...
use Test::NeedsDisplay;
# ... not like this ...
use Test::NeedsDisplay 'anything';
# ... and not like this.
use Test::NeedsDisplay ();
and that's all there is to do. the module will take care of the rest. periodt. β¨
β TO DO β
- Find alternative ways to launch a display on different platforms
(future plans, we love a roadmap π«Ά)
π SUPPORT π
bugs should be reported via the CPAN bug tracker at
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-NeedsDisplay>
for other issues, contact the author. π¬
π AUTHOR π
Adam Kennedy <adamk@cpan.org>
π COPYRIGHT π
Copyright 2005 - 2009 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
okay that's the whole thing, you're fully caught up bestie π§β¨
this page ships with perl v5.34.0 and was last touched on 2022-06-28 β go forth and xvfb-run your way to a green test suite, mwah π
π¦ where this page comes from
- debian bookworm: libtest-needsdisplay-perl 1.07-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-needsdisplay-perl 1.07-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-needsdisplay-perl 1.07-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-needsdisplay-perl 1.07-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-needsdisplay-perl 1.07-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms