scripts/image-fixes/29-code-importer-snippets.stCodeImporterCodeSnippetTest>>testCodeImporter,
OCCodeSnippet class>>badExpressionstestCodeImporter skipped for a source with separators only (2 snippets),
with the remark that the code importer needs a plain expression, and the
snippet ] had a skip mark with a FIXME. CodeImporter handles the three
sources: for the empty source it makes no declaration, for a method chunk
with no source the compiler signals the error that the test expects, and
] has no meaning in the chunk format. The two skips go, and the checks of
the test apply.
| Test | Defect in | State | Cause |
|---|---|---|---|
CodeImporterCodeSnippetTest>>testCodeImporter (3 snippets) |
test | repaired | A skip that the code under test did not need. |
State on our VM: all tests of CodeImporterCodeSnippetTest pass.
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 |
|---|---|---|---|---|---|
CodeImporterCodeSnippetTest>>testCodeImporter | repaired | PASS 353x | PASS 353x | - |
Run the tests in a Pharo 14 image (build 791). Some of these tests are new: the entries file adds them, so file in the entries file first, then run them.
"Run in a Playground of a Pharo 14 image (Do it and print each line)." ((CodeImporterCodeSnippetTest selector: #testCodeImporter) run) printString.
testCodeImporter
| string importer class runBlock |
"Code importer meed a plain expression or use a custom format"
snippet source isAllSeparators ifTrue: [ ^ self skip ].
[
string := snippet isScripting
ifFalse: [
class := ChunkImportTestCase new importAClass.
'!{1} methodsFor: ''some protocol''!{2}' format: {
class name asString.
snippet source } ]
ifTrue: [ snippet source ].
"Note: it might be possible that the snipped messes with the chuck format... to investigate"
importer := CodeImporter fromString: string.
importer parseChunks.
self skipIf: #exec.
"Importer should fail when faulty"
snippet isFaulty ifTrue: [
self should: [ importer evaluate ] raise: OCCompilationError, OCCodeError.
snippet isScripting ifFalse: [ class removeFromSystem ].
^ self ].
"When not faulty, it's more complicated..."
runBlock := [
| value |
value := importer evaluate.
snippet isScripting ifFalse: [
| method phonyArgs |
self assert: value isSymbol.
"Need to call the method, the importer added it to `class`, so retrieve it"
method := class >> value.
class removeFromSystem. "No more needed"
phonyArgs := (1 to: method numArgs) asArray.
value := nil withArgs: phonyArgs executeMethod: method ].
value ].
self testExecuteBlock: runBlock ] ensure: [ self packageOrganizer removePackage: ChunkImportTestCase new packageNameForTests ]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.
"CodeImporterCodeSnippetTest>>testCodeImporter skipped for three code snippets (2026-11-17). The skips are the same on stock Cog and on our VM. C1. The test started with 'snippet source isAllSeparators ifTrue: [ ^ self skip ]', with the remark that the code importer needs a plain expression. An empty chunk and a chunk of separators are legal input of a chunk file, and CodeImporter has code for them: for the empty source it makes no declaration, and for a method chunk with no source the compiler signals an error, which is what the test expects for a snippet with a fault. The skip goes, and the checks of the test apply to the two snippets. C2. The snippet ' ]' had the mark 'skip: #testCodeImporter' with the remark 'FIXME. code importer do not like rogue starting ]'. The chunk format gives ']' no meaning, and the parser handles ')', ']' and '}' at the start of a statement with the same code. The snippets ' )' and ' }' pass the same test. The mark goes." fix value: #CodeImporterCodeSnippetTest value: #testCodeImporter value: [ :source | source includesSubstring: 'isAllSeparators ifTrue: [ ^ self skip ]' ] value: (((CodeImporterCodeSnippetTest >> #testCodeImporter) sourceCode copyReplaceAll: 'snippet source isAllSeparators ifTrue: [ ^ self skip ].' with: '') copyReplaceAll: '"Code importer meed a plain expression or use a custom format"' with: '"An empty source and a source of separators are legal chunk input. The checks below apply to them as to each other snippet."'). fix value: #'OCCodeSnippet class' value: #badExpressions value: [ :source | source includesSubstring: 'skip: #testCodeImporter' ] value: ((OCCodeSnippet class >> #badExpressions) sourceCode copyReplaceAll: 'skip: #testCodeImporter). "FIXME. code importer do not like rogue starting `]`"' with: 'yourself).').
State of 2026-11-20. Made from the test records of the iospharo project (a second Pharo VM). The fixes are proposals for review.