Pharo test defects

platform-unix-resolver

State
Fixed (image fix)
Defect in
the test
Tests
3
Fix
image fix 20-platform-unix-resolver.st
Upstream repository
pharo-project/pharo

Record

The three UnixResolverTest tests began with "OSPlatform current isUnix ifFalse: [ ^ self skip ]". On macOS the platform is MacOSXPlatform, a subclass of MacOSPlatform and not of UnixPlatform, so isUnix is false and the tests skip. The code under test, UnixResolver (HOME, TMPDIR and XDG parsing), is plain POSIX code. The test comments say the tests "can be run on any platform". The fix changes the guard to skip only when the platform is neither Unix nor macOS: (isUnix or: [ isMacOS ]). All assertions are unchanged. This is a test defect, not a VM defect. I measured isUnix=false and isMacOS=true on both VMs.

Test Defect in State Cause
UnixResolverTest>>testGetTempFromTMPDIR test repaired Skip guard uses isUnix, which is false on macOS even though UnixResolver works there
UnixResolverTest>>testXdgParseUserDirLineDocuments test repaired Skip guard uses isUnix, which is false on macOS
UnixResolverTest>>testXdgParseUserDirLineNotRoot test repaired Skip guard uses isUnix, which is false on macOS

Regression check: I changed only the three test methods, and no non-test code. UnixResolverTest holds exactly these 3 tests. Without the fix it gave 3 SKIP on ours and 3 SKIP on Cog. With the fix it gave 3 PASS on ours and 3 PASS on Cog. I ran no other class, because there is no non-test method to cover.

Upstream note: Title: UnixResolverTest: run on macOS too. Description: the three tests skip on macOS because OSPlatform current isUnix is false there (MacOSPlatform does not inherit from UnixPlatform), although UnixResolver is plain POSIX code. The skip guard becomes (isUnix or: [ isMacOS ]). Project: pharo, package FileSystem-PlatformSpecific-Tests. I made no PR text for Cog, because no Cog change is needed.

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
UnixResolverTest>>testGetTempFromTMPDIRSKIPrepairedPASSPASSPASS 3 of 3 (repair run)
UnixResolverTest>>testXdgParseUserDirLineDocumentsSKIPrepairedPASSPASSPASS 3 of 3 (repair run)
UnixResolverTest>>testXdgParseUserDirLineNotRootSKIPrepairedPASSPASSPASS 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)."
((UnixResolverTest selector: #testGetTempFromTMPDIR) run) printString.
((UnixResolverTest selector: #testXdgParseUserDirLineDocuments) run) printString.
((UnixResolverTest selector: #testXdgParseUserDirLineNotRoot) run) printString.

Source of the tests before the fix

UnixResolverTest>>testGetTempFromTMPDIR before the fix (Pharo 14 build 791)
testGetTempFromTMPDIR

	| expected |
	OSPlatform current isUnix ifFalse: [ ^ self skip ].
	
	expected := '/tmp/foo'.
	OSEnvironment current setEnv: 'TMPDIR' value: expected during: [ 
		| actual |
		actual := self createResolver temp.
		self assert: actual fullName equals: expected ]
UnixResolverTest>>testXdgParseUserDirLineDocuments before the fix (Pharo 14 build 791)
testXdgParseUserDirLineDocuments
	"Ensure that a path of the form '$HOME/Documents' answers the expected value.
	Note that this test can be run on any platform."
	| stream path relativePath |
	
	OSPlatform current isUnix ifFalse: [ ^ self skip ].
	stream := '"$HOME/Documents"' readStream.
	path := resolver xdgParseUserDirLine: stream.
	relativePath := path relativeTo: resolver home.
	self assert: relativePath pathString equals: 'Documents'
UnixResolverTest>>testXdgParseUserDirLineNotRoot before the fix (Pharo 14 build 791)
testXdgParseUserDirLineNotRoot
	"Ensure that a path of the form '$HOME/' doesn't resolve to the root directory.
	Note that this test can be run on any platform."
	| stream path |

	OSPlatform current isUnix ifFalse: [ ^ self skip ].
	stream := '"$HOME/"' readStream.
	path := resolver xdgParseUserDirLine: stream.
	self deny: path isRoot

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-platform-unix-resolver.st (download)
"UnixResolverTest: the three tests skip when OSPlatform current isUnix is false.
 MacOSXPlatform is a MacOSPlatform, not a UnixPlatform, so isUnix is false on macOS.
 UnixResolver is plain POSIX code (HOME, TMPDIR, XDG files) and works on macOS; the
 test comments say they can run on any platform.  Skip only when neither Unix nor macOS."
fix value: #UnixResolverTest value: #testGetTempFromTMPDIR
	value: [ :s | (s includesSubstring: 'isUnix ifFalse:') ]
	value: 'testGetTempFromTMPDIR

	| expected |
	(OSPlatform current isUnix or: [ OSPlatform current isMacOS ]) ifFalse: [ ^ self skip ].
	
	expected := ''/tmp/foo''.
	OSEnvironment current setEnv: ''TMPDIR'' value: expected during: [ 
		| actual |
		actual := self createResolver temp.
		self assert: actual fullName equals: expected ]
'.
fix value: #UnixResolverTest value: #testXdgParseUserDirLineDocuments
	value: [ :s | (s includesSubstring: 'isUnix ifFalse:') ]
	value: 'testXdgParseUserDirLineDocuments
	"Ensure that a path of the form ''$HOME/Documents'' answers the expected value.
	Note that this test can be run on any platform."
	| stream path relativePath |
	
	(OSPlatform current isUnix or: [ OSPlatform current isMacOS ]) ifFalse: [ ^ self skip ].
	stream := ''"$HOME/Documents"'' readStream.
	path := resolver xdgParseUserDirLine: stream.
	relativePath := path relativeTo: resolver home.
	self assert: relativePath pathString equals: ''Documents''
'.
fix value: #UnixResolverTest value: #testXdgParseUserDirLineNotRoot
	value: [ :s | (s includesSubstring: 'isUnix ifFalse:') ]
	value: 'testXdgParseUserDirLineNotRoot
	"Ensure that a path of the form ''$HOME/'' doesn''t resolve to the root directory.
	Note that this test can be run on any platform."
	| stream path |

	(OSPlatform current isUnix or: [ OSPlatform current isMacOS ]) ifFalse: [ ^ self skip ].
	stream := ''"$HOME/"'' readStream.
	path := resolver xdgParseUserDirLine: stream.
	self deny: path isRoot
'.

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