-
Notifications
You must be signed in to change notification settings - Fork 751
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
Some tests depend on a SynchronizationContext #1885
Comments
Apparently supplying a SynchronizationContext isn't enough to prevent the EventLoop_ScheduleActionNested and EventLoop_ScheduleActionDue tests from hanging on the build agent. We'll need to fix this properly, so #1885 will track this
I only know two operators that directly depend on the synchronization context, namely |
I don't think it's operators that are the problem. Some of the The operators you mention aren't ones I've seen in any test failures. (There are tests for these that set up a So the thing I'm trying to work out is what the expected behaviour of the code in (I'm also still trying to work out why those two |
I've discovered that reason I guess this happens because some test somewhere created a The effect of this on |
The
TaskLikeSupportTest.Basics
test, and theEventLoop_ScheduleActionDue
andEventLoop_ScheduleActionNested
tests inEventLoopSchedulerTest
were hanging sporadically after moving from xUnit to MSTest. This is indicative of some underlying problem—the success or failure of a test shouldn't depend on which particular test framework you are using.One difference between the test frameworks is that xUnit always supplies a non-null
SynchronizationContext.Current
to tests (apparently to supportasync void
tests). MSTest does not. (It supplies a code analyzer that detectsasync void
tests and tells you not to use them.) The presence of a synchronization context can cause Rx to execute different code paths,.This appears to be why the
TaskLikeSupportTest.Basics
test was failing. We've modified the code to set up aSynchronizationContext
explicitly, and this appears to have got rid of the hange, but this is only a workaround. We need to establish whether there's something about the test that truly requires aSynchronizationContext
for the code to be valid (which is possible, but if so, it's not obvious why), or whether we really should expect it to work with or without aSynchronizationContext
. If it's the latter, that indicates a subtle bug somewhere, in which case the long term solution should be to have two forms of the test, one with theSynchronizationContext
and one without, and make whatever fix is required for the test to pass reliably on both.As for the two problematic tests in
EventLoopSchedulerTest
, these continued to hang even after explicitly setting up aSynchronizationContext
. So whatever it is about xUnit that was different that they depended on, it apparently wasn't just the presence/absence of aSynchronizationContext
.For now, those two tests have been annotated with
[Ignore]
so that we can move forward, but these problems need to be fixed properly.The text was updated successfully, but these errors were encountered: