Hi,

I stumbled on an error in WriteStream>>ensureEndsWith: method. The error caused extra blank lines in logs.

Attached small changeset fixes it. It also adds a test to catch such errors in the future. With this fix,

./pharo generator.image PharoVMSpur32Builder buildUnix32

gives a compact output without extra blank lines.

To which box in which repo should I save this cs for mainlining it?

Regards .. Subbu
'From Pharo5.0 of 16 April 2015 [Latest update: #50770] on 18 April 2017 at 8:08:44.889256 pm'!
"Change Set:		fixcrs-kks
Date:			18 April 2017
Author:			kks

Fixed ensureEndsWith: for start of stream. The error was putting extra blank lines in log output"!


!WriteStream methodsFor: 'accessing' stamp: 'kks 4/18/2017 19:59'!
ensureEndsWith: anObject
	"Append anObject to the receiver IFF there is not one on the end."

	(position == 0 or: [(collection at: position) = anObject]) ifTrue: [^self].
	self nextPut: anObject! !


!WriteStreamTest methodsFor: 'testing' stamp: 'kks 4/18/2017 19:57'!
testEnsureEndsWith
	"self debug: #testEnsureEndsWith"
	| stream |
	stream := String new writeStream.
	stream nextPutAll: 'this is a test'.
	stream ensureEndsWith: Character cr.
	stream nextPutAll: 'for WriteStreamTest'.
	self assert: stream contents = (('this is a test' copyWith: Character cr), 'for WriteStreamTest').
	
	"Manually put a new line and verify there are no 2 new lines"
	stream := String new writeStream.
	stream nextPutAll: ('this is a test' copyWith: Character cr).
	stream ensureEndsWith: Character cr.
	stream nextPutAll: 'for WriteStreamTest'.
	self assert: stream contents = (('this is a test' copyWith: Character cr), 'for WriteStreamTest').
	
	"Test with a empty stream"
	stream := String new writeStream.
	stream ensureEndsWith: Character cr.
	self assert: stream contents = ''.! !

Reply via email to