[PATCH RFC] tests: require regexes in unified tests to be marked with " (re)"

Matt Mackall mpm at selenic.com
Tue Sep 21 17:18:44 CDT 2010


On Tue, 2010-09-21 at 13:36 -0500, Brodie Rao wrote:
> # HG changeset patch
> # User Brodie Rao <brodie at bitheap.org>
> # Date 1285094123 18000
> # Node ID 2ba3c74f410285bb2da18f6f5fa6ea3b863b8c94
> # Parent  dbca8f134f00fb10f7154b2f6cd9b8188095b1de
> tests: require regexes in unified tests to be marked with " (re)"
> 
> Consider this test:
> 
>   $ hg glog --template '{rev}:{node|short} "{desc}"\n'
>   @  2:20c4f79fd7ac "3"
>   |
>   | o  1:38f24201dcab "2"
>   |/
>   o  0:2a18120dc1c9 "1"
> 
> Because each line beginning with "|" can be compiled as a regular
> expression (equivalent to ".*|"), they will match any output.
> 
> By requiring regular expressions to be marked with " (re)", we reduce
> the potential for false negatives.
> 
> To match a line ending in " (re)", the line can be suffixed with "
> (re) (plain)". " (plain)" has no effect anywhere else.

I think that's overkill.

If we have something that does:

  $ echo "foo (re)"
  foo (re)

And we first test it with the fast:

  outputline == literal

..then we're done. So (re) should simply be a flag that says, "hey, if
the literal match failed, let's treat it as a regex".

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list