-
Notifications
You must be signed in to change notification settings - Fork 603
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
ioJS: handle NoSuchFileException in isDirectory, isFile and isSymbolicLink #2727
ioJS: handle NoSuchFileException in isDirectory, isFile and isSymbolicLink #2727
Conversation
Thanks for the PR and improving the test coverage! On the topic of tests, I think you can use this method to create a symlink (actually, I don't think that method is tested right now!): fs2/io/js/src/main/scala/fs2/io/file/FilesPlatform.scala Lines 85 to 89 in 109a71f
Note sure how to easily create hidden files cross-OS (i.e., unix and Windows). |
Added a true-case test for
First, the regex that was used (
Confirmed this in The previous regex:
Removing the
Finally, without
Made a test for it which checked for Having that, I removed the regex completely, leaving a simple implementation instead: override def isHidden(path: Path): F[Boolean] = F.pure {
val fileName = path.fileName.toString
fileName.length >= 2 && fileName(0) == '.' && fileName(1) != '.'
} I'm uncomfortable with doing |
As for testing the |
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'm really thrilled about these fixes, and overall the improved test coverage for the Files
API. 🤞 this will fix some other issues downstream as well :) thanks!
} | ||
} | ||
|
||
group("isHidden") { |
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.
Even though there's no windows CI, this will be annoying for anyone developing on Windows. Not sure how big a deal that is.
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.
Yeah 🤔
If someone's working on fs2 in Windows and runs the tests.. that will be annoying (I kind of blanked out such a possibility :/ )
I wonder if we can do some platform checks in the test code and, at least, always pass isHidden
true-case if it's windows?
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.
Eh, it's merged. Let's see if anyone complains :P
The problem is we need cross-platform (JVM/JS) checks for checking the platform (Unix/Windows). Possible, but annoying!
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.
Eh, it's merged. Let's see if anyone complains :P
=)
The problem is we need cross-platform (JVM/JS) checks for checking the platform (Unix/Windows). Possible, but annoying!
Should be non-crazy enough to implement, right?
Is there a good place for it? (like Files[F]
is for the file stuff)
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.
Oh, as a public API? Probably not in fs2. I was thinking as an internal/test utility.
In nodejs, calling
stat
throws an exception if the path does not exist, thus makingisDirectory
,isFile
andisSymbolicLink
fail as well. In jvm, on the other hand, the underlying calls do not throw and returnfalse
when the path does not exist.This is an attempt to make the behaviour of these functions more aligned across platforms.
There's a couple of TODOs in the tests, not sure how important these are:not sure how to easily create a symlink for testsnot sure how to create a "hidden" file for tests