App::Cm...External(3)

πŸ¦‹ App::Cmd::Tester::CaptureExternal β€” the perl man page, but make it a group chat πŸ¦‹

okay bestie, so this is a page from the User Contributed Perl Documentation, and it's genuinely so useful. it's called App::Cmd::Tester::CaptureExternal and honestly? it ate. let's get into it πŸ’…


✨ NAME ✨

App::Cmd::Tester::CaptureExternal β€” it's the glow-up of App::Cmd::Tester that also catches output from external subprograms. no cap. 🫢


🌸 VERSION 🌸

version 0.338 β€” that's the one, that's the girl πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

here's the whole vibe, copy-paste ready:

use Test::More tests => 4;
use App::Cmd::Tester::CaptureExternal;

use YourApp;

my $result = test_app(YourApp => [ qw(command --opt value) ]);

like($result->stdout, qr/expected output/, 'printed what we expected');

is($result->stderr, '', 'nothing sent to sderr');

ok($result->output, "STDOUT concatenated with STDERR");

(yes, sderr. iconic typo. we keep it exactly as it is, we do not touch the artifact 😌)


πŸ’œ DESCRIPTION πŸ’œ

so, App::Cmd::Tester is a whole scaffold for testing your apps and it's great, it's giving main character energy. but β€” and this is the plot twist β€” it literally cannot capture output that comes from any external subprograms that your application invokes. it just... can't see them. πŸ™ˆ

this subclass right here uses a different mechanism for capturing output (Capture::Tiny) which does capture from external programs. slay. but there's one major limitation, and we need to talk about it, bestie.

it is not possible to capture externally from both STDOUT and STDERR while also having appropriately interleaved combined output. so the "output" from this subclass simply concatenates the two. periodt.

so like β€” you can still use "output" for testing if there's any output at all, or for testing whether something showed up in either output stream. but you cannot rely on the ordering being correct between lines going to STDOUT and lines going to STDERR. the interleaving? not trustworthy. do not build your dreams on it 😭


🧚 PERL VERSION 🧚

this library should run on perls released even a long time ago. it should work on any version of perl released in the last five years. ⭐

although it may work on older versions of perl, there's no guarantee that the minimum required version will not be increased. the version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl. so like, don't @ them about it. πŸ’€


πŸ‘‘ AUTHOR πŸ‘‘

Ricardo Signes <cpan@semiotic.systems> β€” king behavior, honestly 🌈


this software is copyright (c) 2025 by Ricardo Signes.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in, go off, do your thing 🫢


and that's the whole page, bestie!! tysm for reading, ily, go write some tests πŸ’œπŸ¦‹πŸŒΈ

perl v5.42.0 β€” dated 2026-01-16 β€” and the header up top calls it App::Cm...External(3). byeeee ✨

πŸ“¦ where this page comes from