Pharo test defects

Tests that need an interactive session

State
Partly fixed: 4 pass in a normal run; 24 pass only in an interactive run of iospharo (not run on Cog)
Defect in
the Pharo image and the tests
Tests
28
Fix
image fix 22-interactive-session-tests.st
Upstream repository
pharo-project/pharo and pharo-spec/Spec

Stock Cog stopped with a segmentation fault in 1 of 3 interactive runs of MorphicWindowManagerTest: see that Cog page.

Summary

28 tests skip when the test run is not an interactive session (no real display). Six of them asked Smalltalk isHeadless, which always answers true in Pharo 14, so they never ran on any VM. Two tests had defects that showed once they ran: TaskbarMorph>>updateTasks sends hasProperty: to a MorphicNativeWindow (a DNU on our VM and on stock Cog), and SimulateMouseTest>>testSimulateRightClick right-clicks a presenter instead of its morph. With the fix, 4 tests pass in a normal run, and the other 24 pass in an interactive run of our VM (135 of 135 tests of the six classes). No interactive run on Cog is recorded.

Results

TestBeforeiospharo, normal runPatched Cog, normal runiospharo, interactive run
MorphicNativeWindowTest>>testMaximizeWindowSKIPSKIPSKIPPASS
MorphicNativeWindowTest>>testMinimizeWindowSKIPSKIPSKIPPASS
MorphicNativeWindowTest>>testNewWindowDefaultsIsNotMaximizeSKIPSKIPSKIPPASS
MorphicNativeWindowTest>>testNewWindowDefaultsIsNotMinimizedSKIPSKIPSKIPPASS
MorphicNativeWindowTest>>testRestoreWindowSKIPSKIPSKIPPASS
MorphicWindowManagerTest>>testDeleteAllWindowToLeftOfAWindowSKIPSKIPSKIPPASS
MorphicWindowManagerTest>>testDeleteAllWindowToRightOfAWindowSKIPSKIPSKIPPASS
MorphicWindowManagerTest>>testDeleteAWindowAndTaskBarActualizedSKIPSKIPSKIPPASS
OpenToolTest>>testImplementorsOfAtSKIPSKIPSKIPPASS
OpenToolTest>>testInspectArraySKIPSKIPSKIPPASS
OpenToolTest>>testInspectClassSKIPSKIPSKIPPASS
OpenToolTest>>testInspectDictionarySKIPSKIPSKIPPASS
OpenToolTest>>testInspectIntegerSKIPSKIPSKIPPASS
OpenToolTest>>testInspectTraitClassSKIPSKIPSKIPPASS
OpenToolTest>>testOpenBrowseOnClassSKIPSKIPSKIPPASS
OpenToolTest>>testOpenBrowseOnInstalledTraitMethodSKIPSKIPSKIPPASS
OpenToolTest>>testOpenBrowseOnMethodSKIPSKIPSKIPPASS
OpenToolTest>>testOpenBrowseOnTraitMethodSKIPSKIPSKIPPASS
OpenToolTest>>testSendersOfAtSKIPSKIPSKIPPASS
SimulateMouseTest>>testSimulateClickSKIPSKIPSKIPPASS
SimulateMouseTest>>testSimulateMiddleClickSKIPSKIPSKIPPASS
SimulateMouseTest>>testSimulateRightClickSKIPSKIPSKIPPASS
SpTextPresenterTest>>testPropagateNaturalHeightSKIPPASSPASSPASS
SpTextPresenterTest>>testPropagateNaturalHeightWithMultipleLinesSKIPSKIPSKIPPASS
SpTextPresenterTest>>testPropagateNaturalWidthSKIPPASSPASSPASS
SpCodePresenterTest>>testPropagateNaturalHeightSKIPPASSPASSPASS
SpCodePresenterTest>>testPropagateNaturalHeightWithMultipleLinesSKIPSKIPSKIPPASS
SpCodePresenterTest>>testPropagateNaturalWidthSKIPPASSPASSPASS

Test

