[PATCH 0 of 5] Add 'unified' tests to the test framework

Adrian Buehlmann adrian at cadifra.com
Fri Aug 13 00:21:58 CDT 2010


On 13.08.2010 01:56, Nicolas Dumazet wrote:
> 2010/8/13 Matt Mackall <mpm at selenic.com>:
>> Before we go ahead and convert all the tests by hand, I've got the start
>> of a script that automates (part of) it. Ideally we want to:
>>
>> - detect comments and turn them into "body text"
>> - detect commands and turn them into $ lines
>> - deal with multiline statements
>> - run the resultant .t file through the test engine
>> - extract the command output lines from .t.err
>> - double-check them against the known-good original .out file
>> - if everything's good, move the .t.err to .t
>> - do appropriate renaming/deletion of the old files
>> - manually pretty-up the body text before committing
> 
> Yeah, I had two helpers for this
> 
> I first (manually) ident multiline statements.
> 
> Then convert everything but multiline statements:
> sed -e "s/^# */;/" -e "s/^echo *\([^>]*\)$/;\1/" -e "s/^;% */;/" -e
> "s/^;['\"]%\? *\(.*\)['\"]$/;\1/" -e "s/^[^; ]\+/  $ &/" -e
> "s/^;\(.*\)$/\n\1\n/"
> 
> Check that output from the .t matches the .out :
> #!/bin/sh
> NAME=$(echo $1 | sed -e "s/\(.*\)\.t/\1/")
> python run-tests.py "$NAME.t" | grep "^+ " | sed -e "s/^\+  //" -e
> "s/$NAME\.t/$NAME/" | diff -u "$NAME.out" -
> 
> The diff should only contain removed output from "echo % foo" kind of
> lines we used to have, and possibly newlines.
> 
> Then I rename .err to .t. Prettify the test. Hunt down sed and greps
> to see if regexps can help.
> And remove the .out once done.
> 

I verified the testing logic and adjusted things a bit of those I
converted (mostly comments, including fixing preexisting errors in
comments).

It's a good occasion to review the tests if it's done manually.

I've started with the tests I wrote myself or edited significantly in
the past.



More information about the Mercurial-devel mailing list