From 57dd17b46eac63b29d10a7f081fd8175f8ba49c9 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Fri, 22 Mar 2019 09:10:29 +0000 Subject: [PATCH] expose temporary_directory. Since python2 tempfile does not have TemporaryDirectory, we need to either use temporary_directory in gclient_utils or implement it by ourselves. If we chose latter, we also need to implement rmtree for Windows. Considering that, I suppose using gclient_utils should be much easier. Bug: 939959 Change-Id: Ife21a2bc297ac61a4c1940b06df937c293961ae7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1524815 Reviewed-by: Dirk Pranke Reviewed-by: Nico Weber Commit-Queue: Yoshisato Yanagisawa Auto-Submit: Yoshisato Yanagisawa --- presubmit_support.py | 3 +++ tests/presubmit_unittest.py | 1 + 2 files changed, 4 insertions(+) diff --git a/presubmit_support.py b/presubmit_support.py index 987b4c3aa..d560cec8e 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -518,6 +518,9 @@ class InputApi(object): self.cStringIO = cStringIO self.fnmatch = fnmatch self.gclient_paths = gclient_paths + # TODO(yyanagisawa): stop exposing this when python3 become default. + # Since python3's tempfile has TemporaryDirectory, we do not need this. + self.temporary_directory = gclient_utils.temporary_directory self.glob = glob.glob self.json = json self.logging = logging.getLogger('PRESUBMIT') diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index de5a04fbd..ccc7ed278 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -976,6 +976,7 @@ class InputApiUnittest(PresubmitTestsBase): 'subprocess', 'tbr', 'tempfile', + 'temporary_directory', 'thread_pool', 'time', 'traceback',