tests: the cd-level issue

Adrian Buehlmann adrian at cadifra.com
Sat Jun 9 06:38:34 CDT 2012


I'd still like to attack the (small?) problem in the tests, where the
current working directory (=pwd) is driven too high up by an erroneous
"cd .." in a test.

test-commit.t has that problem, as already reported.

A quick and dirty temporary hack I found to be useful to find the exact
place where it happens is:

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -613,12 +613,13 @@

     script = []
     if options.debug:
         script.append('set -x\n')
     if os.getenv('MSYSTEM'):
         script.append('alias pwd="pwd -W"\n')
+    script.append('alias cd="pwd; cd"\n')
     for n, l in enumerate(t):
         if not l.endswith('\n'):
             l += '\n'
         if l.startswith('#if'):
             if skipping is not None:
                 after.setdefault(pos, []).append('  !!! nested #if\n')

Then, in the test output there is

 Issue1049: Hg permits partial commit of merge without warning

   $ cd ..
+  $TESTTMP

Which means, that *before* the cd is executed, $PWD was *already* at
$TESTTMP, in other words, this exact "cd .." command is the offender, as
it tries to break out of the base-directory of the test.

Mads proposed to do

  $ cd $TESTTMP

in the tests (where applicable), which I think is a good idea.

But test-commit.t has that cd-bug, and it can obvisouly be fixed with a
minimal change by removing that offending "cd .." line.

So, I think I'm going to send a patch for the stable branch for
test-commit.t, which removes that offending "cd ..", and then we can
look into more agressive changes on the default branch, like for example
applying Mads'

  $ cd $TESTTMP

,but this will have to be done by hand-and-eyeballs.



More information about the Mercurial-devel mailing list