-
Notifications
You must be signed in to change notification settings - Fork 91
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
Move JDK shims to munit.internal
#441
Conversation
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.
Thank you for this contribution! Looks good to me overall, just a few nitpick comments on undocumented conventions I try to keep in the codebase.
import java.util | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
// Rough implementation of java.nio.Path, should work similarly for the happy | ||
// path but has undefined behavior for error handling. | ||
case class NodeNIOPath(filename: String) extends Path { | ||
case class Path(filename: String) { |
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.
Let's call this MUnitPath
instead of Path
. Or something else if you have suggestions. I don't like it when libraries use generic names for internal classes because it pollutes the namespace when you're auto-completing symbols.
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.
Makes sense, done.
@@ -1,10 +1,7 @@ | |||
package java.nio.file | |||
package munit.internal |
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.
Let's introduce a new munit.internal.io
package. The general structure I try to following is
- flat list of classes/objects inside
munit._
for public API - flat list of packages inside
munit.internal._
The reason is mostly historical because MUnit includes a reimplementation of the java difflib and it didn't feel right to have all of those diff classes inside munit.internal._
.
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.
Done.
package munit | ||
|
||
package object internal { | ||
type File = java.io.File |
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.
Can we add an object called PlatformIO
that has these methods and aliases instead? I try to avoid package objects when possible.
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 moved the io-related ones to PlatformIO
. I moved the reflect ones to PlatformCompat
.
You can run |
Thanks for the feedback and pointers. I'm still tracking down various linking issues for JS then I'll iterate on your feedback 👍 |
Just a heads up, I've been thinking how to solve another issue #382 and just realized it's somewhat related to this issue. The root problem is that MUnit does file I/O at runtime, which is incompatible with JS in the browser and distributed build tools like Gradle and Bazel. One alternative solution to this problem is to embed the full text contents of the file inside |
Uh-oh, maybe I should wait on this until you decide what you want to do? 😅 Removing I/O completely would be excellent for browsers and friends. |
You can try to implement this alternative approach if you're interested. The steps would be
|
I'm sorry for guiding you in the other direction, this idea didn't come up until after you opened the draft PR. |
The CI seems green so we can also merge this PR as is and I can look into the alternative later. |
Apologies, getting a bit out-of-scope for me. As it stands this PR does the hard part of #437 by tracking down all the JDK stuff and condensing it in the internal package. All that's left is bike-shedding names according to unwritten convention which it seems you are the expert on 😉 |
It's not bike-shedding IMO to follow conventions of existing code structure. I apologize if it seems like a waste of time or if your dissatisfied with the lack of documentation for how the code should be structured. I'm happy to merge this PR as is once the proposed renames and code structure suggestions have been implemented. |
I don't claim these conventions are the best conventions or that they're even standard conventions. They're just conventions that are part of this codebase, for better or worse (some of them are accidental while others are for historical reasons). |
Apologies, I regret my remark as it came across poorly I think 😕 I have ton of respect for projects and developers that keep things organized, extremely important for projects like this at the top of the dependency food chain. It's just hard for me to know exactly how you want things without a couple more iterations and it seems the future of this PR is dubious depending on some very good changes that might be forthcoming. So I'm happy to let this sit and if it's still relevant by the time 1.0 is solidifying then we can make it all perfect :) |
Sound good, we can let this PR wait. No worries! |
FYI I'm working on this issue here right now #41 and it may take a while to get through the finish line. |
@olafurpg we've been butting heads with this problem again in http4s/http4s#5758. Would you be open to accepting the changes in this PR into 0.7.x series (after it's polished up)? I know it's technically a breaking change, but in fact anyone who experiences that breaking change likely had bugs/linking issues that were masked precisely because of these shims. Thanks! |
Oh, one more idea: if you really want to avoid a breaking change, we apply the changes here, and also move these shims into a new artifact. So anyone that experiences issues because of the change, can just add a new dependency to get the shims back (or alternatively, the shims can be included by default and downstreams where it causes a problem can remove that artifact explicitly). |
@olafurpg I've now renamed/re-organized everything as you suggested. Thanks for your patience on this one! :) |
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.
LGTM thank you!
Will fix #437.