test/MCSnapshotTest.st
author Jan Vrany <jan.vrany@labware.com>
Fri, 17 May 2024 23:06:48 +0100
branchjv
changeset 1179 2b0400211720
parent 1121 c5661215109c
permissions -rw-r--r--
Tonel: fix possible endless recursion in `TonelRepository class >> discover:` This commit fixes horrible bug in `TonelRepository class >> discover:` when using relative directories that caused endless recursion. This is because `Filename >> directory` does not handle well relative directories: following code causes endless loop: f := '.' asFilename. [ f isRootDirectory ] whileFalse:[f := f directory]. while this one does not: f := Filename currentDirectory. [ f isRootDirectory ] whileFalse:[f := f directory]. Clearly, this is something that has to be fixed in `Filename`, but meanwhile, we fix it here too. While at it, rewrite this method using loop as opposed ro recursion.

"
COPYRIGHT (c) 2020 LabWare
"
"{ Package: 'stx:goodies/monticello/test' }"

"{ NameSpace: Smalltalk }"

MCTestCase subclass:#MCSnapshotTest
	instanceVariableNames:'snapshot'
	classVariableNames:''
	poolDictionaries:''
	category:'SCM-Monticello-Tests'
!

!MCSnapshotTest class methodsFor:'documentation'!

copyright
"
COPYRIGHT (c) 2020 LabWare

"
! !

!MCSnapshotTest methodsFor:'*MonticelloMocks'!

mockClassExtension

    "I change the protocol of this method to resolve the failing test: MCChangeNotificationTest >> testExtMethodModified. This test basically test that when we modified an extension method, the extended package is marked as 'modified'. The problem is that Monticello treat differently a classic method from an extension method, and this only by checking if the protocol name start with a star. Therefore, if the protocol does not match the extending package name, the extending package name will never be notified, and the test will fail. " 
! !

!MCSnapshotTest methodsFor:'running'!

setUp
	snapshot _  self mockSnapshot.
! !

!MCSnapshotTest methodsFor:'tests'!

testCreation
	|d|
	d _  self mockSnapshot definitions.
	self assert: (d anySatisfy: [:ea | ea isClassDefinition and: [ea className = #MCMockClassA]]).
	self assert: (d anySatisfy: [:ea | ea isMethodDefinition and: [ea selector = #mockClassExtension]]).
	self assert: (d allSatisfy: [:ea | ea isClassDefinition not or: [ea category endsWith: 'Mocks']]).
	
!

testInstanceReuse
	| x m n y |
	x _ (MCPackage new name: self mockCategoryName) snapshot.
	Smalltalk garbageCollect.
	n _ MCDefinition allSubInstances size.
	y _ (MCPackage new name: self mockCategoryName) snapshot.
	Smalltalk garbageCollect.
	m _ MCDefinition allSubInstances size.
	self assert: m = n
! !

!MCSnapshotTest class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/monticello/test/MCSnapshotTest.st,v 1.2 2013-05-29 00:01:35 vrany Exp $'
! !