bovigo / vfsStream

vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with any unit test framework, like PHPUnit or SimpleTest.
BSD 3-Clause "New" or "Revised" License
1.42k stars 102 forks source link

Allow for custom directory separators #275

Open danon opened 2 years ago

danon commented 2 years ago

Given that the file system is virtual, and as I understand fairly independent of the underlying system, it would seam it's possible to set a custom directory separator.

I have a usecase.

I develop an application that's supposed to work both on windows and Unix, so I need to write tests for / as separator and \ as well. In order to test it, I run two docker containers, one based on debian, one on windows.

If vfsStream supported both kinds of separators, I could test all my code without need for docker at all.

bizurkur commented 2 years ago

There's some in-progress stuff that's blocking work on this library at the moment (a massive restructuring) so it could be a while for this to happen (see #221).

If you absolutely need this today, you may want to check out https://github.com/bizurkur/mockfs. It already supports the feature you're asking about and has a pre-built configuration to mimic a Windows OS. It's more than just the file separator that changes - the characters that are allowed in file names also change. It also supports / as the root partition for Unix-like OSes.

danon commented 2 years ago

It's okay, I can wait. I got the pipeline that runs on docker windows and ubuntu, so I can test it.

It just struc me that with virtual file system, that's a possibility.