[Pkg] The Trunk: SUnit-ar.77.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed May 12 03:00:09 UTC 2010
Andreas Raab uploaded a new version of SUnit to project The Trunk:
http://source.squeak.org/trunk/SUnit-ar.77.mcz
==================== Summary ====================
Name: SUnit-ar.77
Author: ar
Time: 11 May 2010, 7:59:58.369 pm
UUID: ff3747cb-e4fb-c749-b9bc-18f796b0e44a
Ancestors: SUnit-ar.76
Fixes timeout handling during debugging. The previous version would issue timeouts when debugging a failing case. The new version suppresses timeout failures after noting a test failure or test error.
=============== Diff against SUnit-ar.76 ===============
Item was changed:
----- Method: TestCase>>runCase (in category 'running') -----
runCase
+ "Run this TestCase. Time out if the test takes too long."
+ [self timeout:[
+ self setUp.
+ self performTest
+ ] after: self timeoutForTest] ensure:[self tearDown].!
- [[self setUp.
- self performTest] ensure: [self tearDown]]
- valueWithin: self timeoutForTest seconds
- onTimeout:[TestFailure signal: 'Test timed out'].
- !
Item was added:
+ ----- Method: TestCase>>timeout:after: (in category 'running') -----
+ timeout: aBlock after: seconds
+ "Evaluate the argument block. Time out if the evaluation is not
+ complete after the given number of seconds. Handle the situation
+ that a timeout may occur after a failure (during debug)"
+
+ | theProcess delay watchdog |
+
+ "the block will be executed in the current process"
+ theProcess := Processor activeProcess.
+ delay := Delay forSeconds: seconds.
+
+ "make a watchdog process"
+ watchdog := [
+ delay wait. "wait for timeout or completion"
+ theProcess ifNotNil:[ theProcess signalException:
+ (TestFailure new messageText: 'Test timed out') ]
+ ] newProcess.
+
+ "Watchdog needs to run at high priority to do its job (but not at timing priority)"
+ watchdog priority: Processor timingPriority-1.
+
+ "catch the timeout signal"
+ watchdog resume. "start up the watchdog"
+ ^[aBlock on: TestFailure do:[:ex|
+ theProcess := nil.
+ ex pass.
+ ]] ensure:[ "evaluate the receiver"
+ theProcess := nil. "it has completed, so ..."
+ delay delaySemaphore signal. "arrange for the watchdog to exit"
+ ]!
More information about the Packages
mailing list