Christoph Thiede uploaded a new version of SUnit to project The Trunk: http://source.squeak.org/trunk/SUnit-ct.135.mcz
==================== Summary ====================
Name: SUnit-ct.135 Author: ct Time: 16 January 2022, 9:40:03.045332 pm UUID: 0e341764-d837-c94c-b5f5-c360f5bff1e6 Ancestors: SUnit-ct.134, SUnit-ct.129, SUnit-ct.130
Merge commit.
SUnit-ct.129: Catch warnings and halts in test case execution as well as Errors.
SUnit-ct.130: Deprecates TestResult class >> #error and replaces sends to it with #exError. It is a bad and erroneous practice to override #error in a way that does not signal an error but returns a class object.
=============== Diff against SUnit-ct.134 ===============
Item was changed: ----- Method: SUnitTest>>testDialectLocalizedException (in category 'tests') ----- testDialectLocalizedException
self should: [TestResult signalFailureWith: 'Foo'] raise: TestResult failure. self should: [TestResult signalErrorWith: 'Foo'] + raise: TestResult exError.! - raise: TestResult error. - - !
Item was changed: ----- Method: SUnitTest>>testException (in category 'tests') ----- testException
self should: [self error: 'foo'] + raise: TestResult exError! - raise: TestResult error - !
Item was changed: ----- Method: SUnitTest>>testWithExceptionDo (in category 'tests') ----- testWithExceptionDo
self should: [self error: 'foo'] + raise: TestResult exError - raise: TestResult error withExceptionDo: [:exception | self assert: (exception description includesSubstring: 'foo') + ]! - ] - !
Item was changed: ----- Method: TestCase>>timeout:after: (in category 'private') ----- 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' translated) ] - (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, TestResult allErrors do: [:ex| - ^[aBlock on: TestFailure, Error, Halt 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" ]!
Item was added: + ----- Method: TestResult class>>allErrors (in category 'exceptions') ----- + allErrors + ^ self exError, Warning, Halt + !
Item was changed: ----- Method: TestResult class>>error (in category 'exceptions') ----- error + + self deprecated: 'ct: Send #exError to retrieve an exception class or #error: to signal an error, depending on what you need.'. + ^ super error! - ^self exError - !
Item was added: + ----- Method: TestResult class>>exAllErrors (in category 'exceptions') ----- + exAllErrors + ^ self exError, Warning, Halt + !
Item was changed: ----- Method: TestResult class>>signalErrorWith: (in category 'exceptions') ----- signalErrorWith: aString + ^ self exError signal: aString! - self error signal: aString - !
Item was changed: ----- Method: TestResult>>runCase: (in category 'running') ----- runCase: aTestCase | testCasePassed timeToRun | testCasePassed := true.
[timeToRun := [aTestCase runCase] timeToRunWithoutGC] on: self class failure do: [:signal | failures add: aTestCase. testCasePassed := false. signal return: false] + on: self class allErrors - on: self class error do: [:signal | errors add: aTestCase. testCasePassed := false. signal return: false]. testCasePassed ifTrue: [passed add: aTestCase]. self durations at: aTestCase put: timeToRun.!
squeak-dev@lists.squeakfoundation.org