Test::S...:Capture(3)

πŸ“¦
version 1.302027 Β· 2 versions
, in fedora 43

πŸ’– Test::Stream::Plugin::Capture β€” the manual page, bestie edition ✨

okay so this is the page for Test::Stream::Plugin::Capture(3) β€” yeah it's a User Contributed Perl Documentation page, and yeah we're gonna read it together, it's fine, it's literally fine 🫢


🌸 NAME 🌸

Test::Stream::Plugin::Capture β€” the plugin that snatches up your STDERR and STDOUT for you. it's giving "I'll hold your bags while you shop" energy πŸ’…


πŸ’€ DEPRECATED πŸ’€

bestie. sit down. 😭

This whole distribution is deprecated in favor of Test2, Test2::Suite, and Test2::Workflow.

There's a whole conversion guide over in Test::Stream::Manual::ToTest2 if you wanna make the move β€” highly recommend, it's the glow-up arc 🌈


πŸ¦‹ DESCRIPTION πŸ¦‹

So this plugin hands you the capture { ... } function, right? and what it does is it captures all STDERR and STDOUT output from whatever code you put inside that codeblock. every last print, all of it, collected. obsessed. ✨

Now here's the part that's lowkey the best: it will not intercept TAP output from Test::Stream itself. so you can literally run tests inside the block and it won't mess with your TAP. safe. iconic. no cap. πŸ‘‘


🌟 SYNOPSIS 🌟

look at this beautiful example, I'm not crying you're crying 😭

is(
    capture {
        print STDERR "First STDERR\n";
        print STDOUT "First STDOUT\n";
        print STDERR "Second STDERR\n";
        print STDOUT "Second STDOUT\n";
    },
    {
        STDOUT => "First STDOUT\nSecond STDOUT\n",
        STDERR => "First STDERR\nSecond STDERR\n",
    },
    "Captured stdout and stderr"
);

see how both handles get their own string, in order, all tidy? chef's kiss πŸ§‘πŸ³πŸ’‹


πŸŽ€ EXPORTS πŸŽ€

  • $out = capture { ... } β€” this is the one and only export, and it's the main character. it captures all STDERR and STDOUT output inside the codeblock. $out comes back as a hashref with STDERR and STDOUT as its keys. and ngl, all the output for each handle gets combined into a single string per handle β€” so no line-by-line nonsense, just one big string per stream. periodt. πŸ’…

πŸ”₯ SOURCE πŸ”₯

The source code repository for Test::Stream lives at:

http://github.com/Test-More/Test-Stream/

go star it, go read it, go be nosy, it's your right 🫢


πŸ‘‘ MAINTAINERS πŸ‘‘

  • Chad Granum <exodist@cpan.org>

🌈 AUTHORS 🌈

  • Chad Granum <exodist@cpan.org>

Copyright 2015 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/


and that's the whole page, bestie β€” every flag, every key, every name, nothing skipped, we ate that πŸ’–βœ¨

k byeeee, this was perl v5.42.0, dated 2025-07-25, page Test::S...:Capture(3) β€” mwah, go capture something πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from