Pharo test defects

NavigationInteractionTest

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

Record

The test called self skip with the comment "not possible to simply write a test for the normal case". Removing the skip showed three separate defects. (1) The test used an unbuilt ClyFullBrowserMorph new, whose defaultNavigationScope fails with SubclassResponsibility (ClyUnknownScope>>representsScope:) because packageView is not built. (2) ClyBrowserMorph>>spawnQueryBrowserOn:withState: spawned (Smalltalk tools toolNamed: #messageList), which in Pharo 14 is the NewTools StMethodBrowser. StMethodBrowser does not understand the Calypso protocol on:systemScope:, so the method fails with doesNotUnderstand. Every caller of spawnQueryBrowserOn: is affected (ClyTextEditor, the implementors/senders navigation). (3) ClyBrowserMorph>>browseImplementorsOf:inNameResolver: returned the bare symbol #NormalImplementorBrowse, while the class branch returns { browser. symbol }, which is the shape the test reads with res first / res second. The fix spawns ClyQueryBrowserMorph (the class that has on:systemScope:, queryScopes: and showResultOf:), makes browseImplementorsOf:inNameResolver: return { spawnedBrowser. #NormalImplementorBrowse }, and rewrites the test to open a real browser with ClyFullBrowserMorph openOnClass: Object. The test closes both browsers in an ensure: block. The assertion on res second is unchanged, and an assertion that res first is not nil was added.

Test Defect in State Cause
NavigationInteractionTest>>testBrowseMethodViaImplementorActuallyBrowseTheClass image-code repaired Skipped by the test itself. The test used an unbuilt browser. spawnQueryBrowserOn:withState: used the NewTools StMethodBrowser, which lacks on:systemScope:. browseImplementorsOf:inNameResolver: returned a bare symbol instead of { browser. symbol }.

Regression check: NavigationInteractionTest (3 tests) on both ours and cog with the fix: 3 of 3 pass, 3 runs each. Before the fix: 2 pass, 1 skip. ClyQueryBrowserStateTest on both VMs: 13 PASS before and 13 PASS after. I also ran ClyFullBrowserMorphTest, ClyBrowserMorphTest, ClyNavigationHistoryTest and ClyTextEditorTest. They gave 0 passes before and after, on both VMs. ClyNavigationHistoryTest exists in the sources but its run printed only "RT| DONE", and I did not find out why it has no tests; I did not check whether the other three classes exist in the image. Only the JIT-on build (ours) and Cog were run, not ours-nojit. No other test class covering spawnQueryBrowserOn: was found in the Pharo sources.

Upstream note: Title: Calypso: spawnQueryBrowserOn:withState: uses the NewTools message list, which does not speak the Calypso protocol; enable NavigationInteractionTest>>testBrowseMethodViaImplementorActuallyBrowseTheClass. Project: pharo (Calypso-SystemTools-QueryBrowser and Calypso-Browser-Tests). ClyBrowserMorph>>spawnQueryBrowserOn:withState: calls "Smalltalk tools toolNamed: #messageList", which is now StMethodBrowser. StMethodBrowser class does not understand #on:systemScope:, so any implementors or senders navigation from a Calypso browser fails with doesNotUnderstand. The fix spawns ClyQueryBrowserMorph directly. browseImplementorsOf:inNameResolver: now returns { browser. #NormalImplementorBrowse }, like its class branch. The test opened a bare ClyFullBrowserMorph new, which cannot compute defaultNavigationScope; it now opens a real browser with openOnClass: and closes both browsers. The self skip is removed. Needs human review before any upstream PR.

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
NavigationInteractionTest>>testBrowseMethodViaImplementorActuallyBrowseTheClassSKIPrepairedPASSPASSPASS 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)."
((NavigationInteractionTest selector: #testBrowseMethodViaImplementorActuallyBrowseTheClass) run) printString.

Source of the tests before the fix

NavigationInteractionTest>>testBrowseMethodViaImplementorActuallyBrowseTheClass before the fix (Pharo 14 build 791)
testBrowseMethodViaImplementorActuallyBrowseTheClass

	| browser res |
	self skip.
	"This is not possible to simply write a test for the normal case... how sad!!!"
	browser := ClyFullBrowserMorph new.
	res := (browser browseImplementorsOf: #add: inNameResolver: Object).
	"this does not work with inNameResolver: nil"
	self assert: res second equals: #NormalImplementorBrowse.
	res first close

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-NavigationInteractionTest.st (download)
fix value: #ClyBrowserMorph value: #browseImplementorsOf:inNameResolver: value: [ :s | (s includesSubstring: 'spawned') not and: [ s includesSubstring: '^ #NormalImplementorBrowse' ] ] value: 'browseImplementorsOf: aSymbol inNameResolver: aNameResolver
	| classBinding classToBrowse spawned |
	aSymbol first isUppercase ifTrue: [
		aNameResolver 
			ifNil: [ classToBrowse := self class environment at: aSymbol.
						^ { ClyFullBrowserMorph openOnClass: classToBrowse.
						#BrowseClassWithoutNameResolver} ]
			ifNotNil: [ 
		classBinding := aNameResolver bindingOf: aSymbol.
	   
		classBinding ifNotNil: [
			classToBrowse := classBinding definingClass ifNil: [ classBinding value ].
			classToBrowse isClassOrTrait ifFalse: [ classToBrowse := classToBrowse class ].
			self spawnBrowser: ClyFullBrowserMorph withState: [ :browser |
				browser selectClass: classToBrowse].
			^ #NormalBrowseClass ] ] ].

	self
		spawnQueryBrowserOn: (ClyMessageImplementorsQuery of: aSymbol)
		withState: [ :browser | spawned := browser ].
	^ { spawned. #NormalImplementorBrowse }'.
fix value: #ClyBrowserMorph value: #spawnQueryBrowserOn:withState: value: [ :s | s includesSubstring: 'toolNamed: #messageList' ] value: 'spawnQueryBrowserOn: aQuery withState: navigationBlock
	| targetQuery |
	targetQuery := aQuery.
	aQuery isBoundToEnvironment ifFalse: [
		targetQuery := aQuery withScope: self defaultNavigationScope].

	targetQuery scope = self systemScope ifTrue: [
		"If query is empty in system (global) scope then it is empty in any other scope.
		In that case we do not need a query browser because it will be always empty and useless"
		targetQuery semiAsync hasEmptyResult ifTrue: [
			"For slow queries we will not wait and open a browser to indicate execution progress"
			^ InformativeNotification signal:  ''There are no '', targetQuery description ]  ].

	"The message list tool of the Smalltalk tools registry is the NewTools StMethodBrowser, which does not
	understand the Calypso protocol used here (on:systemScope:, queryScopes:, showResultOf:).  The Calypso
	query browser does."
	self 
		spawnBrowser: ClyQueryBrowserMorph
		withState: [ :browser |
			browser queryScopes: self allNavigationScopes.
			browser showResultOf: targetQuery.
			navigationBlock valueWithPossibleArgs: {browser} ]'.
fix value: #NavigationInteractionTest value: #testBrowseMethodViaImplementorActuallyBrowseTheClass value: [ :s | s includesSubstring: 'self skip' ] value: 'testBrowseMethodViaImplementorActuallyBrowseTheClass

	| browser res |
	"The browser must be built and opened: the method implementors query is scoped by the package view of the full browser."
	browser := ClyFullBrowserMorph openOnClass: Object.
	[ res := browser browseImplementorsOf: #add: inNameResolver: Object.
	self assert: res second equals: #NormalImplementorBrowse.
	self assert: res first isNotNil ] ensure: [
		res ifNotNil: [ res first ifNotNil: [ :spawned | spawned close ] ].
		browser close ]'.

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