[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: HEADS UP: cmdline test factory

From: Branko Cibej <brane_at_xbc.nu>
Date: Sun, 21 Jun 2009 14:04:04 +0200

Neels Janosch Hofmeyr wrote:
> This is how I implemented the same test cmpilato wrote in about two minutes
> sharp:
> [[[
> def mine(sbox):
> "lock a file using a comment with xml special chars"
> svntest.factory.make(sbox, """
> echo "This represents a binary file\\n" >> iota
> svn ci
> svn lock -m 'lock & load' iota
> """)
> ]]]
> (Note that I had to double-escape the '\n' to '\\n' because of python
> parsing it before factory can.)

Good start. Now add some syntactic sugar so you can write the tests like

@svntest.factory("lock a file using a comment with xml special chars")
def mine(sbox):
    echo "This represents a binary file\\n" >> iota
    svn ci
    svn lock -m 'lock & load' iota

I leave the implementation as an exercise for the reader. :)

However this approach has some serious flaws:

    * it introduces another scripting language for defining test cases;
      we already have Python, so this appears to be serious overkill.
    * Testcase syntax is only verified at runtime.
    * New features for testcases must be implemented twice -- once in
      the factory parser, and once in the svntest infrastructure

This testcase could written like this:

from svntest import testcase

def mine(sbox):
    "lock a file using a comment with xml special chars"
    iota = sbox.wc_file('iota')
    iota.append("This represents a binary file\n")
    svn.lock(iota, m='lock & load', EXPECT=(".*locked by user", []))

In general, with a bit of objective Pythonic magic, we could make our
testcase writing a lot less verbose.

-- Brane

Received on 2009-06-21 14:04:32 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.