Description
I'm the author of dshell
https://pub.dev/packages/dshell.
I'm using the path package extensively.
I'm currently trying to write unit tests for dshell and having some problems.
Dshell creates a ~/.dshell directory and all my unit tests make adjustments to this directory and its children.
When running unit tests this can be problematic for two reasons.
- unit tests can't be serialized so different unit tests are writing over each others changes to ~/.dshell and its children
- Modifying my local file system is of concern as a number of my unit tests do recursive deletes.
As such I'm trying to use Zones and the MemoryFileSystem.
This seems like it will work however the path package causes problems.
The path package has a number of global variables. The key pain point is the 'current' variable that maintains a cache of of the current working directory.
As this variable is global it is shared across zones which means that my unit tests still interfere with each other (e.g. if one test changes the CWD then all unit tests get the new CWD).
It seems to me that we could modify the paths package to be zone aware without much effort.
The 'current' method could be modified to check if it is in the root zone via;
Zone.current == Zone.root
If it is in the root zone it continues as it currently does.
If its not in the root zone then we could modified to pull its settings from a Zone key.
_current = Zone[#paths]._current;
The #paths key would be a unique class that contains all of the global settings that paths uses.
If I submitted a change to make the path package zone aware would it be accepted (assuming suitable quality standards are met)?
I believe these changes could be made without modifying the current api.