Make checkout_unittest more robust against files moving around
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jul 2011 20:02:23 +0000 (20:02 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jul 2011 20:02:23 +0000 (20:02 +0000)
Fixes <http://webkit.org/b/64197> checkout_unittest contains ugly, fragile code to find the
Scripts directory

Reviewed by Adam Barth.

* Scripts/webkitpy/common/checkout/checkout_unittest.py:
(CommitMessageForThisCommitTest.test_commit_message_for_this_commit): Instantiate a real SCM
object and use it to get the path to the Scripts directory, rather than hard-coding the
relative path from this file to Scripts.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@90659 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py

index 8bd9974..9a4b096 100644 (file)
@@ -1,5 +1,19 @@
 2011-07-08  Adam Roben  <aroben@apple.com>
 
+        Make checkout_unittest more robust against files moving around
+
+        Fixes <http://webkit.org/b/64197> checkout_unittest contains ugly, fragile code to find the
+        Scripts directory
+
+        Reviewed by Adam Barth.
+
+        * Scripts/webkitpy/common/checkout/checkout_unittest.py:
+        (CommitMessageForThisCommitTest.test_commit_message_for_this_commit): Instantiate a real SCM
+        object and use it to get the path to the Scripts directory, rather than hard-coding the
+        relative path from this file to Scripts.
+
+2011-07-08  Adam Roben  <aroben@apple.com>
+
         Make TestFailures remember that run-webkit-tests timed out, even across reloads
 
         Fixes <http://webkit.org/b/64193> TestFailures page incorrectly thinks all tests passed in
index 46329aa..e67fc16 100644 (file)
@@ -119,8 +119,6 @@ Second part of this complicated change by me, Tor Arne Vestb\u00f8!
     # FIXME: This should not need to touch the file system, however
     # ChangeLog is difficult to mock at current.
     def test_commit_message_for_this_commit(self):
-        scm = Mock()
-
         def mock_run(*args, **kwargs):
             # Note that we use a real Executive here, not a MockExecutive, so we can test that we're
             # invoking commit-log-editor correctly.
@@ -129,13 +127,13 @@ Second part of this complicated change by me, Tor Arne Vestb\u00f8!
             kwargs['env'] = env
             return Executive().run_command(*args, **kwargs)
 
-        def mock_script_path(script):
-            return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', script))
+        real_scm = detect_scm_system(self.old_cwd)
 
-        scm.run = mock_run
-        scm.script_path = mock_script_path
+        mock_scm = Mock()
+        mock_scm.run = mock_run
+        mock_scm.script_path = real_scm.script_path
 
-        checkout = Checkout(scm)
+        checkout = Checkout(mock_scm)
         checkout.modified_changelogs = lambda git_commit, changed_files=None: self.changelogs
         commit_message = checkout.commit_message_for_this_commit(git_commit=None)
         self.assertEqual(commit_message.message(), self.expected_commit_message)