[PATCH 01 of 14] tests: roll test-committer.t into test-commit.t

Adrian Buehlmann adrian at cadifra.com
Fri Jun 8 16:25:21 CDT 2012


On 2012-06-08 22:07, Mads Kiilerich wrote:
> Adrian Buehlmann wrote, On 06/08/2012 07:02 PM:
>> On 2012-06-08 18:07, Martin Geisler wrote:
>>>> diff --git a/tests/test-commit.t b/tests/test-commit.t
>>>> --- a/tests/test-commit.t
>>>> +++ b/tests/test-commit.t
>>>> @@ -106,7 +106,8 @@
>>>>     [255]
>>>>
>>>>     $ cd ..
>>>> -
>>>> +  $ pwd
>>>> +  $TESTTMP
>>> Is this there on purpose? I don't see what it tests.
>>>
>> It is on purpose.
>>
>> Some tests had errors with incorrectly matched cd of the sort
>>
>>     $ cd foo
>>     ...
>>     $ cd ..
>>     ...
>>     $ cd ..
>>
>> which resultet in cd'ing way too high up. That check makes sure that
>> this doesn't happen again if someone edits the test later on.
> 
> I think it would be better to make it a general rule to avoid doing 'cd 
> ..' and instead do 'cd $TESTDIR'.

Agreed. But it should be 'cd $TESTTMP'.

> That would also protect against the situation where a directory creation 
> (clone?) and the following 'cd' for some reason fails and the matching 
> 'cd ..' then escapes from TESTDIR and can cause various degrees of damage.

Right.

> Manually spreading 'pwd' everywhere doesn't scale ... and is an 
> unrelated change, FWIW.

The current offenders can be found with

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -610,6 +610,9 @@
     f = open(test)
     t = f.readlines()
     f.close()
+    t.append('  $ pwd\n')
+    pwd = '  $TESTTMP/* (glob)\n'
+    t.append(pwd)
 
     script = []
     if options.debug:
@@ -735,6 +738,14 @@
     if pos in after:
         postout += after.pop(pos)
 
+    epwd = postout[-1]
+    if epwd == pwd:
+        postout = postout[:-2]
+    else:
+        postout[-1] = pwd
+        postout.append(epwd)
+        postout.append("  error: Working directory is above $TESTTMP\n")
+
     return exitcode, postout
 
 wifexited = getattr(os, "WIFEXITED", lambda x: False)


Example offender:


$ python run-tests.py --local test-commit.t

--- C:/Users/adi/hgrepos/hg-main/tests\test-commit.t
+++ C:/Users/adi/hgrepos/hg-main/tests\test-commit.t.err
@@ -304,3 +304,7 @@
      rev    offset  length   base linkrev nodeid       p1           p2
        0         0       6      0       0 26d3ca0dfd18 000000000000 000000000000
        1         6       7      1       1 d267bddd54f7 26d3ca0dfd18 000000000000
+  $ pwd
+  $TESTTMP/* (glob)
+  C:/Users/adi/AppData/Local/Temp/hgtests.oko_77/dir2
+  error: Working directory is above $TESTTMP

ERROR: C:/Users/adi/hgrepos/hg-main/tests\test-commit.t output changed
!
Failed test-commit.t: output changed
# Ran 1 tests, 0 skipped, 1 failed.


But this doesn't reveal at which command the pwd went too high up. It only detects
that the level is too high at the end.


More information about the Mercurial-devel mailing list