Pharo test defects

WeakAnnouncerTest

State
Fixed (image fix)
Defect in
the Pharo image
Tests
1
Fix
image fix 20-WeakAnnouncerTest.st
Upstream repository
pharo-project/pharo

Record

testNoWeakBlock was an expected failure. AnnouncementSubscription>>makeWeak raised 'Not currently available due to missing ephemerons support' for block actions. The test comment states the intended behaviour: there is no weak block, a block subscription never goes away. The fix makes makeWeak return self (stay strong) when the action is a block, and removes the <expectedFailure> pragma from the test. The test body is unchanged. The same defect is in image code, not in either VM. No other code or test in pharo/src depends on the old error.

Test Defect in State Cause
WeakAnnouncerTest>>testNoWeakBlock image-code repaired AnnouncementSubscription>>makeWeak raised an error for block actions instead of keeping the subscription strong, and the test was marked expectedFailure to record that.

Regression check: Measured with runtest.sh, PASS counts before the fix and after the fix, on both ours and cog. WeakAnnouncerTest: 33 before, 34 after, on both VMs. AnnouncerTest: 29 before, 29 after, on both VMs. SubscriptionRegistryTest does not exist (0 and 0). AnnouncementSetTest was not run. makeWeak is called only from WeakAnnouncerTest in the pharo sources.

Upstream note: Title: Announcements: makeWeak on a block subscription stays strong instead of raising an error. Description: AnnouncementSubscription>>makeWeak raised an error for block actions because of missing ephemerons, and WeakAnnouncerTest>>testNoWeakBlock was marked <expectedFailure> although its comment says "there is no such thing as a weak block, these things never go away". makeWeak now returns self for a block action, and the expectedFailure mark is removed. Project: pharo (Announcements-Core, Announcements-Core-Tests). This note is a draft; the owner must review it before any PR is made.

Results

Last full sweeps of 2026-11-17: iospharo (sweep14-new14) and stock Cog with the Cog changes (sweepcogp14-new10), with all image fixes. "Before" is the state of the test before the repairs. The Stock Cog column has a value only where the record measured stock Cog: "PASS 3 of 3 (repair run)" is the check of each repair on stock Cog v12.0.6 with the fix entry; "-" is not measured separately.

TestBeforeStateiospharo VMPatched CogStock Cog
WeakAnnouncerTest>>testNoWeakBlockXFAILrepairedPASSPASSPASS 3 of 3 (repair run)

Test

Run the tests in a Pharo 14 image (build 791). Before the fix they skip, fail or carry the expected-failure mark.

"Run in a Playground of a Pharo 14 image (Do it and print each line)."
((WeakAnnouncerTest selector: #testNoWeakBlock) run) printString.

Source of the tests before the fix

WeakAnnouncerTest>>testNoWeakBlock before the fix (Pharo 14 build 791)
testNoWeakBlock
	"There is no such thing as a weak block, these things never go away."

	<expectedFailure>

	| counter |

	self longTestCase.

	counter := 0.

	(announcer when: AnnouncementMockA do: [ :ann | counter := counter + 1 ] for: self) makeWeak.

	Smalltalk garbageCollect.
	announcer announce: AnnouncementMockA.
	self assert: counter equals: 1.

	Smalltalk garbageCollect.
	announcer announce: AnnouncementMockA.
	self assert: counter equals: 2

Fix

How to apply an entries file: file in 00-header.st and the entries file as one chunk (the iospharo script scripts/gen-image-fixes.py makes that chunk). Each entry checks for the defect first and prints FIXED, ADDED or SKIP. Download 00-header.st.

20-WeakAnnouncerTest.st (download)
"A block action holds its receiver strongly and there are no ephemerons, so a
 block subscription cannot be weak.  makeWeak keeps the subscription strong
 instead of raising an error, as testNoWeakBlock states."
fix value: #AnnouncementSubscription value: #makeWeak
	value: [ :s | s includesSubstring: 'missing ephemerons support' ]
	value: 'makeWeak

	"A block holds its receiver strongly and there are no ephemerons, so there is no weak block subscription: stay strong."
	action isBlock ifTrue: [ ^ self ].

	^ announcer replace: self with:
		(WeakAnnouncementSubscription new
			announcer: announcer;
			action: action asWeakMessageSend;
			subscriber: subscriber;
			announcementClass: announcementClass)'.
fix value: #WeakAnnouncerTest value: #testNoWeakBlock
	value: [ :s | s includesSubstring: '<expectedFailure>' ]
	value: 'testNoWeakBlock
	"There is no such thing as a weak block, these things never go away."

	| counter |

	self longTestCase.

	counter := 0.

	(announcer when: AnnouncementMockA do: [ :ann | counter := counter + 1 ] for: self) makeWeak.

	Smalltalk garbageCollect.
	announcer announce: AnnouncementMockA.
	self assert: counter equals: 1.

	Smalltalk garbageCollect.
	announcer announce: AnnouncementMockA.
	self assert: counter equals: 2'.

State of 2026-11-20. Made from the test records of the iospharo project (a second Pharo VM). The fixes are proposals for review.