-
Notifications
You must be signed in to change notification settings - Fork 1.4k
red-knot: Add directory support to MemoryFileSystem
#11825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
MemoryFileSystem
MemoryFileSystem
bee11e7
to
0a7a310
Compare
|
2fb8508
to
0b6f5b2
Compare
0a7a310
to
c5e4ec0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there are some clippy/test problems to resolve before merging this.
/// The implementation doesn't aim at fully capturing the behavior of a real file system. | ||
/// The implementation intentionally doesn't support: | ||
/// * symlinks | ||
/// * hardlinks | ||
/// * permissions: All files and directories have the permission 0755. | ||
/// | ||
/// Use a tempdir with the real file system to test these advanced file system features and complex file system behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to this approach. We should use in-memory file system for fast and easy testing of semantic analysis, not for testing filesystem behaviors.
struct MemoryFileSystemInner { | ||
files: FxDashMap<FileSystemPathBuf, FileData>, | ||
by_path: RwLock<FxHashMap<Utf8PathBuf, Entry>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the switch from FxDashMap
to an FxHashMap
wrapped in a RwLock
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I don't think it was necessary as part of this PR. I first thought I would need a BTreeMap
. I'll leave it this way because I do need a BTreeMap
when adding support for removing directories.
/// Normalizes the path by removing `.` and `..` components and transform the path into an absolute path. | ||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am very surprised that we have to implement such a thing ourselves instead of just using a battle-tested library method for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it exists, it's just not stabalized. @BurntSushi knows more ;)
0b6f5b2
to
99cbb93
Compare
c5e4ec0
to
671d556
Compare
MemoryFileSystem
MemoryFileSystem
CodSpeed Performance ReportMerging #11825 will improve performances by 13.32%Comparing Summary
Benchmarks breakdown
|
Summary
This PR adds support for handling directories to the
MemoryFileSystem
.I'm adding this now because the module resolver contains logic that branches if
path
is a directory.I used this PR to remove permissions support from the
MemoryFileSystem
. I think having support for it is misleading, it gives the impression that the file system would check permissions when reading/writing which it does not and I don't plan on adding.The
MemoryFileSystem
is mainly intended for testing. We should use the real file system to test more advanced or even platform specific filesystem behavior. That's the only way to get that right.Test Plan
Added tests