-
Notifications
You must be signed in to change notification settings - Fork 534
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
Replace specs2 with munit #4216
base: series/3.x
Are you sure you want to change the base?
Conversation
e671306
to
d2b73e9
Compare
// we try iterating a few times to get canceled in the middle | ||
if (i > Bound) { | ||
IO.pure(skipped(s"attempted $i times and could not reproduce scenario")) | ||
IO.println(s"attempted $i times and could not reproduce scenario") |
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.
So, it's not a direct equivalent. But I cannot think of anything better.
4c319c2
to
7bc5906
Compare
…holy crap |
General 20k LOC changeset. Nothing to worry about 😅 |
Specs2 model feels more strict. With munit the following code compiles and the test is green, but it's never being executed: test("leaky io") {
IO(sys.error("boom"))
} The compiler doesn't throw any warning, either. I hope I didn't miss such cases. |
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.
NGL, I didn't read through all 11k lines. Did some spot checking around though and left some comments on things that I think probably apply more broadly. Agree we should review carefully. Overall looks good though.
This one is concerning, to be sure. We've historically had a bunch of problems with this, and we do have a ton of tests which throw exceptions in various cases. We should explore our own variant of |
3d60f3f
to
9f68a30
Compare
I think the next step on this is probably to go through and surgically break some subtle things one at a time and make sure the test suite still catches it. |
Sorry, I snuck a new test in here. |
new ValueTransform( | ||
"Other", | ||
{ | ||
case r if !r.isInstanceOf[Unit] && !r.isInstanceOf[Prop] => | ||
sys.error(s"Unexpected value of type ${r.getClass.getName}: $r") | ||
} | ||
) |
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.
This transformer ensures the result type is Unit
or Prop
.
From the munit perspective, that's a valid test:
test("some test") {
1 == 2
}
However, it should use assert
:
test("some test") {
assert(1 == 2)
}
Here are all the fixed tests that were exposed by this transformer: 9186d4b
No worries. I've backported the test. |
So for some reason,
|
My best guess is that
If you didn't clean the project, it may use the old cached native artifacts. |
For some reason, munit seems a lot more prone to hanging tests without timeouts in some failure cases. For example, if you remove the |
I did some flipping tests before, and they were timing out correctly.
However, CPU usage skyrocketed to 1300%, and the fans went crazy. Today I decided to use nix env, and the result was different:
Hangs forever. CPU usage is normal, though. |
Interesting. I'm on Java 23 and for me it was a forever hang with normal CPU. |
Do you use Temurin by any chance?
I'm testing on Darwin Aarch64. |
Fascinating! And somewhat terrifying. I wonder why there's such a significant difference between the distributions? |
Seems to be related: scalameta/munit#730. override def munitExecutionContext: ExecutionContext = ExecutionContext.global |
I did some extra testing on the Azul JVM. After several reruns of the 65dc9ad - this change fixes hanging behavior on all JVMs. |
This change still seems to hang forever for me: diff --git a/core/shared/src/main/scala/cats/effect/IOFiber.scala b/core/shared/src/main/scala/cats/effect/IOFiber.scala
index 9e0357b734..39c44fd37e 100644
--- a/core/shared/src/main/scala/cats/effect/IOFiber.scala
+++ b/core/shared/src/main/scala/cats/effect/IOFiber.scala
@@ -697,7 +697,7 @@ private final class IOFiber[A](
*/
suspend()
}
- } else if (finalizing == state.wasFinalizing && !shouldFinalize() && outcome == null) {
+ } else if (finalizing == state.wasFinalizing && outcome == null) {
/*
* If we aren't canceled or completed, and we're
* still in the same finalization state, loop on Maybe that's a unique one. I'm trying out a few more which hung previously. |
Roughly 1 in 10 runs hangs, no matter what JVM you use. |
Follow up to #3787.
The whole PR is purely focused on the migration. There are options to build more usable test abstractions and utilities, but I don't want to do it without proper thinking.