Test::...empFile(3pm)
π Test::Trap::Builder::TempFile
okay so picture this: it's a page from the User Contributed Perl Documentation, manual section 3pm, and it's all about capturing trap output using File::Temp. Strap in bestie π
β¨ NAME β¨
Test::Trap::Builder::TempFile β the capture strategies that use File::Temp, no cap π
πΈ VERSION πΈ
Version 0.3.5 β that's the one, periodt β¨
π¦ DESCRIPTION π¦
So by default, this module hands you a capture strategy built on top of File::Temp, and it does that for the trap's output layers. Iconic behavior, honestly π
The import is where the magic happens: it accepts a name (as a string β defaults to tempfile, and yes that's the literal default) and options (as a hashref β by default empty, like, no options at all, empty, nothing). Then it registers a capture strategy with that name, plus a variant implementation based on the options you passed. Slay π
Lowkey important: you can specify different strategies for each output layer on the trap. Mix and match, main character energy, you do you β¨
See also: Test::Trap (:stdout and :stderr) and Test::Trap::Builder (output_layer) β go read those too, iykyk π«Ά
π₯ OPTIONS π₯
The following options are recognized (aka, the ones that actually do something):
π«Ά preserve_io_layers
A boolean, bestie β it tells you whether to apply the same perlio layers found on the to-be-trapped output handle onto the handles that write to and read from the tempfile. Basically "keep the vibe of the original layers" β
π io_layers
A colon-separated string representing the perlio layers to be applied to the handles that write to and read from the tempfile. So like, layer1:layer2:layer3 β you get it π
And here's the tea: if the preserve_io_layers option is set, these perlio layers get applied on top of the original (preserved) perlio layers. Stacking, nesting, immaculate layering π
π CAVEATS π
Okay so real talk, here's the fine print you gotta know:
- Using
File::Tempmeans we need privileges to create tempfiles. Permissions check β if you don't got it, you don't got it π - We need disk space for the output of every trap. It should clean up after the trap is sprung, but. Yeah. It should π
- Disk access may be slow β certainly compared to the in-memory files of
PerlIO. Bestie it is lowkey way slower, like literally not even close π - If the options specify (explicitly, or via preserve on handles with) perlio custom layers, they may (or may not) fail to apply to the tempfile read and write handles. So like, your mileage varies, we don't promise anything there π€·ββοΈ
- Threads? No idea. It might even work correctly. That's the whole answer. That's the entire answer β¨
ngl "it might even work correctly" is the most honest sentence in all of CPAN and I respect it so much
π BUGS π
Please report any bugs or feature requests directly to the author. No middleman, straight to the source, we keep it efficient around here π
π AUTHOR π
Eirik Berg Hanssen, "<ebhanssen@cpan.org>" β the actual legend behind all this π«Ά
πΈ COPYRIGHT & LICENSE πΈ
Copyright 2006-2014 Eirik Berg Hanssen, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Free as in yes bestie you can use it π
π so that's the whole page!! captured, documented, immaculate. this came to you courtesy of perl v5.42.0 and its 2022-07-28 date stamp β an older era, but the vibes are timeless. mwah π β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Test-Trap 0.3.5-bp160.1.12 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms