diff options
author | Mats Wichmann <mats@linux.com> | 2019-03-29 17:39:46 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2019-03-29 17:57:10 (GMT) |
commit | f439ae8a8c3aa53219cc0ef7741da106902f778c (patch) | |
tree | 115c3e037f443f313978a577cc765ecd43e1549c /testing | |
parent | f4090a380132898099199a9ae23c0cfabdcc921f (diff) | |
download | SCons-f439ae8a8c3aa53219cc0ef7741da106902f778c.zip SCons-f439ae8a8c3aa53219cc0ef7741da106902f778c.tar.gz SCons-f439ae8a8c3aa53219cc0ef7741da106902f778c.tar.bz2 |
[PR #333] close files to avoid scons-time races
With runtest now honoring the -j 2 option given to it in
CI setup on Windows, there were some problems where scons-time
tests could try to remove a test directory while some files
in it were still open (these locations were complained about
by Python 3.8 also).
Switch test framework to using mkdtemp also, and to not use
tempfile.template (usage of that and mktemp are long
deprecated)
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'testing')
-rw-r--r-- | testing/framework/TestCmd.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py index a6a8045..24f2350 100644 --- a/testing/framework/TestCmd.py +++ b/testing/framework/TestCmd.py @@ -366,11 +366,9 @@ else: def is_String(e): return isinstance(e, (str, unicode, UserString)) -tempfile.template = 'testcmd.' +testprefix = 'testcmd.' if os.name in ('posix', 'nt'): - tempfile.template = 'testcmd.' + str(os.getpid()) + '.' -else: - tempfile.template = 'testcmd.' + testprefix += "%s." % str(os.getpid()) re_space = re.compile('\s') @@ -1662,10 +1660,11 @@ class TestCmd(object): """ if path is None: try: - path = tempfile.mktemp(prefix=tempfile.template) + path = tempfile.mkdtemp(prefix=testprefix) except TypeError: - path = tempfile.mktemp() - os.mkdir(path) + path = tempfile.mkdtemp() + else: + os.mkdir(path) # Symlinks in the path will report things # differently from os.getcwd(), so chdir there |