in reply to Mock/Fake network fileshare for my new modules Test Suite

Network shares mounted locally should behave the same as local filesystems for basic operations (open, read, write). If you're only listing directories and testing filenames, it should work just fine to create the file structure locally and test against that. If you need to simulate large file sizes, you could abstract out the fetching of the file size into a sub get_size { my ($filename) = @_; ... }, and then mock that during testing (more advanced monks may know if it's possible to mock -s directly...?).

However, if you're going to be doing other things like file locking or reading file attributes other than size and modification time, support for that can vary wildly depending on protocol, software versions, etc. Also of course each software and protocol may have some other small quirks here and there.

As for switching locations to test against, if it's a single test program, then a command line arg should be enough; if it's a suite of test scripts, an environment variable is easiest.

To keep your test suite small, you could include a script that generates the fake directory structures for you (for example, create a temp dir via File::Temp, generate the files there, and test against that).

What OS will you be running on? Also, if you haven't seen them yet, the excellent Path::Class and File::Find::Rule modules should help you in navigating the directory structure.

(A bit of Googling brings up Filesys::Virtual::Async and Test::Virtual::Filesystem, maybe those can help too.)

Replies are listed 'Best First'.
Re^2: Mock/Fake network fileshare for my new modules Test Suite
by Anonymous Monk on Aug 27, 2014 at 12:01 UTC
    Here's a PerlMonks post in which Athanasius shows how a class can overload -X operations performed on itself (that would require that you use this class for all -s calls). According to this StackOverflow post, overriding the file test operators isn't directly possible. stat can be mocked, but I haven't yet found out if it's possible to affect -X.