[squeak-dev] The Inbox: SUnit-ct.133.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Fri Dec 31 14:20:42 UTC 2021


Hi Christoph --

Well, looks good. 

+1

Best,
Marcel

Am 29.12.2021 18:38:37 schrieb commits at source.squeak.org <commits at source.squeak.org>:
A new version of SUnit was added to project The Inbox:
http://source.squeak.org/inbox/SUnit-ct.133.mcz

==================== Summary ====================

Name: SUnit-ct.133
Author: ct
Time: 29 December 2021, 6:38:28.060638 pm
UUID: 83af50fb-86e6-d843-8e9e-9abe8e8e379a
Ancestors: SUnit-mt.125

Updates debugging logic of TestCase. Instead of abusing #halt, open a debugger directly on the entrypoint to run the case. Deprecates #openDebuggerOnFailingTestMethod.

Also slightly refactors internal behavior to avoid some duplication, and to get rid of unnecessary semaphores which do not add any value compared to #ensure: unless some really low-level things are broken.

Supersedes SUnit-ct.125. Based on my own experiences from >1.5 years, I have revised #debugAsFailure to always halt right before sending #setUp. This improves a) the explorability of any custom set-up/tear-down logic of the test case and b) the immediacy of opening a debugger if you have a very heavy #setUp implementation. From the user perspective, effectively, you still have to click "Over-into-over-into" to navigate into the actual test method.

Please report back whether you find this behavior acceptable. :-)

=============== Diff against SUnit-mt.125 ===============

Item was added:
+ ----- Method: TestCase>>assureResourcesDuring: (in category 'private') -----
+ assureResourcesDuring: aBlock
+
+ | resources |
+ resources := self resources.
+ resources do: [:resource |
+ resource isAvailable ifFalse: [
+ ^ resource signalInitializationError]].
+ ^ aBlock ensure: [
+ resources do: [:resource |
+ resource reset]].!

Item was changed:
----- Method: TestCase>>debug (in category 'running') -----
debug
+ "Run the receiver and open a debugger on the first failure or error."
+
+ ^ self assureResourcesDuring: [self runCaseWithoutTimeout]!
- self resources do:
- [ : res | res isAvailable ifFalse: [ ^ res signalInitializationError ] ].
- [ self runCase ] ensure:
- [ self resources do:
- [ : each | each reset ] ]!

Item was changed:
----- Method: TestCase>>debugAsFailure (in category 'running') -----
debugAsFailure
+ "Spawn a debugger that is ready to debug the receiver."
+
+ (Process
+ forBlock: [self debug]
+ runUntil: [:context | context isClosureContext "navigate the process directly to the point where it is about to send #setUp"
+ and: [context selector = #runCaseWithoutTimeout]])
+ debug.!
- | semaphore |
- semaphore := Semaphore new.
- self resources do: [:res |
- res isAvailable ifFalse: [^res signalInitializationError]].
- [semaphore wait. self resources do: [:each | each reset]] fork.
- (self class selector: testSelector) runCaseAsFailure: semaphore.!

Item was changed:
----- Method: TestCase>>openDebuggerOnFailingTestMethod (in category 'running') -----
openDebuggerOnFailingTestMethod
+
+ self deprecated: 'ct: Use #debugAsFailure'.
+
"SUnit has halted one step in front of the failing test method. Step over the 'self halt' and
send into 'self perform: testSelector' to see the failure from the beginning"
-
self
halt;
performTest!

Item was changed:
----- Method: TestCase>>runCaseAsFailure: (in category 'running') -----
runCaseAsFailure: aSemaphore
+
+ self deprecated: 'ct: Use #runCaseWithoutTimeout and #ensure:'.
+ ^ [self runCaseWithoutTimeout]
+ ensure: [aSemaphore signal]!
- [self setUp.
- self openDebuggerOnFailingTestMethod] ensure: [
- self tearDown.
- aSemaphore signal]!

Item was added:
+ ----- Method: TestCase>>runCaseWithoutTimeout (in category 'running') -----
+ runCaseWithoutTimeout
+
+ [self setUp.
+ self performTest]
+ ensure: [self tearDown].!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211231/f1702a83/attachment-0001.html>


More information about the Squeak-dev mailing list