-
Couldn't load subscription status.
- Fork 1.4k
ZTestRunnerNative/ZTestTask => Override default execute + use the scala-js implementation #7911
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
|
Great progress. That test failure would indicate that possibly yielding is not working correctly. In a single threaded environment that test relies on the child fiber yielding control at some point so that other fibers have a chance to run. Looking for other areas where there is platform specific code and making sure the Native implementation is consistent with the Scala.js one could be a good place to start. Will take a look in more detail in the morning. |
|
I think I see now where the difference in the
|
|
Yes exactly. I spent some time looking at that test failure. suite("heap")(
test("unit.forever is safe") {
for {
fiber <- ZIO.unit.forever.fork
_ <- Live.live(ZIO.sleep(5.seconds))
_ <- fiber.interrupt
} yield assertCompletes
}
),It looks like in the above test we fork the fiber and initiate the Thinking about what is different about this test, the |
|
Yes, sorry I wasn't so clear - the tests were passing for me as well, except when it hangs running the full suite instead of testOnly. Another interesting behavior I just encountered: If I run So it seems ok if it's the first test, but causes trouble when not. I'm not saying its a proper solution, but I had experimented with configuring sbt with |
|
The tests should already be run sequentially since we have parallel execution set to false and that appeared to be the case for me. So I think it is running something before this test versus running it concurrently with it that is causing the issue. |
|
Just another peculiarity: Running with an updated first test to and the test bails early as successful, but doesn't actually complete: |
|
I thought about how the runner was evaluating the spec, and then dusted off some code I used the last time I was testing zio effects for scala native... I think it works now. Instead of using I switched to this the one thing is doesn't have is something corresponding to this part for logging: ... but I imagine it might need some more slight clean up anyway 😄 |
|
So I think the underlying question here is whether we can block for a result. |
This reverts commit fa00047.
|
My current attempts at using I though a could de-duplicate a file, but was wrong - I reverted it, so hopefully the Scala 3 code compiles again. I think the native tests are dying due to heap size... I just found where I can bump that, so I'll adjust. |
|
On the JVM we can block for a result because we actually have multiple threads so at the end of the world if we have to we can just block the thread for the result. We can't do that on Scala.js. |
|
Peaking at the ZIO 1 branch, For the native runner I see: but I don't think it's being called, since it has the I suppose there is was actually calling the default method as well? 🤔 |
|
Yes it ran the generic method. Which raises the question of why your original change made any difference since it clearly blocks for a result to be available. |
|
My original change was to override and not use the default, but instead call the local method. The default is a |
|
Right but that doesn't really make sense because |
|
Nobody said I was making any sense yet 🤣 But, going back to the original behavior of the fail-fast error: from #7833 It seems to die right away while trying to call Just searching around the scala-native repo, in the I see junit-async section I see this which is kind of interesting. (I haven't found much on However, in our runner code: if I use a then it performs like my first change, where the tests hang at |
|
With what's currently in place (less one (and It seems the current outstanding issues are
For 1, it seems like the the updated ZIO 1 code runs these tests synchronously - so is that acceptable here too? Or do we want to dig into that issue further? |
|
Weren't all tests except |
|
I was focusing more on getting passed the |
|
It looks like the failure in test("the value of all fibers in inherited when running many ZIOs with collectAllPar") {
for {
fiberRef <- FiberRef.make[Int](0, _ => 0, _ + _)
_ <- ZIO.collectAllPar(List.fill(100000)(fiberRef.update(_ + 1)))
value <- fiberRef.get
} yield assert(value)(equalTo(100000))
},If I reduce the size from 100,000 to 10,000 the test passes. Could be a problem with resources or there could be something in the platform specific implementation that is algorithmically pathalogical. |
|
It looks like the issue with that test is the default unbounded parallelism. I haven't dug into what the max value I can make it break at is, but the test below (only adding |
|
Edit: |
|
More investigating on (This is all done in the same sbt session) If I do a clean, and then a If I run If I run Some times it hangs, but if I kill it with Absolutely maddening! |
|
I think we need to be addressing the underlying causes of these issues rather than changing the tests. |
|
I agree. For the |
|
👍 |
|
Looking back at the issue of running with I can run this app, and there is no issue: However, if I use these two reproducer specs (i have them locally) with This makes me feel like it's something running the test code, vs "a core ZIO issue". Looking at If I put a log before and after, I can see the before for If I try to add a sleep before running the test, I can see the sleep dies there before the test is run. E.g. i won't see "after sleep" for To be continued... |
|
I think that is the same issue I identified above regarding |
|
Yes, and this was me circling back to it 😁 once we crack that nut, we can tackle the ‘withParallelism’ issue, and then determine if those nonFlaky tests are just resource intensive or not. |
|
😀 Can we reproduce the issue without ZIO? |
|
I've only been able to reproduce it on a narrow subset of ZIO 🙃 I only see it fail when being run in a spec, as part of multiple specs, AND that spec isn't the first run! 😭 I built against a local version of Probably worth investigating some more - I'll see if I can try to recreate the issue outside of ZIO as well. Also, another interesting thing, just running the two tests: It looks like the test case for Spec 1 leaked in? Seeing a Oh, hey - this might be interesting. If I add in a third test I haven't been running yet, The test: The error looks like I might be building Scala native locally tomorrow 😄 |
|
I'm going to convert this to a draft PR so the tests don't run for now. Some updates for visibility: I believe he above error from Going back to square one, if we don't do anything with the specs, and just look at calling Edit - I guess making this a draft PR doesn't stop ci tests from running 😬 |
|
@alterationx10 Hello Mark. Do you think you could resuscitate this PR? It would be awesome to have running tests in ZIO 2 after all that time 😊 |
|
@sideeffffect Yes - this PR still haunts my dreams 😆 I'll try and re-ignite the spark starting next week and see if we can get it done! |
|
We already run tests on Scala Native. |
|
I see, it was this PR #8080 |
|
No problem! Excited to see what you do with it! |
This is an exploration from #7883
For reasons I don't understand, in
ZTestRunnerJS.scalatheTasktrait forZTestTaskexpects methoddef execute(eventHandler: EventHandler, loggers: Array[Logger], continuation: Array[Task] => Unit): Unit, and doesn't call the maindef execute(eventHandler: EventHandler, loggers: Array[Logger]): Array[Task]fromBaseTestTask.In
ZTestRunnerNative.scala, that isn't the case - but there is no override of theexecutemethod, and the default implementation crashes.This PR copies over the JS implementation of execute, and implements
override def execute(eventHandler: EventHandler, loggers: Array[Logger]): Array[Task]which calls it. There was already a non-overriding execute method, however it also seemed to crash, which is why I copied over the JS version.The next peculiarity is considering running the tests:
coreTestsNative/testwill hang at thezio.ZIOSpecsuite, but work viacoreTestsNative/testOnly zio.ZIOSpec.If I remove the first test there:
Then
coreTestsNative/testwill not hang (and passes 🎉 ).I have not yet attempted to run native tests outside of
core-tests.