[PATCH] tests: create test directories under /tmp/kallithea_tests rather than /tmp

Mads Kiilerich mads at kiilerich.com
Mon May 11 17:54:12 EDT 2015

On 05/11/2015 09:28 PM, Thomas De Schampheleire wrote:
> On Mon, May 11, 2015 at 1:09 AM, Mads Kiilerich <mads at kiilerich.com> wrote:
>> On 05/10/2015 08:23 PM, Thomas De Schampheleire wrote:
>>> # HG changeset patch
>>> # User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
>>> # Date 1431280346 -7200
>>> #      Sun May 10 19:52:26 2015 +0200
>>> # Node ID b4524d737ef6d0d22526075b113ebfe333a44271
>>> # Parent  98c06fc800ed0f0635f3aa189177027b3f8e6c1f
>>> tests: create test directories under /tmp/kallithea_tests rather than /tmp
>>> Do not pollute /tmp with tens of test directories.
>>> diff --git a/kallithea/tests/__init__.py b/kallithea/tests/__init__.py
>>> --- a/kallithea/tests/__init__.py
>>> +++ b/kallithea/tests/__init__.py
>>> @@ -85,7 +85,7 @@ environ = {}
>>>    -TESTS_TMP_PATH = jn('/', 'tmp', 'rc_test_%s' %
>>> _RandomNameSequence().next())
>>> +TESTS_TMP_PATH = jn('/', 'tmp', 'kallithea_tests', 'rc_test_%s' %
>>> _RandomNameSequence().next())
>> That would do that different users can't run the tests on the same machine.
>> We should probably add the uid to the tmp name, as in
>> /tmp/kallithea_tests.1000/... .
> Hmm, indeed. In fact, we could also use a random suffix in that
> top-level directory, instead of the user id.

Perhaps ... but if it still is leaking, it would perhaps be better if it 
leaked in the same dir every time.

A predictable name in /tmp could however be a "DOS", so perhaps, yes.

>> IIRC, this is not enough to move _all_ output?
>> Also, the real solution is to clean up, right? This is just a workaround?
>> Might be worth mentioning in the commit message.
> You're probably right. I must admit I did not investigate this in detail.
> I think the correct approach is to let nosetests/py.test generate a
> temp directory, and use any facilities in there to avoid them being in
> /tmp directly.

The Mercurial test suite will by default do that and remove it after the 
tests have completed, with an option for skipping that removal. That 
seems like a fine solution.

Also, within that shared tmp dir there is no need for using random 
names. More predictable names can make it easier to debug tests.


More information about the kallithea-general mailing list