Pharo test defects

NA-platform-windows

State
Partly fixed: 3 fixed, 16 not applicable (2 not proven)
Defect in
the test (3 tests); the other 16 are for Windows or x86_64 only
Tests
19
Fix
image fix 20-NA-platform-windows.st
Upstream repository
pharo-project/pharo

Open: the two tests testCallingFunctionWithW64CallingConvention (TFFunctionCallTest and TFUFFIDifferentCallingConventionFunctionCallTest) run only on an x86_64 VM on macOS. The proof is only the architecture name on arm64; a run on an x86_64 VM under Rosetta is not done.

Record

Of 19 tests, 3 (Win32EnvironmentTest) were skipping on macOS for no good reason; the skip is removed and they now pass on both VMs. The other 16 test Windows-only or x86_64-only behaviour and are proven not applicable on this machine. No VM defect was found.

Test Defect in State Cause
Win32EnvironmentTest>>testExistingEnvironmentVariableLongerThanBufferShouldReturnValue test repaired Skipped on non-Windows although it only checks the platform-independent OSEnvironment contract, which works on macOS. The isWindows skip is removed and the assertions are unchanged.
Win32EnvironmentTest>>testExistingEnvironmentVariableShouldReturnValue test repaired Same as above. The skip is removed and the assertion is unchanged.
Win32EnvironmentTest>>testNonExistingEnvironmentVariableShouldGenerateException test repaired Same as above. The skip is removed and the assertion is unchanged.
Win32WideStringTest>>testCharactersAreEncodedInUnicode16Bits none-not-applicable not applicable Win32WideString (FFI-Kernel) converts through the Windows API MultiByteToWideChar and WideCharToMultiByte, called via WinPlatform. On this machine asWin32WideString fails with MessageNotUnderstood MacOSXPlatform>>#multiByteToWideCharacterCodepage:flags:input:inputLen:output:outputLen:. Measured on both VMs with evalfile.sh (<work directory>). OSPlatform current isWindows is false.
Win32WideStringTest>>testConvertingInBothDirectionsGaveSameString none-not-applicable not applicable Same as above: Windows-API-only code under test.
Win32WideStringTest>>testHandleIsAByteArray none-not-applicable not applicable Same as above.
Win32WideStringTest>>testUnderlayingByteArrayEndsInTwoZeros none-not-applicable not applicable Same as above.
Win32WideStringTest>>testUnderlayingByteArrayIsMultipleOf2 none-not-applicable not applicable Same as above.
KMCombinationTest>>testWindowsAndUnixMetaShouldBeCtrl none-not-applicable not applicable The test is skipped when OSPlatform current isMacOS. On macOS $n meta prints 'Meta + N' and $n ctrl prints 'Ctrl + N', and $n meta = $n ctrl is false on both VMs, so the assertion cannot hold here by design. The macOS counterpart KMCombinationTest>>testMacMetaShouldBeCmd passes on both VMs.
TFBasicTypeSizeTest>>testSizeSignedLongWindows none-not-applicable not applicable Asserts long is 4 bytes, which is the Windows LLP64 size. On this machine TFBasicType slong byteSize is 8 on both VMs. The Unix counterpart testSizeSignedLongUnix (long equals Smalltalk wordSize) passes on both VMs.
TFBasicTypeSizeTest>>testSizeUnsignedLongWindows none-not-applicable not applicable Same as above (ulong is 8 bytes here). Counterpart testSizeUnsignedLongUnix passes on both VMs.
TFBasicTypeTest>>testSignedLongWindows none-not-applicable not applicable Same as above. Counterpart testSignedLongUnix passes on both VMs.
TFBasicTypeTest>>testUnsignedLongWindows none-not-applicable not applicable Same as above. Counterpart testUnsignedLongUnix passes on both VMs.
TFUFFIBasicTypeSizeTest>>testSizeSignedLongWindows none-not-applicable not applicable Same as above (the test inherits TFBasicTypeSizeTest). Counterpart testSizeSignedLongUnix passes on both VMs.
TFUFFIBasicTypeSizeTest>>testSizeUnsignedLongWindows none-not-applicable not applicable Same as above. Counterpart testSizeUnsignedLongUnix passes on both VMs.
TFFunctionCallTest>>testCallingFunctionWithW64CallingConvention none-not-applicable not applicable The test runs only when isMacOS and Smalltalk vm architectureName = 'x86_64', and uses the ABI DARWIN_X86_64_WIN64. This machine is arm64 (architectureName is 'aarch64' on our VM, 'arm64' on Cog). That ABI exists only in libffi for x86_64 Darwin. I did not try an x86_64 VM under Rosetta, so the test is not proven to pass there.
TFUFFIDifferentCallingConventionFunctionCallTest>>testCallingFunctionWithW64CallingConvention none-not-applicable not applicable Same condition as above (x86_64 only).
WinPlatformTest>>testGetTempPathFromTMP none-not-applicable not applicable Tests WinPlatform>>getTempPath, which calls the kernel32 function GetTempPathW. On this machine OSPlatform current is MacOSXPlatform, which does not understand #getTempPath, and WinPlatform new getTempPath fails. The code under test cannot run on macOS.
WindowsResolverTest>>testResolveTempPathFromTMP none-not-applicable not applicable WindowsResolver>>temp calls OSPlatform current getTempPath (GetTempPathW). Measured: WindowsResolver new temp gives MessageNotUnderstood MacOSXPlatform>>#getTempPath on both VMs.

