mercurial/HGTestCase.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 21 Jan 2013 05:27:51 -0800
changeset 183 8f8315881c72
parent 174 0d293012a897
child 210 54a73fa50d40
permissions -rw-r--r--
Bugfix in Settings (checking for Mercurial version).

"{ Package: 'stx:libscm/mercurial' }"

TestCase subclass:#HGTestCase
	instanceVariableNames:'repositories'
	classVariableNames:'Verbose'
	poolDictionaries:''
	category:'SCM-Mercurial-Tests'
!

!HGTestCase class methodsFor:'documentation'!

documentation
"
    An anbstract base class for Mercurial tests

    [author:]
        Jan Vrany <jan.vrany@fit.cvut.cz>

    [instance variables:]

    [class variables:]

    [see also:]

"
! !

!HGTestCase class methodsFor:'accessing'!

resources
    ^Array with: HGRepositoriesResource

    "Created: / 19-09-2012 / 18:55:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 17-10-2012 / 13:01:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGTestCase class methodsFor:'testing'!

isAbstract
    ^self == HGTestCase

    "Created: / 17-11-2012 / 11:00:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGTestCase methodsFor:'debugging'!

dumpRepositoryLog: repo
    ^self dumpRepositoryLog: repo on: Transcript sender: thisContext sender

    "Created: / 22-11-2012 / 11:08:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

dumpRepositoryLog: repo on: stream
    self dumpRepositoryLog: repo on: stream sender: thisContext sender.

    "Created: / 22-11-2012 / 11:10:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

dumpRepositoryLog: repo on: stream sender: sender

    Verbose == true ifFalse:[ ^ self ].
    stream cr.
    stream nextPutAll: '+-- hg log '; nextPutAll: repo pathName; nextPutAll:' -- '; cr.
    stream nextPutAll: '+-- sender: '; nextPutAll: sender printString ; nextPutAll:' -- '; cr.
    (OperatingSystem getFullCommandOutputFrom:'hg log ', repo pathName) do:[:line|
        stream nextPutAll:'| '; nextPutAll: line; cr.
    ].
    stream nextPutAll: '+------------- '; cr.

    "Created: / 22-11-2012 / 11:10:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGTestCase methodsFor:'private'!

performTest

    HGAuthorQuery answer: (testSelector , ' <', testSelector , '@', self class name, '>') do:[
        super performTest
    ].

    "Created: / 30-09-2012 / 10:02:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 22-11-2012 / 11:25:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGTestCase methodsFor:'running'!

setUp
    repositories:= OrderedCollection new.

    "Created: / 19-09-2012 / 19:01:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-12-2012 / 12:58:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

tearDown

    HGPackageModelRegistry current flush:'mocks*'.

    HGRepositoriesResource current directoryForRepositories directoryContentsAsFilenames do:[:e|
            [
                Verbose == true ifTrue:[
                    Transcript cr; show: '+-- removing '; showCR: e pathName.
                ].
                e asFilename recursiveRemove.
            ] on: Error do:[:ex|
                "Stupid windows"
                ex halt
            ]
        ].

    repositories := nil.

    "Created: / 19-09-2012 / 19:03:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 30-09-2012 / 05:26:48 / jv"
    "Modified: / 22-11-2012 / 11:35:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGTestCase methodsFor:'utilities'!

repositoryNamed: nm
    ^self repositoryNamed: nm unpack: true

    "Created: / 19-09-2012 / 19:04:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 14-01-2013 / 13:20:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

repositoryNamed: nm unpack: unpack
    | dir |

    dir := HGRepositoriesResource current directoryForRepositoryNamed: nm unpack: unpack.
    repositories add:  dir.
    ^HGRepository on: dir.

    "Created: / 14-01-2013 / 13:20:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGTestCase class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !