mercurial/HGCommandParserTests.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 19 Nov 2012 21:57:45 +0000
changeset 80 8f300696b26b
parent 69 17045d49309f
child 88 1ad71a063a20
permissions -rw-r--r--
Added configurable path to 'hg' command.

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

TestCase subclass:#HGCommandParserTests
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'SCM-Mercurial-Tests'
!


!HGCommandParserTests methodsFor:'tests - misc'!

test_misc_01

    | id |

    id := (HGCommandParser on: '4:6f88e1f44d9eb86e0b56ca15e30e5d786acd83c7') parseNodeId.
    self assert: ( id revno == 4 ).
    self assert: ( id hexPrintString = '6F88E1F44D9EB86E0B56CA15E30E5D786ACD83C7' ).

    id := (HGCommandParser on: '4:6f88e1f44d9e') parseNodeId.
    self assert: ( id revno == 4 ).
    self assert: ( id hexPrintString = '6F88E1F44D9E' ).

    id := (HGCommandParser on: '-1:0000000000000000000000000000000000000000') parseNodeId.
    self assert: id == HGNodeId null.

    id := (HGCommandParser on: '-1:000000000000') parseNodeId.
    self assert: id == HGNodeId null.


    "/ Too short id
    self 
        should:[id := (HGCommandParser on: '4:6f88e1f44d9eb86e0b56ca15e30e5d786acd83') parseNodeId.]
        raise: Error.
    self 
        should:[id := (HGCommandParser on: '4:6f88e1f44d9') parseNodeId.]
        raise: Error.


    "/ Invalid char
    self 
        should:[id := (HGCommandParser on: '4:6f88e1f44d9eb86e0b56ca15e30e5d786acd8X') parseNodeId.]
        raise: Error.

        self 
        should:[id := (HGCommandParser on: '4:6f88e1f44d9X') parseNodeId.]
        raise: Error.

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

test_misc_03

    | rev |

    rev := (HGCommandParser on: '4:6f88e1f44d9eb86e0b56ca15e30e5d786acd83c7
default
3:912a64597e4f133ffbc1fdabdda99167a2d69ce2 -1:0000000000000000000000000000000000000000 
Jan Vrany <jan.vrany@fit.cvut.cz>
2012-10-17 13:20 +0200
Commit 4
**EOE**
') parseLogEntry.

    self assert: rev id revno = 4.
    self assert: rev author = 'Jan Vrany <jan.vrany@fit.cvut.cz>'.
    self assert: rev timestamp hour = 13

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

test_misc_04

    | revs |

    revs := (HGCommandParser on: '4:6f88e1f44d9eb86e0b56ca15e30e5d786acd83c7
default
3:912a64597e4f133ffbc1fdabdda99167a2d69ce2 -1:0000000000000000000000000000000000000000 
Jan Vrany <jan.vrany@fit.cvut.cz>
2012-10-17 13:20 +0200
Commit 4
**EOE**
3:912a64597e4f133ffbc1fdabdda99167a2d69ce2
default
2:db43a5baa9acaf2536d8b12c070b4f5e0363d45c -1:0000000000000000000000000000000000000000 
Jan Vrany <jan.vrany@fit.cvut.cz>
2012-10-17 13:20 +0200
Commit 3
**EOE**
') parseLog.

    self assert: revs size == 2

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

test_version_2_3_3

    | vsn |

    vsn := (HGCommandParser on: 'Mercurial Distributed SCM (version 2.3.2)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2012 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
') parseCommandVersion.

    self assert: vsn = #(2 3 2)

    "Created: / 19-11-2012 / 20:59:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_version_2_4

    | vsn |

    vsn := (HGCommandParser on: 'Mercurial Distributed SCM (version 2.4)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2012 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
') parseCommandVersion.

    self assert: vsn = #(2 4 nil)

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

!HGCommandParserTests class methodsFor:'documentation'!

version_HG
    "Never, ever change this method. Ask JV or CG why"
    ^thisContext method mclass theNonMetaclass instVarNamed: #revision
!

version_SVN
    ^ '§Id::                                                                                                                        §'
! !