Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] runtests: create a global tempdir to hold subtest files
Date: Fri, 30 Oct 2015 18:55:46
Message-Id: 5633BD2C.8070300@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH] runtests: create a global tempdir to hold subtest files by Zac Medico
1 On 10/30/2015 11:52 AM, Zac Medico wrote:
2 > On 10/30/2015 11:00 AM, Mike Frysinger wrote:
3 >
4 >> + try:
5 >> + # Set up a single tempdir for all the tests to use.
6 >> + # This way we know the tests won't leak things on us.
7 >> + tempdir = tempfile.mkdtemp(prefix='portage.runtests.')
8 > [snip]
9 >> + finally:
10 >> + if opts.keep_temp:
11 >> + print('Temporary directory left behind:\n%s' % tempdir)
12 >> + else:
13 >> + # Nuke our tempdir and anything that might be under it.
14 >> + shutil.rmtree(tempdir, True)
15 >>
16 >> # Then summarize it all.
17 >> print('\nSummary:\n')
18 >>
19 >
20 > This will raise NameError if mkdtemp for some reason. For absolute
21 > correctness, you need to call mkdtemp before try, or set tempdir = None
22 > before the try and check that it's not None before calling rmtree.
23 >
24
25 I mean, "if mkdtemp fails for some reason." Other then that issue, the
26 patch looks good.
27 --
28 Thanks,
29 Zac