Regression check: OSEnvironmentTest (the only code these tests touch, no non-test method changed): 8 PASS on both our VM and Cog, with the fix image. It was also 8 PASS on the base images before the fix. TFBasicTypeSizeTest, TFBasicTypeTest, TFUFFIBasicTypeSizeTest and KMCombinationTest were run on the base images only (no change there). Only the Unix/macOS counterpart tests were checked as PASS; the remaining tests in those classes were not listed.

Open points: None blocking. Two items I did not run: (1) the W64 calling-convention tests under an x86_64 VM on Rosetta (proven not applicable only by the condition value on arm64). (2) The Win32WideString and WinPlatform/WindowsResolver tests could only be run on Windows. I did not stub the Windows API into the tests, since that would weaken them. The p1.st output for 'WinPlatform new getTempPath' showed a MessageNotUnderstood about multiByteToWideCharacterCodepage:, which looks like the wrong selector for that call; I did not investigate it.

Upstream note: Pharo, System-OSEnvironments-Tests: Win32EnvironmentTest only skips on non-Windows, but its three tests check platform-independent OSEnvironment behaviour (at:put:, a value of 1500 characters, NotFound for an absent name). Remove the OSPlatform current isWindows skip so the tests run on Unix and macOS. The assertions are unchanged. Not submitted; needs owner review first.

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
Win32EnvironmentTest>>testExistingEnvironmentVariableLongerThanBufferShouldReturnValueSKIPrepairedPASSPASSPASS 3 of 3 (repair run)
Win32EnvironmentTest>>testExistingEnvironmentVariableShouldReturnValueSKIPrepairedPASSPASSPASS 3 of 3 (repair run)
Win32EnvironmentTest>>testNonExistingEnvironmentVariableShouldGenerateExceptionSKIPrepairedPASSPASSPASS 3 of 3 (repair run)
KMCombinationTest>>testWindowsAndUnixMetaShouldBeCtrlSKIPnot applicableSKIPSKIP-
TFBasicTypeSizeTest>>testSizeSignedLongWindowsSKIPnot applicableSKIP 2xSKIP 2x-
TFBasicTypeSizeTest>>testSizeUnsignedLongWindowsSKIPnot applicableSKIP 2xSKIP 2x-
TFBasicTypeTest>>testSignedLongWindowsSKIPnot applicableSKIP 2xSKIP 2x-
TFBasicTypeTest>>testUnsignedLongWindowsSKIPnot applicableSKIP 2xSKIP 2x-
TFFunctionCallTest>>testCallingFunctionWithW64CallingConventionSKIPnot applicableSKIP 2xSKIP 2x-
TFUFFIBasicTypeSizeTest>>testSizeSignedLongWindowsSKIPnot applicableSKIP 2xSKIP 2x-
TFUFFIBasicTypeSizeTest>>testSizeUnsignedLongWindowsSKIPnot applicableSKIP 2xSKIP 2x-
TFUFFIDifferentCallingConventionFunctionCallTest>>testCallingFunctionWithW64CallingConventionSKIPnot applicableSKIP 2xSKIP 2x-
Win32WideStringTest>>testCharactersAreEncodedInUnicode16BitsSKIPnot applicableSKIPSKIP-
Win32WideStringTest>>testConvertingInBothDirectionsGaveSameStringSKIPnot applicableSKIPSKIP-
Win32WideStringTest>>testHandleIsAByteArraySKIPnot applicableSKIPSKIP-
Win32WideStringTest>>testUnderlayingByteArrayEndsInTwoZerosSKIPnot applicableSKIPSKIP-
Win32WideStringTest>>testUnderlayingByteArrayIsMultipleOf2SKIPnot applicableSKIPSKIP-
WinPlatformTest>>testGetTempPathFromTMPSKIPnot applicableSKIPSKIP-
WindowsResolverTest>>testResolveTempPathFromTMPSKIPnot applicableSKIPSKIP-

