Pharo test defects

Package: PharoWiki (chicoary/PharoWiki, row 26)

State
Fixed (package repair)
Defect in
see the record
Tests
0
Fix
chicoary-pharowiki.st, chicoary-pharowiki.patch
Upstream repository
chicoary/PharoWiki

The record is the text of the repair. The Results table is the last run of the row.

Record

Test

Load the package into a Pharo 14 image (build 791) with the load expression of the test run, file in the fixes file of the row if there is one, and run the test classes of the package.

"row 26"
Metacello new baseline: 'PharoWiki'; repository: 'github://chicoary/PharoWiki:main/src'; onConflict: [:e | e useIncoming]; load: #('default').

Results

Last result of the package run (stock Cog and iospharo on the same image).

RowLabelLoadStock Cogiospharo VM
26chicoary-pharowikioktests=77 P=77 F=0 E=0 S=0 T=0 X=0tests=77 P=77 F=0 E=0 S=0 T=0 X=0

Fix

Fixes file (filed in after the load): chicoary-pharowiki.st (download)
"PharoWiki (chicoary/PharoWiki, main): seven tests skip, none for a machine reason.

1. PWikiGeneratorRegistryTest>>testGeneratorForChangesClass and
   testGeneratorForLibsClass skip when the Epicea log of the image has no
   EpClassAddition entry.  Epicea does not log code that Metacello loads
   (EpMonitor class>>shouldLogMetacelloLoading is false by default) and does not log
   during a test (EpMonitor>>subscribeToSystemAnnouncer), so in a loaded image the log
   is empty and both tests skip.  The tests become independent of the log of
   the image: each one installs an EpMonitor with a memory log that holds one
   EpClassAddition, and restores the monitor afterwards.

2. PWikiGeneratorTest has five tests with an unconditional self skip.  The
   tests work on Point and call the generator with the real
   SystemNavigation scan for implementors and senders of each selector sent in
   Point.  The tests use a stub extractor now (the scan is not under test), and
   testGeneratePointExtensionsSection does not expect the *Geometry
   extension asGVector of the machine of the author: it takes the last
   extension method that Point has in the image."

add value: #PWikiGeneratorRegistryTest value: #withEpiceaLogAdding:do: value: 'private'
	value:
'withEpiceaLogAdding: aClass do: aBlock
	"Run aBlock with an Epicea monitor whose log holds one EpClassAddition for aClass.
	 The log of the image is empty after a Metacello load, because Epicea does not log it."
	| saved |
	saved := EpMonitor hasCurrent ifTrue: [ EpMonitor current ].
	EpMonitor current: (EpMonitor newWithLog: (EpLog newWithEvents: { EpClassAddition class: aClass })).
	^ aBlock ensure: [ EpMonitor current: saved ]'.

fix value: #PWikiGeneratorRegistryTest value: #testGeneratorForChangesClass
	value: [ :source | source includesSubstring: 'self skip' ]
	value:
'testGeneratorForChangesClass
	"generatorFor: returns changesGen for a project class registered in Epicea."
	| registry |
	registry := self buildRegistry.
	self
		withEpiceaLogAdding: PWikiClassPage
		do: [ self assert: (registry generatorFor: PWikiClassPage) == registry changesGen ]'.

fix value: #PWikiGeneratorRegistryTest value: #testGeneratorForLibsClass
	value: [ :source | source includesSubstring: 'self skip' ]
	value:
'testGeneratorForLibsClass
	"generatorFor: returns libsGen for a class registered in Epicea that is not in a project package."
	| registry |
	registry := self buildRegistry.
	self
		withEpiceaLogAdding: Point
		do: [ self assert: (registry generatorFor: Point) == registry libsGen ]'.

add value: #PWikiGenerator value: #extractor: value: 'accessing'
	value:
'extractor: aDependencyExtractor
	extractor := aDependencyExtractor'.

add value: #PWikiGeneratorTest value: #stubExtractor value: 'private'
	value:
'stubExtractor
	"An extractor without the scan of the whole image: the tests check the generated pages, not SystemNavigation."
	| class |
	class := PWikiDependencyExtractor newAnonymousSubclass.
	class compile: ''implementorsOf: aSelector ^ #()''.
	class compile: ''sendersOf: aSelector ^ #()''.
	^ class new'.

