Merging test scripts and output demo

Martin Geisler mg at lazybytes.net
Sun Jun 13 13:11:00 CDT 2010


Peter Arrenbrecht <peter.arrenbrecht at gmail.com> writes:

> On Fri, Jun 11, 2010 at 11:30 PM, Matt Mackall <mpm at selenic.com> wrote:
>> I started with this test script I had lying around:
>
> I like the direction this is going.
>
>> It shouldn't be too hard to teach run-tests to decorate/undecorate tests
>> using my "salt trick" and to convert the existing tests to this format.
>> Volunteers?
>
> But isn't this being a little hasty? I would really appreciate it if
> you gave the discussion a bit more time. Then again, maybe this is
> your way of forcing our hands?

It's definitely cool that we can merge the output into the test files
like this. But I never considered this to be the most important part.
Making sure we can run the tests on Windows is important and will be
harder.

Though I like the precision of Greg's test framework, I think it's too
verbose. So perhaps we can use Patrick's shell implementation to parse a
test script into calls to Greg's framework? Something like this:

  % hg pull
  pulling from ssh://hg@hg.intevation.org/mercurial/crew/
  searching for changes
  no changes found

is turned into this call:

  hgt.hg('pull', stdout="""\
  pulling from ssh://hg@hg.intevation.org/mercurial/crew/
  searching for changes
  no changes found""")


As for the portability issues, what if we provide a set of "builtins"
for the shell-like language we will be executing? So we recognize
programs like sed, grep, tar, etc. When we write

  % hg pull | sed 's|ssh://.*|<somewhere>|'
  pulling from <somewhere>
  searching for changes
  no changes found

in a test script, it is parsed into code that looks like this:

  p = Pipe()
  hgt.hg('pull', stdout=p)
  sed.call('ssh://.*', '<somewhere>', stdin=p, stdout="""\
  pulling from <somewhere>
  searching for changes
  no changes found""")

We can even do away with the (IMO) silly sed syntax and invent a better:

  % hg pull | replace 'ssh://.*' '<somewhere>'

The shell-like language will then only be a convenience interface for
writing scripts in the style of Greg's framework.

-- 
Martin Geisler

See my Mercurial presentation: http://vimeo.com/11497288
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100613/69384457/attachment.pgp>


More information about the Mercurial-devel mailing list