scripts/image-fixes/20-SpCodePresenterTest.stSpCodePresenter>>evaluate:onCompileError:onError:permitUndeclared: (added), SpCodePresenter>>evaluate:onCompileError:onError:, SpCodePresenter>>doBrowseClass, SpCodePresenterTest>>testDoBrowseClassNotFound, SpCodePresenterTest>>testDoBrowseMethodReferences, SpCodePresenterTest>>testEnvironmentAll three tests skipped themselves. Removing the skip showed three different causes. (1) testDoBrowseMethodReferences: the skip comment claims a blocking dialogue, but the test passes without the skip on both VMs (about 0.2 to 0.6 s), so the skip is only removed. (2) testDoBrowseClassNotFound: SpCodePresenter>>doBrowseClass evaluates the selected text with the interactive compiler, and an unknown class name makes OCCodeReparator open a modal "Unknown variable" menu (Define new class, ...). In the headless fake-GUI world the menu construction (PopupChoiceDialogWindow>>newChoicesMorph) spins for about 10 s on both VMs, because the world is 240x120 and maxLines evaluates to 0, so "str next: 0" never advances the stream; the test only "passed" after that timeout. On a real display the menu would wait for the user. Fix: add SpCodePresenter>>evaluate:onCompileError:onError:permitUndeclared: (the old selector delegates with false) and make doBrowseClass use it with true and return on OCUndeclaredVariableWarning, so browsing a class never offers to define one. The test now runs in 0.2 to 0.5 s and I added an assertion that browseClass is nil. (3) testEnvironment: doBrowseClass ignored the presenter environment. The environment only reaches Opal as a fallback behind the scope lookup, so 'OrderedCollection' still resolved and was browsed. The Symbol branch also asked "self class environment" instead of "self environment". Fix: doBrowseClass uses self environment, and browses a class value only if the presenter environment holds that class (anonymous classes are exempt). The skip and its comment are removed and the original assertions are unchanged.
| Test | Defect in | State | Cause |
|---|---|---|---|
SpCodePresenterTest>>testDoBrowseClassNotFound |
image-code | repaired | doBrowseClass opened the interactive undeclared-variable menu of OCCodeReparator for an unknown class name; the test skipped itself because of that dialog. Same behaviour on both VMs. The menu also hangs about 10 s in the fake-GUI world, where the 240x120 world makes maxLines 0 and newChoicesMorph loops. |
SpCodePresenterTest>>testDoBrowseMethodReferences |
test | repaired | Obsolete skip: the comment claims that doBrowseMethodReferences opens a blocking dialogue. Measured with the skip removed: no dialogue, the test passes on both VMs. |
SpCodePresenterTest>>testEnvironment |
image-code | repaired | SpCodePresenter>>doBrowseClass ignored the presenter environment: the compiler environment is only a fallback after the scope lookup, so OrderedCollection was found and browsed, and the Symbol branch asked 'self class environment'. Without the skip the test failed with Assertion failed on both VMs (measured with a copy of the test). |
Regression check: I ran 16 test classes on both VMs, once on the base image and once on the fixed image. The classes were SpCodePresenterTest, SpCodeAdapterTest, SpCodeCommandTest, SpCodeEditorPresenterTest, five SpCodeInteractionModelTest classes (Behavior, Method, Null, Object, Scripting) plus SpCodeInteractionModelTest, SpTextPresenterTest and five StPlayground classes (Presenter, InteractionModel, BindingAdd, BindingModification, BindingsPresenter). Result on our VM and on Cog is the same: SpCodePresenterTest goes from 62 pass / 6 skip to 65 pass / 3 skip (the 3 remaining skips are other tests, outside this cluster). Every other class has identical counts before and after, with no new failure. SpCodeInteractionModelTest has 4 errors both before and after, on both VMs, and I did not look into them. Ran on the JIT-on default of our VM only; I did not run ours-nojit.
Upstream note: Spec2 / Pharo: (a) SpCodePresenter>>doBrowseClass must not open the interactive "Unknown variable" menu. Add SpCodePresenter>>evaluate:onCompileError:onError:permitUndeclared:, and have doBrowseClass use it with true and return on OCUndeclaredVariableWarning. (b) doBrowseClass should use the presenter environment (self environment) and browse a class only if that environment holds it. This lets SpCodePresenterTest unskip testDoBrowseClassNotFound and testEnvironment, and unskip testDoBrowseMethodReferences, which already passes. Pharo (not Spec2, separate small bug): PopupChoiceDialogWindow>>newChoicesMorph loops forever when "currentWorld height - 100 // 2 // button height" is 0 (a small world), because "str next: 0" does not advance the stream. It needs a "max: 1". This is not part of the fix file. Nothing was sent upstream; the owner must review it first.
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.
| Test | Before | State | iospharo VM | Patched Cog | Stock Cog |
|---|---|---|---|---|---|
SpCodePresenterTest>>testDoBrowseClassNotFound | SKIP | repaired | PASS | PASS | PASS 3 of 3 (repair run) |
SpCodePresenterTest>>testDoBrowseMethodReferences | SKIP | repaired | PASS | PASS | PASS 3 of 3 (repair run) |
SpCodePresenterTest>>testEnvironment | SKIP | repaired | PASS | PASS | PASS 3 of 3 (repair run) |
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)." ((SpCodePresenterTest selector: #testDoBrowseClassNotFound) run) printString. ((SpCodePresenterTest selector: #testDoBrowseMethodReferences) run) printString. ((SpCodePresenterTest selector: #testEnvironment) run) printString.
testDoBrowseClassNotFound | navigation | "in fact, compiling a non existing class is popping a a dialog to choose what to do (I hate that). Until that is fixed, this test is useless." self skip. navigation := SpCodeSystemNavigationMock new. presenter systemNavigation: navigation. self openInstance. presenter text: 'ClassThatDoesNotExits'. presenter doBrowseClass. self assert: navigation messageList isNil
testDoBrowseMethodReferences | navigation | navigation := SpCodeSystemNavigationMock new. presenter systemNavigation: navigation. presenter environment add: SpCodePresenterTest binding. presenter environment add: SpCodeSystemNavigationMock binding. self openInstance. presenter text: 'Object'. self skip: 'This next line is currently opening a dialogue that is blocking the test. We skip it for now but we should be able to bring it back soon becaue the informations should be changed from a dialogue to a growl morph that does not block the UI thread.'. presenter doBrowseMethodReferences. self assert: navigation messageList isNil. navigation reset. presenter text: 'SpCodeSystemNavigationMock'. presenter doBrowseMethodReferences. self assert: navigation messageList notEmpty. self assert: (navigation messageList includes: SpCodePresenterTest >> #testDoBrowseMethodReferences)
testEnvironment | environment navigation | "Since the environment is not actually working, this is hard to test for now" self skip. environment := self newEnvironment. navigation := SpCodeSystemNavigationMock new. presenter environment: environment. presenter systemNavigation: navigation. self openInstance. "we will find Object but not OrderedCollection" presenter text: 'Object'. presenter doBrowseClass. self assert: navigation browseClass equals: Object. navigation reset. presenter text: 'OrderedCollection'. presenter doBrowseClass. self assert: navigation browseClass isNil
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.
"SpCodePresenterTest cluster: three tests that skip themselves.
1. testDoBrowseClassNotFound: doBrowseClass evaluated the selected text with
the interactive compiler. An unknown class name made OCCodeReparator open
a modal 'Unknown variable' choice menu ('Define new class', ...). Browsing a
class must never offer to define one. Fix: SpCodePresenter gets
evaluate:onCompileError:onError:permitUndeclared:, and doBrowseClass uses it
and returns when the text names an undeclared variable.
2. testEnvironment: doBrowseClass ignored the presenter environment (it only
asked the class environment for Symbols; a class value was browsed whatever
the environment). Fix: doBrowseClass browses a class only when the
presenter environment holds it.
3. testDoBrowseMethodReferences: the skip said a dialogue blocks the test. The
test passes without the skip (measured on both VMs), so the skip is only
removed."
(Smalltalk globals includesKey: #SpCodePresenter) ifTrue: [
"--- code under test ---"
add value: #SpCodePresenter value: #'evaluate:onCompileError:onError:permitUndeclared:' value: 'evaluating'
value: (((SpCodePresenter >> #evaluate:onCompileError:onError:) sourceCode
copyReplaceAll: 'evaluate: aString onCompileError: compileErrorBlock onError: errorBlock '
with: 'evaluate: aString onCompileError: compileErrorBlock onError: errorBlock permitUndeclared: aBoolean')
copyReplaceAll: 'source: aString;'
with: 'source: aString;
permitUndeclared: aBoolean;').
fix value: #SpCodePresenter value: #'evaluate:onCompileError:onError:'
value: [ :src | (src includesSubstring: 'permitUndeclared') not ]
value: 'evaluate: aString onCompileError: compileErrorBlock onError: errorBlock
"evaluate aString.
evaluate compileErrorBlock if there are compilation errors.
evaluate errorBlock is anything happens *during* evaluation (code compiled, but it does not
executes.). See #evaluate:onCompileError:onError:permitUndeclared: for the details."
^ self
evaluate: aString
onCompileError: compileErrorBlock
onError: errorBlock
permitUndeclared: false'.
fix value: #SpCodePresenter value: #doBrowseClass
value: [ :src | (src includesSubstring: 'permitUndeclared') not ]
value: 'doBrowseClass
| result |
"An unknown name must not open the interactive menu of the compiler (it offers to define a class): there is nothing to browse."
result := [ self
evaluate: self selectedTextOrLine
onCompileError: [ ^ self ]
onError: [ :e | ^ self ]
permitUndeclared: true ]
on: OCUndeclaredVariableWarning
do: [ :warning | ^ self ].
(result isKindOf: Symbol)
ifTrue: [
| classToBrowse |
classToBrowse := self environment at: result ifAbsent: [ nil ].
classToBrowse ifNotNil: [ ^ self systemNavigation browse: classToBrowse ] ].
"Only the classes of the environment of the presenter can be browsed"
(result isKindOf: Behavior) ifTrue: [ | instanceSide |
instanceSide := result instanceSide.
(instanceSide isAnonymous not
and: [ (self environment at: instanceSide name ifAbsent: [ nil ]) ~~ instanceSide ])
ifTrue: [ ^ self ] ].
self systemNavigation browse: result'.
"--- tests ---"
fix value: #SpCodePresenterTest value: #testDoBrowseClassNotFound
value: [ :src | src includesSubstring: 'self skip' ]
value: 'testDoBrowseClassNotFound
| navigation |
navigation := SpCodeSystemNavigationMock new.
presenter systemNavigation: navigation.
self openInstance.
presenter text: ''ClassThatDoesNotExits''.
presenter doBrowseClass.
self assert: navigation browseClass isNil.
self assert: navigation messageList isNil'.
fix value: #SpCodePresenterTest value: #testDoBrowseMethodReferences
value: [ :src | src includesSubstring: 'self skip' ]
value: 'testDoBrowseMethodReferences
| navigation |
navigation := SpCodeSystemNavigationMock new.
presenter systemNavigation: navigation.
presenter environment add: SpCodePresenterTest binding.
presenter environment add: SpCodeSystemNavigationMock binding.
self openInstance.
presenter text: ''Object''.
presenter doBrowseMethodReferences.
self assert: navigation messageList isNil.
navigation reset.
presenter text: ''SpCodeSystemNavigationMock''.
presenter doBrowseMethodReferences.
self assert: navigation messageList notEmpty.
self assert: (navigation messageList includes: SpCodePresenterTest >> #testDoBrowseMethodReferences)'.
fix value: #SpCodePresenterTest value: #testEnvironment
value: [ :src | src includesSubstring: 'self skip' ]
value: 'testEnvironment
| environment navigation |
environment := self newEnvironment.
navigation := SpCodeSystemNavigationMock new.
presenter environment: environment.
presenter systemNavigation: navigation.
self openInstance.
"we will find Object but not OrderedCollection"
presenter text: ''Object''.
presenter doBrowseClass.
self assert: navigation browseClass equals: Object.
navigation reset.
presenter text: ''OrderedCollection''.
presenter doBrowseClass.
self assert: navigation browseClass isNil'.
].
State of 2026-11-20. Made from the test records of the iospharo project (a second Pharo VM). The fixes are proposals for review.