Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(865)

Unified Diff: tests/scm_unittest.py

Issue 329823002: scm.GIT.IsValidRevision: Only return True if the given object is a commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scm.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/scm_unittest.py
diff --git a/tests/scm_unittest.py b/tests/scm_unittest.py
index 4e97c73eebea7d4f78ebf987725372bb7ac2ddb0..0b03152e9955d56689a26c240aace22d752dcca9 100755
--- a/tests/scm_unittest.py
+++ b/tests/scm_unittest.py
@@ -8,6 +8,7 @@
import logging
import os
import sys
+import tempfile
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@@ -141,6 +142,17 @@ class RealGitTest(fake_repos.FakeReposTestBase):
self.assertTrue(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev=first_rev))
self.assertTrue(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev='HEAD'))
+ # Verify that IsValidRevision returns False for non-commit objects.
+ tmp = tempfile.NamedTemporaryFile(delete=False)
+ try:
+ tmp.write('This is not a commit')
+ tmp.close()
+ hashval = scm.GIT.Capture(['hash-object', '-w', tmp.name],
+ cwd=self.clone_dir)
+ finally:
+ os.remove(tmp.name)
+ self.assertFalse(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev=hashval))
+
class RealGitSvnTest(fake_repos.FakeReposTestBase):
def setUp(self):
« no previous file with comments | « scm.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698