Skip to content
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

If you can’t beat ’em, join ’em #3225

Merged
merged 1 commit into from May 1, 2019

Conversation

jnm2
Copy link
Contributor

@jnm2 jnm2 commented Apr 30, 2019

Fixes #3222. It would be nice to figure out why thread aborting hasn't worked for us on Mono in the last ten years, but I should have excluded Mono in #2023 for my test as well, since it's just a fancier version of:

[Test]
[Platform(Exclude = "Mono", Reason = "Runner hangs at end when this is run")]
public void TestTimesOutAndTearDownIsRun()
{
TimeoutFixture fixture = new TimeoutFixture();
TestSuite suite = TestBuilder.MakeFixture(fixture);
TestMethod testMethod = (TestMethod)TestFinder.Find("InfiniteLoopWith50msTimeout", suite, false);
ITestResult result = TestBuilder.RunTest(testMethod, fixture);
Assert.That(result.ResultState, Is.EqualTo(ResultState.Failure));
Assert.That(result.Message, Does.Contain("50ms"));
Assert.That(fixture.TearDownWasRun, "TearDown was not run");
}

[Test, Timeout(50)]
public void InfiniteLoopWith50msTimeout()
{
while (true) { }
}
[Test, Timeout(500)]
public void TimeoutWithMessagePumpShouldAbort()
{
// Simulate System.Windows.Forms.Application.Run or .ShowDialog,
// or System.Windows.Threading.Dispatcher.PushFrame,
// which block on native calls to WaitMessage or MsgWaitForMultipleObjectsEx.
while (true)
WaitMessage();
}
[DllImport("user32.dll")]
private static extern bool WaitMessage();

@jnm2 jnm2 requested a review from a team April 30, 2019 00:51
Copy link
Contributor

@CharliePoole CharliePoole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny thing... I just assumed you knew it had been a problem and were ultra-determined to fix it!

Your idea about Mono not supporting multiple thread aborts is worth checking out some time.

Copy link
Member

@mikkelbu mikkelbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but cannot kick Azure from this computer.

@jnm2
Copy link
Contributor Author

jnm2 commented Apr 30, 2019

@CharliePoole I'd sure like to eventually. @rprouse is waiting for my custom awaitables PR and I'm trying to only do things that get me closer to figuring out where its unexpected thread abort is coming from.

@jnm2 jnm2 merged commit 8a6245b into nunit:master May 1, 2019
@jnm2 jnm2 deleted the test_should_also_be_excluded_on_mono branch May 12, 2019 02:49
@jnm2
Copy link
Contributor Author

jnm2 commented May 12, 2019

Funny thing... I just assumed you knew it had been a problem and were ultra-determined to fix it!

Guess what? I was ultra-determined to fix #3095 and in fixing it, I accidentally fixed all these tests too! It's a nice reward for a frustrating and time-consuming search. In addition to learning a few things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Our build script tests hang when run with Mono on Windows
3 participants