From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 71EE313888F for ; Fri, 30 Oct 2015 18:52:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AB641E07E1; Fri, 30 Oct 2015 18:52:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 20853E07DF for ; Fri, 30 Oct 2015 18:52:44 +0000 (UTC) Received: from [10.128.12.146] (unknown [100.42.98.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zmedico) by smtp.gentoo.org (Postfix) with ESMTPSA id 15144340C16 for ; Fri, 30 Oct 2015 18:52:41 +0000 (UTC) Subject: Re: [gentoo-portage-dev] [PATCH] runtests: create a global tempdir to hold subtest files To: gentoo-portage-dev@lists.gentoo.org References: <1446228019-5147-1-git-send-email-vapier@gentoo.org> From: Zac Medico X-Enigmail-Draft-Status: N1110 Message-ID: <5633BC75.2010305@gentoo.org> Date: Fri, 30 Oct 2015 11:52:37 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org MIME-Version: 1.0 In-Reply-To: <1446228019-5147-1-git-send-email-vapier@gentoo.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 0a6552b8-7c9b-43ee-bad9-82578a47c13a X-Archives-Hash: c8bcd6b69ff5eebf52946a02b68242ad On 10/30/2015 11:00 AM, Mike Frysinger wrote: > + try: > + # Set up a single tempdir for all the tests to use. > + # This way we know the tests won't leak things on us. > + tempdir = tempfile.mkdtemp(prefix='portage.runtests.') [snip] > + finally: > + if opts.keep_temp: > + print('Temporary directory left behind:\n%s' % tempdir) > + else: > + # Nuke our tempdir and anything that might be under it. > + shutil.rmtree(tempdir, True) > > # Then summarize it all. > print('\nSummary:\n') > This will raise NameError if mkdtemp for some reason. For absolute correctness, you need to call mkdtemp before try, or set tempdir = None before the try and check that it's not None before calling rmtree. -- Thanks, Zac