[PATCH 0 of 5] Add 'unified' tests to the test framework
Nicolas Dumazet
nicdumz at gmail.com
Thu Aug 12 23:56:35 UTC 2010
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.
>
> --
> Mathematics is the supreme nostalgia of our time.
>
>
>
--
Nicolas Dumazet — NicDumZ
More information about the Mercurial-devel
mailing list