Test

Run the tests in a Pharo 14 image on macOS arm64: they skip (the fixtures and the platform tests skip by design).

"Run in a Playground of a Pharo 14 image (Do it and print each line)."
((KMCombinationTest selector: #testWindowsAndUnixMetaShouldBeCtrl) run) printString.
((TFBasicTypeSizeTest selector: #testSizeSignedLongWindows) run) printString.
((TFBasicTypeSizeTest selector: #testSizeUnsignedLongWindows) run) printString.
((TFBasicTypeTest selector: #testSignedLongWindows) run) printString.
((TFBasicTypeTest selector: #testUnsignedLongWindows) run) printString.
((TFFunctionCallTest selector: #testCallingFunctionWithW64CallingConvention) run) printString.
((TFUFFIBasicTypeSizeTest selector: #testSizeSignedLongWindows) run) printString.
((TFUFFIBasicTypeSizeTest selector: #testSizeUnsignedLongWindows) run) printString.
((TFUFFIDifferentCallingConventionFunctionCallTest selector: #testCallingFunctionWithW64CallingConvention) run) printString.
((Win32EnvironmentTest selector: #testExistingEnvironmentVariableLongerThanBufferShouldReturnValue) run) printString.
((Win32EnvironmentTest selector: #testExistingEnvironmentVariableShouldReturnValue) run) printString.
((Win32EnvironmentTest selector: #testNonExistingEnvironmentVariableShouldGenerateException) run) printString.
((Win32WideStringTest selector: #testCharactersAreEncodedInUnicode16Bits) run) printString.
((Win32WideStringTest selector: #testConvertingInBothDirectionsGaveSameString) run) printString.
((Win32WideStringTest selector: #testHandleIsAByteArray) run) printString.
((Win32WideStringTest selector: #testUnderlayingByteArrayEndsInTwoZeros) run) printString.
((Win32WideStringTest selector: #testUnderlayingByteArrayIsMultipleOf2) run) printString.
((WinPlatformTest selector: #testGetTempPathFromTMP) run) printString.
((WindowsResolverTest selector: #testResolveTempPathFromTMP) run) printString.

Source of the tests before the fix

KMCombinationTest>>testWindowsAndUnixMetaShouldBeCtrl before the fix (Pharo 14 build 791)
testWindowsAndUnixMetaShouldBeCtrl
	OSPlatform current isMacOS ifTrue: [ ^ self skip ].
	self assert: $n meta equals: $n ctrl.
	self assert: $n ctrl equals: $n meta.
	self assert: $n meta shift equals: $n ctrl shift.
	self assert: $n ctrl shift equals: $n meta shift
TFBasicTypeSizeTest>>testSizeSignedLongWindows before the fix (Pharo 14 build 791)
testSizeSignedLongWindows

	OSPlatform current isWindows ifFalse: [
		"Check #testSizeSignedLongUnix"
		^ self skip ].
	self assertType: 'long' equals: 4
TFBasicTypeSizeTest>>testSizeUnsignedLongWindows before the fix (Pharo 14 build 791)
testSizeUnsignedLongWindows

	OSPlatform current isWindows ifFalse: [
		"Check #testSizeUnsignedLongUnix"
		^ self skip ].
	self assertType: 'ulong' equals: 4
TFBasicTypeTest>>testSignedLongWindows before the fix (Pharo 14 build 791)
testSignedLongWindows

	OSPlatform current isWindows ifFalse: [
		"Check #testSignedLongUnix"
		^ self skip ].
	self assert: TFBasicType slong byteSize equals: 4
TFBasicTypeTest>>testUnsignedLongWindows before the fix (Pharo 14 build 791)
testUnsignedLongWindows

	OSPlatform current isWindows ifFalse: [
		"Check #testUnsignedLongUnix"
		^ self skip ].
	self assert: TFBasicType ulong byteSize equals: 4
TFFunctionCallTest>>testCallingFunctionWithW64CallingConvention before the fix (Pharo 14 build 791)
testCallingFunctionWithW64CallingConvention

	| fun returnValue |

	"This test is only valid in OSX and X86_64, as calling conventions constants are heavily dependant on the OS & Architecture"
	(OSPlatform current isMacOS and: [ Smalltalk vm architectureName = 'x86_64'])
		ifFalse: [ self skip ].

	fun := TFExternalFunction
		name: 'w64Convention'
		moduleName: self libraryPath
		definition: (TFFunctionDefinition
			parameterTypes: {TFBasicType sint. TFBasicType sint. TFBasicType sint. TFBasicType sint. TFBasicType sint. TFBasicType sint. TFBasicType sint. TFBasicType sint. TFBasicType sint. TFBasicType sint}
			returnType: TFBasicType sint
			abi: DARWIN_X86_64_WIN64).

	returnValue := runner invokeFunction: fun withArguments: (1 to: 10) asArray.

	self assert: returnValue equals: 55
TFUFFIDifferentCallingConventionFunctionCallTest>>testCallingFunctionWithW64CallingConvention before the fix (Pharo 14 build 791)
testCallingFunctionWithW64CallingConvention

	| result |

	"This test is only valid in OSX and X86_64, as calling conventions constants are heavily dependant on the OS & Architecture"
	(OSPlatform current isMacOS and: [ Smalltalk vm architectureName = 'x86_64'])
		ifFalse: [ self skip ].

	result := self
			calloutWithManyArguments: 1
			and: 2
			and: 3
			and: 4
			and: 5
			and: 6
			and: 7
			and: 8
			and: 9
			and: 10.

	self assert: result equals: 55
Win32EnvironmentTest>>testExistingEnvironmentVariableLongerThanBufferShouldReturnValue before the fix (Pharo 14 build 791)
testExistingEnvironmentVariableLongerThanBufferShouldReturnValue

	| value aExpectedValue |

	OSPlatform current isWindows
		ifFalse: [ ^self skip ].

	aExpectedValue := String loremIpsum: 1500.

	OSEnvironment current at: 'ExistingNonEmpty' put: aExpectedValue.

	value := OSEnvironment current at: 'ExistingNonEmpty'.

	self assert: value equals: aExpectedValue
Win32EnvironmentTest>>testExistingEnvironmentVariableShouldReturnValue before the fix (Pharo 14 build 791)
testExistingEnvironmentVariableShouldReturnValue

	| value |

	OSPlatform current isWindows
		ifFalse: [ ^self skip ].

	OSEnvironment current at: 'ExistingNonEmpty' put: 'IamAValue'.

	value := OSEnvironment current at: 'ExistingNonEmpty'.

	self assert: value equals: 'IamAValue'
Win32EnvironmentTest>>testNonExistingEnvironmentVariableShouldGenerateException before the fix (Pharo 14 build 791)
testNonExistingEnvironmentVariableShouldGenerateException

	OSPlatform current isWindows
		ifFalse: [ ^self skip ].

	self should: [ OSEnvironment current at: 'NonExistingVariable' ] raise: NotFound
Win32WideStringTest>>testCharactersAreEncodedInUnicode16Bits before the fix (Pharo 14 build 791)
testCharactersAreEncodedInUnicode16Bits

	| bytes index |

	self isWindows
		ifFalse: [ ^self skip ].

	bytes := self exampleString asWin32WideString getHandle.
	index := 1.

	self exampleString do: [ :aCharacter |
		self assert: (bytes at: index) equals: (aCharacter codePoint bitAnd: 255).
		self assert: (bytes at: index+1) equals: (aCharacter codePoint >> 8).
		index := index + 2.
	]
Win32WideStringTest>>testConvertingInBothDirectionsGaveSameString before the fix (Pharo 14 build 791)
testConvertingInBothDirectionsGaveSameString

	self isWindows
		ifFalse: [ ^self skip ].

	self assert: self exampleString asWin32WideString asString equals: self exampleString
Win32WideStringTest>>testHandleIsAByteArray before the fix (Pharo 14 build 791)
testHandleIsAByteArray

	self isWindows
		ifFalse: [ ^self skip ].

	self assert: (self exampleString asWin32WideString getHandle isKindOf: ByteArray)
Win32WideStringTest>>testUnderlayingByteArrayEndsInTwoZeros before the fix (Pharo 14 build 791)
testUnderlayingByteArrayEndsInTwoZeros

	self isWindows
		ifFalse: [ ^self skip ].

	self assert: (self exampleString asWin32WideString getHandle last:2) equals: #[00 00]
Win32WideStringTest>>testUnderlayingByteArrayIsMultipleOf2 before the fix (Pharo 14 build 791)
testUnderlayingByteArrayIsMultipleOf2

	self isWindows
		ifFalse: [ ^self skip ].

	self assert: (self exampleString asWin32WideString getHandle size) % 2 equals: 0
WinPlatformTest>>testGetTempPathFromTMP before the fix (Pharo 14 build 791)
testGetTempPathFromTMP

	| value |
	OSPlatform current isWindows ifFalse: [ ^ self skip ].

	value := OSEnvironment current at: 'TMP' ifAbsent: [ nil ].
	[
	| actual expected |
	expected := 'X:\Temp\'.
	OSEnvironment current at: 'TMP' put: expected.
	actual := OSPlatform current getTempPath.
	self assert: actual equals: expected ] ensure: [
		value
			ifNil: [ OSEnvironment current removeKey: 'TMP' ]
			ifNotNil: [ OSEnvironment current at: 'TMP' put: value ] ]
WindowsResolverTest>>testResolveTempPathFromTMP before the fix (Pharo 14 build 791)
testResolveTempPathFromTMP

	| expected |
	OSPlatform current isWindows ifFalse: [ ^ self skip ].

	expected := 'X:\Temp'.

	OSEnvironment current setEnv: 'TMP' value: expected during: [
		| actual |
		actual := WindowsResolver new temp.
		self assert: actual fullName equals: expected ]

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-NA-platform-windows.st (download)
"Win32EnvironmentTest: the three tests check the platform independent OSEnvironment contract (at:put:, at: with a value longer than 1000 characters, NotFound for an absent name).  Their only Windows part was the skip; the code under test (OSEnvironment current) works on macOS and Linux, so the tests run everywhere."
fix value: #Win32EnvironmentTest value: #testExistingEnvironmentVariableLongerThanBufferShouldReturnValue value: [ :s | s includesSubstring: 'isWindows' ] value: 'testExistingEnvironmentVariableLongerThanBufferShouldReturnValue

	| value aExpectedValue |

	aExpectedValue := String loremIpsum: 1500.

	OSEnvironment current at: ''ExistingNonEmpty'' put: aExpectedValue.

	value := OSEnvironment current at: ''ExistingNonEmpty''.

	self assert: value equals: aExpectedValue'.
fix value: #Win32EnvironmentTest value: #testExistingEnvironmentVariableShouldReturnValue value: [ :s | s includesSubstring: 'isWindows' ] value: 'testExistingEnvironmentVariableShouldReturnValue

	| value |

	OSEnvironment current at: ''ExistingNonEmpty'' put: ''IamAValue''.

	value := OSEnvironment current at: ''ExistingNonEmpty''.

	self assert: value equals: ''IamAValue'''.
fix value: #Win32EnvironmentTest value: #testNonExistingEnvironmentVariableShouldGenerateException value: [ :s | s includesSubstring: 'isWindows' ] value: 'testNonExistingEnvironmentVariableShouldGenerateException

	self should: [ OSEnvironment current at: ''NonExistingVariable'' ] raise: NotFound'.

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