fix value: #PWikiGeneratorTest value: #setUp
	value: [ :source | (source includesSubstring: 'extractor:') not ]
	value:
'setUp
	outputDir := FileSystem memory root.
	generator := PWikiSourcesGenerator outputDir: outputDir.
	generator extractor: self stubExtractor'.

fix value: #PWikiGeneratorTest value: #testExtensionsNotDuplicated
	value: [ :source | source includesSubstring: 'self skip' ]
	value:
'testExtensionsNotDuplicated
	"Given a class with extension protocols (Point)
	 When rendering its page
	 Then the Extensions section appears exactly once"
	| page content occurrences |
	page := PWikiClassPage forClass: Point.
	self assert: page extensionProtocolNames isNotEmpty.
	content := generator renderPage: page.
	occurrences := 0.
	content linesDo: [ :line |
		(line trimmed = ''## Extensions'') ifTrue: [ occurrences := occurrences + 1 ] ].
	self assert: occurrences equals: 1'.

fix value: #PWikiGeneratorTest value: #testGeneratePointExtensionsSection
	value: [ :source | source includesSubstring: 'self skip' ]
	value:
'testGeneratePointExtensionsSection
	"Given a PWikiSourcesGenerator writing to a memory filesystem
	 When generating the Point class page
	 Then the file ends with the Extensions section: the last method of the last extension protocol of Point"
	| page protocol method content expected |
	page := PWikiClassPage forClass: Point.
	protocol := page extensionProtocolNames reversed
		detect: [ :each | (page methodsInProtocol: each) isNotEmpty ].
	method := (page methodsInProtocol: protocol) last.
	generator generateForClass: Point.
	content := (outputDir / ''Kernel'' / ''Point.md'') readStream contents.
	expected := String streamContents: [ :s |
		s
			nextPutAll: method sourceCode; cr;
			nextPutAll: ''```''; cr ].
	self assert: (content includesSubstring: ''## Extensions'').
	self assert: (content includesSubstring: ''### '', protocol).
	self assert: (content includesSubstring: ''#### '', method selector).
	self assert: (content last: expected size) equals: expected'.

fix value: #PWikiGeneratorTest value: #testGeneratedFileContainsClassName
	value: [ :source | source includesSubstring: 'self skip' ]
	value:
'testGeneratedFileContainsClassName
	"Given the generator
	 When generating for the class Point
	 Then the file contains the class name"
	| content |
	generator generateForClass: Point.
	content := (outputDir / ''Kernel'' / ''Point.md'') readStream contents.
	self assert: (content includesSubstring: ''Point'')'.

fix value: #PWikiGeneratorTest value: #testGeneratedFileNotEmpty
	value: [ :source | source includesSubstring: 'self skip' ]
	value:
'testGeneratedFileNotEmpty
	"Given the generator
	 When generating for the class Point
	 Then the resulting file is not empty"
	| content |
	generator generateForClass: Point.
	content := (outputDir / ''Kernel'' / ''Point.md'') readStream contents.
	self assert: content isNotEmpty'.

fix value: #PWikiGeneratorTest value: #testGeneratesFileForPoint
	value: [ :source | source includesSubstring: 'self skip' ]
	value:
'testGeneratesFileForPoint
	"Given the generator configured with an output dir
	 When generating for the class Point
	 Then a .md file exists for Point"
	generator generateForClass: Point.
	self assert: (outputDir / ''Kernel'' / ''Point.md'') exists'.

Patch of the package source: chicoary-pharowiki.patch (download)
diff --git a/src/.filetree b/src/.filetree
deleted file mode 100644
index 0737d8d..0000000
--- a/src/.filetree
+++ /dev/null
@@ -1 +0,0 @@
-{"monticello" : false}
diff --git a/src/.properties b/src/.properties
new file mode 100644
index 0000000..50adb58
--- /dev/null
+++ b/src/.properties
@@ -0,0 +1,3 @@
+{
+  #format : 'tonel'
+}

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