"Run in a Playground of a Pharo 14 image (Do it and print each line)."
((MorphicNativeWindowTest selector: #testMaximizeWindow) run) printString.
((MorphicNativeWindowTest selector: #testMinimizeWindow) run) printString.
((MorphicNativeWindowTest selector: #testNewWindowDefaultsIsNotMaximize) run) printString.
((MorphicNativeWindowTest selector: #testNewWindowDefaultsIsNotMinimized) run) printString.
((MorphicNativeWindowTest selector: #testRestoreWindow) run) printString.
((MorphicWindowManagerTest selector: #testDeleteAllWindowToLeftOfAWindow) run) printString.
((MorphicWindowManagerTest selector: #testDeleteAllWindowToRightOfAWindow) run) printString.
((MorphicWindowManagerTest selector: #testDeleteAWindowAndTaskBarActualized) run) printString.
((OpenToolTest selector: #testImplementorsOfAt) run) printString.
((OpenToolTest selector: #testInspectArray) run) printString.
((OpenToolTest selector: #testInspectClass) run) printString.
((OpenToolTest selector: #testInspectDictionary) run) printString.
((OpenToolTest selector: #testInspectInteger) run) printString.
((OpenToolTest selector: #testInspectTraitClass) run) printString.
((OpenToolTest selector: #testOpenBrowseOnClass) run) printString.
((OpenToolTest selector: #testOpenBrowseOnInstalledTraitMethod) run) printString.
((OpenToolTest selector: #testOpenBrowseOnMethod) run) printString.
((OpenToolTest selector: #testOpenBrowseOnTraitMethod) run) printString.
((OpenToolTest selector: #testSendersOfAt) run) printString.
((SimulateMouseTest selector: #testSimulateClick) run) printString.
((SimulateMouseTest selector: #testSimulateMiddleClick) run) printString.
((SimulateMouseTest selector: #testSimulateRightClick) run) printString.
((SpTextPresenterTest selector: #testPropagateNaturalHeight) run) printString.
((SpTextPresenterTest selector: #testPropagateNaturalHeightWithMultipleLines) run) printString.
((SpTextPresenterTest selector: #testPropagateNaturalWidth) run) printString.
((SpCodePresenterTest selector: #testPropagateNaturalHeight) run) printString.
((SpCodePresenterTest selector: #testPropagateNaturalHeightWithMultipleLines) run) printString.
((SpCodePresenterTest selector: #testPropagateNaturalWidth) run) printString.

Start the image with a display (stock Cog: no --headless; iospharo: PHARO_INTERACTIVE=1).

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.

22-interactive-session-tests.st (download)
"Fixes for the tests that skip because the test run is not an interactive
 session (2026-11-17).  With these entries and an interactive session
 (PHARO_INTERACTIVE=1 on our VM, a start without --headless on stock Cog) the
 28 tests of the group run.

 1. SpTextPresenterTest (and SpCodePresenterTest, which inherits the tests):
    testPropagateNaturalHeight, testPropagateNaturalHeightWithMultipleLines,
    testPropagateNaturalWidth began with `Smalltalk isHeadless ifTrue: [ ^ self skip ]`.
    In Pharo 14 SmalltalkImage>>isHeadless is deprecated and always answers
    true, so the 6 tests never ran on any VM.  The tests open a presenter in
    the Morphic world and compare widget sizes against font metrics; they need
    no native window.  Two of the three need no interactive session: the guard is
    removed.  testPropagateNaturalHeightWithMultipleLines needs a real display
    size (the fake-GUI world is 240@120, too small for six lines): its guard
    becomes isInteractive, as the deprecation text asks.
 2. MorphicWindowManagerTest>>testDeleteAWindowAndTaskBarActualized:
    TaskbarMorphForManager answers the manager's MorphicNativeWindow objects as
    its windows; TaskbarMorph>>updateTasks asks each task's morph
    `hasProperty: #isClosed`, which a MorphicNativeWindow does not understand
    (stock Cog: same DNU).  A native window answers #isClosed itself.
 3. SimulateMouseTest>>testSimulateRightClick: `Smalltalk tools toolNamed:
    #workspace) open` answers an StWindowPresenter in Pharo 14, not a Morph, so
    `simulateRightClick` is not understood (stock Cog: same DNU).  The test
    right-clicks the morph of the window: the window presenter's widget."

"These two need no interactive session: they pass in the fake-GUI world."
#( #testPropagateNaturalHeight #testPropagateNaturalWidth ) do: [ :sel |
	fix value: #SpTextPresenterTest value: sel
		value: [ :src | src includesSubstring: 'Smalltalk isHeadless ifTrue: [ ^ self skip ].' ]
		value: ((SpTextPresenterTest >> sel) sourceCode
			copyReplaceAll: 'Smalltalk isHeadless ifTrue: [ ^ self skip ].' with: '') ].

"This one needs a real display: it asserts a widget height of six text lines,
 and the fake-GUI world is 240@120 (widget height 47 on both VMs).  It runs in an
 interactive session, where the display is large enough."
fix value: #SpTextPresenterTest value: #testPropagateNaturalHeightWithMultipleLines
	value: [ :src | src includesSubstring: 'Smalltalk isHeadless ifTrue: [ ^ self skip ].' ]
	value: ((SpTextPresenterTest >> #testPropagateNaturalHeightWithMultipleLines) sourceCode
		copyReplaceAll: 'Smalltalk isHeadless ifTrue: [ ^ self skip ].'
		with: 'Smalltalk isInteractive ifFalse: [ ^ self skip ].').

"The new text holds the old text, so the guard also asks that the fix is not there."
fix value: #TaskbarMorph value: #updateTasks
	value: [ :src | (src includesSubstring: 'task morph hasProperty: #isClosed')
		and: [ (src includesSubstring: 'task morph isMorph') not ] ]
	value: ((TaskbarMorph >> #updateTasks) sourceCode
		copyReplaceAll: 'task morph hasProperty: #isClosed'
		with: '(task morph isMorph
					                              ifTrue: [ task morph hasProperty: #isClosed ]
					                              ifFalse: [ task morph isClosed ])').

fix value: #SimulateMouseTest value: #testSimulateRightClick
	value: [ :src | (src includesSubstring: 'adapter widget') not ]
	value: 'testSimulateRightClick

	| menu |
	morph := (Smalltalk tools toolNamed: #workspace) open adapter widget.
	menu := self menuOpenedDuring: [ morph simulateRightClick ].
	self assert: menu isNil not'.

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