nunit / nunitv2

NUnit 2.x repository. NUnit V2 IS NO LONGER MAINTAINED OR UPDATED. Bugs should be reported in the main NUnit 3.0 repository.
https://github.com/nunit/nunit
Other
25 stars 26 forks source link

Test with infinite loop in TearDown cannot be aborted #26

Closed CharliePoole closed 9 years ago

CharliePoole commented 9 years ago

Pursuant to a discussion on an NUnit 3.0 issue, I added some tests to V2 in order to see the behavior of tests that caused a timeout because of a hung SetUp or a hung TearDown. An infinite loop in the SetUp is handled the same as one in the test but a loop in TearDown causes the entire run to hang.

The cause of this phenomenon is that we run TearDown out of a finally clause. Code in a finally clause is not interupted by a ThreadAbortExceptiopn.

It appears that there are three options:

  1. Don't run TearDown in a finally clause.
  2. Don't use Thread.Abort to cancel a test that times out.
  3. Have NUnit host the CLR and thereby gain the ability to escalate aborts.

All of these options are pretty complex so it's not clear that we will be able to fix this in NUnit 2.6.4. We most likely will do something for 3.0.

rprouse commented 9 years ago

I think that this is too deep of a change to include in a revision point release and should be left for 3.0

CharliePoole commented 9 years ago

I agree. In particular, this is a problem that has been there for years and nobody has ever reported. It only found as a result of examining the code.