Pārlūkot izejas kodu

depot_tools: Run git_cache_test and git_footers_test on windows.

Bug: Some
Change-Id: I74eef44bfe3d940c773e548e6d1035dee4cd45ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1842638
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Edward Lesmes 5 gadi atpakaļ
vecāks
revīzija
ab51754cc7
3 mainītis faili ar 11 papildinājumiem un 6 dzēšanām
  1. 0 2
      PRESUBMIT.py
  2. 2 1
      tests/git_cache_test.py
  3. 9 3
      tests/git_footers_test.py

+ 0 - 2
PRESUBMIT.py

@@ -73,10 +73,8 @@ def CommonChecks(input_api, output_api, tests_to_black_list, run_on_python3):
         r'.*download_from_google_storage_unittest\.py$',
         r'.*gclient_scm_test\.py$',
         r'.*gclient_smoketest\.py$',
-        r'.*git_cache_test\.py$',
         r'.*git_cl_test\.py$',
         r'.*git_common_test\.py$',
-        r'.*git_footers_test\.py$',
         r'.*git_hyper_blame_test\.py$',
         r'.*git_number_test\.py$',
         r'.*git_rebase_update_test\.py$',

+ 2 - 1
tests/git_cache_test.py

@@ -28,7 +28,8 @@ class GitCacheTest(unittest.TestCase):
 
   def git(self, cmd, cwd=None):
     cwd = cwd or self.origin_dir
-    subprocess.check_call(['git'] + cmd, cwd=cwd)
+    git = 'git.bat' if sys.platform == 'win32' else 'git'
+    subprocess.check_call([git] + cmd, cwd=cwd)
 
   def testParseFetchSpec(self):
     testData = [

+ 9 - 3
tests/git_footers_test.py

@@ -252,9 +252,15 @@ My commit message is my best friend. It is my life. I must master it.
       'sys.stdin',
       StringIO('line\r\nany spaces\r\n\r\n\r\nFoo: 1\nBar: 2\nFoo: 3'))
   def testToJson(self):
-    with tempfile.NamedTemporaryFile() as tmp:
-      self.assertEqual(git_footers.main(['--json', tmp.name]), 0)
-      js = json.load(open(tmp.name))
+    with tempfile.NamedTemporaryFile(delete=False) as tmp:
+      try:
+        # NamedTemporaryFiles must be closed on Windows before being opened
+        # again.
+        tmp.close()
+        self.assertEqual(git_footers.main(['--json', tmp.name]), 0)
+        js = json.load(open(tmp.name))
+      finally:
+        os.remove(tmp.name)
     self.assertEqual(js, {'Foo': ['3', '1'], 'Bar': ['2']})