Fix depot_tools unit tests on Windows.

TEST=unittests
BUG=none
Review URL: http://codereview.chromium.org/273010

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@28591 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py
index 5a5237a..5ffa7b5 100644
--- a/tests/gclient_scm_test.py
+++ b/tests/gclient_scm_test.py
@@ -378,18 +378,22 @@
 reset refs/heads/master
 from :3
 """
-
   def Options(self, *args, **kwargs):
     return self.OptionsObject(self, *args, **kwargs)
 
   def CreateGitRepo(self, git_import, path):
-    subprocess.Popen(['git', 'init'], stdout=subprocess.PIPE,
-                     stderr=subprocess.STDOUT, cwd=path).communicate()
+    try:
+      subprocess.Popen(['git', 'init'], stdout=subprocess.PIPE,
+                       stderr=subprocess.STDOUT, cwd=path).communicate()
+    except WindowsError:
+      # git is not available, skip this test.
+      return False
     subprocess.Popen(['git', 'fast-import'], stdin=subprocess.PIPE,
                      stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                      cwd=path).communicate(input=git_import)
     subprocess.Popen(['git', 'checkout'], stdout=subprocess.PIPE,
                      stderr=subprocess.STDOUT, cwd=path).communicate()
+    return True
 
   def GetGitRev(self, path):
     return subprocess.Popen(['git', 'rev-parse', 'HEAD'],
@@ -404,7 +408,7 @@
     self.root_dir = tempfile.mkdtemp()
     self.relpath = '.'
     self.base_path = os.path.join(self.root_dir, self.relpath)
-    self.CreateGitRepo(self.sample_git_import, self.base_path)
+    self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path)
 
   def tearDown(self):
     shutil.rmtree(self.root_dir)
@@ -420,6 +424,8 @@
     self.compareMembers(gclient_scm.CreateSCM(url=self.url), members)
 
   def testRevertMissing(self):
+    if not self.enabled:
+      return
     options = self.Options()
     file_path = os.path.join(self.base_path, 'a')
     os.remove(file_path)
@@ -433,6 +439,8 @@
     self.assertEquals(file_list, [])
 
   def testRevertNone(self):
+    if not self.enabled:
+      return
     options = self.Options()
     scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
                                 relpath=self.relpath)
@@ -444,6 +452,8 @@
 
 
   def testRevertModified(self):
+    if not self.enabled:
+      return
     options = self.Options()
     file_path = os.path.join(self.base_path, 'a')
     open(file_path, 'a').writelines('touched\n')
@@ -459,6 +469,8 @@
                       '069c602044c5388d2d15c3f875b057c852003458')
 
   def testRevertNew(self):
+    if not self.enabled:
+      return
     options = self.Options()
     file_path = os.path.join(self.base_path, 'c')
     f = open(file_path, 'w')
@@ -478,6 +490,8 @@
                       '069c602044c5388d2d15c3f875b057c852003458')
 
   def testStatusNew(self):
+    if not self.enabled:
+      return
     options = self.Options()
     file_path = os.path.join(self.base_path, 'a')
     open(file_path, 'a').writelines('touched\n')
@@ -488,6 +502,8 @@
     self.assertEquals(file_list, [file_path])
 
   def testStatus2New(self):
+    if not self.enabled:
+      return
     options = self.Options()
     expected_file_list = []
     for f in ['a', 'b']:
@@ -502,6 +518,8 @@
     self.assertEquals(sorted(file_list), expected_file_list)
 
   def testUpdateCheckout(self):
+    if not self.enabled:
+      return
     options = self.Options(verbose=True)
     root_dir = tempfile.mkdtemp()
     relpath = 'foo'
@@ -520,6 +538,8 @@
       shutil.rmtree(root_dir)
 
   def testUpdateUpdate(self):
+    if not self.enabled:
+      return
     options = self.Options()
     expected_file_list = [os.path.join(self.base_path, x) for x in ['a', 'b']]
     scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,