Test::...leTemp(3pm)

πŸ“¦
version 0.039 Β· 4 versions
, in ubuntu stonking

πŸ’– Test::MockFile::Plugin::FileTemp β€” the manual page, but make it cute πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation section, manual page 3pm. Yes, the header got truncated to Test::...leTemp(3pm) because apparently man pages also have a character limit and no self-esteem. πŸ™ˆ The actual module name is Test::MockFile::Plugin::FileTemp and we're gonna talk about it. Sit down, grab a strawberry πŸ“, we're doing this.


✨ NAME ✨

Test::MockFile::Plugin::FileTemp β€” a plugin that lets File::Temp calls through, no cap πŸ’…


✨ SYNOPSIS ✨

okay so here's the whole vibe in code form. Look at it. Soak it in. 🌸

use Test::MockFile 'strict', plugin => 'FileTemp';

# using FileTemp plugin, all calls from FileTemp bypass the Test::MockFile strict mode

my $dir = File::Temp->newdir();
ok opendir( my $dh, "$dir" );
ok open( my $f, '>', "$dir/myfile.txt" );

That's it. That's the whole thing. It's giving minimalist icon. ✨


✨ DESCRIPTION ✨

So here's what's actually going on 🫢 β€” Test::MockFile::Plugin::FileTemp gives Test::MockFile a plugin whose entire job is to authorize any calls coming out of the File::Temp package. Like, it's the bouncer at the club and File::Temp is on the list. Periodt. πŸ‘‘

The trick is in that 'strict' in the SYNOPSIS β€” under strict mode, Test::MockFile normally wants to mock everything and would be very upset if something wandered off and touched the real filesystem. But with plugin => 'FileTemp' loaded, anything File::Temp does gets waved through instead of getting strict-mode'd into oblivion. It's giving ✨diplomatic immunity✨.


✨ METHODS ✨

🌈 register( $self )

A public method. Its whole purpose in life is to register the plugin. That's it, that's the job. $self goes in, registration happens, and the plugin is officially official. No notes. πŸ’œ


πŸ‘€ SEE ALSO πŸ‘€

  • Test::MockFile β€” the main character this plugin is attached to πŸŽ€
  • Test::MockFile::Plugins β€” the whole plugin squad, iykyk πŸ¦‹
  • Test::MockModule β€” also in the Perl testing cinematic universe ⭐

🌸 tiny reminder bestie: the facts above are the facts, the vibes are mine. Don't @ me if File::Temp does something spicy in your specific test suite. πŸ™ˆ

and that's the page, fr fr πŸ’– this one's from perl v5.40.1, dated 2026-03-27, hanging out in the User Contributed Perl Documentation section. go write some tests, you ate. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from