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 }"
TestCase subclass:#MCSortingTest
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'SCM-Monticello-Tests'
!
!MCSortingTest class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 2020 LabWare
"
! !
!MCSortingTest methodsFor:'actions'!
sortDefinitions: aCollection
^ aCollection asSortedCollection asArray
! !
!MCSortingTest methodsFor:'building'!
classNamed: aSymbol
^ MCClassDefinition
name: aSymbol
superclassName: #Object
category: ''
instVarNames: #()
comment: ''
!
methodNamed: aSymbol class: className meta: aBoolean
^ MCMethodDefinition
className: className
classIsMeta: aBoolean
selector: aSymbol
category: ''
timeStamp: ''
source: ''
!
sortKeyFor: aDefinition
^ String streamContents:
[:s |
aDefinition description
do: [:ea | s nextPutAll: ea asString]
separatedBy: [s nextPut: $.]]
! !
!MCSortingTest methodsFor:'tests'!
testConsistentSorting
| definitions shuffledAndSorted|
definitions _
{self methodNamed: #a class: #A meta: false.
self methodNamed: #a class: #A meta: true.
self methodNamed: #a class: #B meta: false.
self methodNamed: #b class: #A meta: false.
self methodNamed: #b class: #B meta: false.
self classNamed: #A.
self classNamed: #B}.
shuffledAndSorted _
(1 to: 100) collect: [:ea | self sortDefinitions: definitions shuffled].
self assert: shuffledAndSorted asSet size = 1.
!
testSortOrder
| aA aAm aB bA bB A B cA bAm cAm |
aA _ self methodNamed: #a class: #A meta: false.
bA _ self methodNamed: #b class: #A meta: false.
cA _ self methodNamed: #c class: #A meta: false.
aAm _ self methodNamed: #a class: #A meta: true.
bAm _ self methodNamed: #b class: #A meta: true.
cAm _ self methodNamed: #c class: #A meta: true.
aB _ self methodNamed: #a class: #B meta: false.
bB _ self methodNamed: #b class: #B meta: false.
A _ self classNamed: #A.
B _ self classNamed: #B.
self assert: (self sortDefinitions: {aA. aAm. cAm. aB. bAm. bA. bB. A. cA. B})
= {A. aAm. bAm. cAm. aA. bA. cA. B. aB. bB}
! !
!MCSortingTest class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/goodies/monticello/test/MCSortingTest.st,v 1.2 2013-05-29 00:02:42 vrany Exp $'
! !