tests: the cd-level issue

Mads Kiilerich mads at kiilerich.com
Mon Jun 11 05:45:29 CDT 2012


On 11/06/12 11:43, Adrian Buehlmann wrote:
> On 2012-06-11 11:21, Pierre-Yves David wrote:
>> If you are creating a new alias for cd; why not just add an explicite 
>> check and abortion when getting out of the scope ?

...

> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -659,6 +659,9 @@
>               prepos = pos
>               pos = n
>               addsalt(n, False)
> +            cmd = l[4:].split()
> +            if len(cmd) == 2 and cmd[0] == 'cd':
> +                l = '  $ cd %s || exit 1\n' % cmd[1]
>               script.append(l[4:])
>           elif l.startswith('>  '): # continuations
>               after.setdefault(prepos, []).append(l)
> This only exits if the cd fails, but that's certainly an improvement. If
> a cd fails, the test should better not proceed creating artifacts, so
> that's a nice change.
>
> FWIW, this change doesn't help with cd .. going too high up though.

It is simple to extend it to validating that the cd doesn't "escape". I 
did that to detect some problems ... or to prove that there were no 
problems left. That is however a runtime check just to check for a 
static 'programming' error in the test. I don't think that's worth it.

/Mads



More information about the Mercurial-devel mailing list