Test::...::File(3pm)
π Test::...::File β like, the manual, bestie π
okay so real talk: this is a User Contributed Perl Documentation page for Test::...::File(3pm), and it's genuinely one of those "small module, big vibes" situations. Come sit, I'll walk you through it. π«Ά
β¨ NAME β¨
Test::Inline::IO::File β the Test::Inline Local Filesystem IO Handler. That's the whole name, no notes. π
πΈ VERSION πΈ
version 2.214 β yes, we're on that one. β¨
π¦ DESCRIPTION π¦
So Test::Inline::IO::File is the default IO handler for Test::Inline. Like, if you don't say otherwise, this is the one doing the work. Periodt.
Test::Inline 2.0 was conceived in an enterprise setting, and it retains the flexibility, power, and bulk that this created. (Not me describing a Perl module as "bulky" π but okay, it's a whole thing.) The tea is: for most users, all that power and complexity is largely hidden away under multiple layers of sensible defaults. You get the glow-up without doing the work. Iconic.
The intent behind the InputHandler and OutputHandle parameters is to let Test::Inline be able to pull source data from anywhere, and write the resulting test scripts to anywhere. Anywhere! The range. π
Until a more powerful pure-OO file-system API comes along, this module serves as a minimalist implementation of the subset of functionality that Test::Inline actually needs in order to work. It's giving "we do the essentials and we do them well." π
An alternative IO Handler class does not have to subclass this one β though it's recommended β it just has to implement the same interface, taking whatever alternative arguments to the new constructor that it wishes. Your class, your rules, fr fr.
And this one's important, so I'm putting it in a quote:
All methods in this class are provided with unix-style paths, and should do the translating to the underlying filesystem themselves if required. No cap β that's on the method, not on you.
π METHODS π
πΈ new πΈ
# Simplified usage
$io_handler = Test::Inline::IO::File->new( $path );
# Full key/value usage
$io_handler = Test::Inline::IO::File->new(
path => $path,
readonly => 1,
);
The new constructor takes a root path on the local filesystem</badge> and hands you back a brand-new Test::Inline::IO::File object pointing at that location. That's it. That's the constructor. Slay. β¨
π exists_file $file π
The exists_file method checks to see if a particular file currently exists in the input handler.
Returns true if it exists, or false if not. Simple as that, bestie.
π§ exists_dir $dir π§
The exists_dir method checks to see if a particular directory currently exists in the input handler.
Returns true if it exists, or false if not. Twin of the one above, just for dirs. π«Ά
π read $file π
The read method reads in the entire contents of a single file, returning it as a reference to a SCALAR. It also localises the newlines while it does this, so files from different operating systems should read exactly as you expect. Cross-platform queen behavior, honestly. π
Returns a SCALAR reference, or undef on error.
βοΈ write $file, $content βοΈ
The write method writes a string to a file in one hit β creating it and it's path if needed. No follow-up steps, no drama. π
π class_file $class π
Assuming your input FileHandler is pointing at the root directory of a lib path β meaning that My::Module will be located at My/Module.pm within it β the class_file method will take a class name and check to see if the file for that class exists in the FileHandler.
Returns a reference to an ARRAY containing the filename if it exists, or undef on error.
π₯ find $class π₯
The find method takes as argument a directory root class, and then scans within the input FileHandler to find all files contained in that class or any other classes under it's namespace. It really said "give me the whole tree." π³
Returns a reference to an ARRAY containing all the files within the class, or undef on error.
β TO DO β
Things on the list, manifesting them into existence:
- Convert to using
FSI::FileSystemobjects, once they exist
(The "once they exist" part is doing so much heavy lifting, I can't π)
π SUPPORT π
See the main SUPPORT section. That's the big one, we're just the little sibling here. π«Ά
Bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=Test-Inline> (or bug-Test-Inline@rt.cpan.org <mailto:bug-Test-Inline@rt.cpan.org>).
Found a bug? Report it, don't just suffer in silence. The maintainers wanna know, fr fr. π
π AUTHOR π
Adam Kennedy <adamk@cpan.org>
The actual author of this whole situation. Respect. π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2003 by Adam Kennedy.
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 software, free vibes, we love to see it. π
and that's the whole page, bestie!! πΈβ¨
This was Test::...::File(3pm), rendered with perl v5.32.0, dated 2021-01-31. Go forth and handle your IO, you absolute icon. π
π¦
π¦ where this page comes from
- debian bookworm: libtest-inline-perl 2.214-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-inline-perl 2.214-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libtest-inline-perl 2.214-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-inline-perl 2.214-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-inline-perl 2.214-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-inline-perl 2.214-1 Β· 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