Changeset 90978 in webkit


Ignore:
Timestamp:
Jul 13, 2011 10:05:10 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Move webkitpy off of loose mocks
https://bugs.webkit.org/show_bug.cgi?id=64508

Reviewed by Adam Barth.

Using Mock has caused us more pain than help.
It's possible that there was a cleaner way to use it
(maybe Mock(class) instead of inheriting from it?).
But for now, I've removed all uses of Mock from mocktool.py.

I also moved run_command into the only 3 files which call it
instead of leaving the deprecated method in executive.py.

I changed various direct calls to os.* to use filesystem instead.

  • Scripts/webkitpy/common/checkout/checkout.py:
  • Scripts/webkitpy/common/checkout/checkout_unittest.py:
  • Scripts/webkitpy/common/checkout/scm/git.py:
  • Scripts/webkitpy/common/checkout/scm/scm.py:
  • Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
  • Scripts/webkitpy/common/checkout/scm/svn.py:
  • Scripts/webkitpy/common/system/executive.py:
  • Scripts/webkitpy/common/system/executive_unittest.py:
  • Scripts/webkitpy/tool/mocktool.py:
  • Scripts/webkitpy/tool/steps/cleanworkingdirectory_unittest.py:
  • Scripts/webkitpy/tool/steps/ensurelocalcommitifneeded.py:
Location:
trunk/Tools
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r90977 r90978  
     12011-07-13  Eric Seidel  <eric@webkit.org>
     2
     3        Move webkitpy off of loose mocks
     4        https://bugs.webkit.org/show_bug.cgi?id=64508
     5
     6        Reviewed by Adam Barth.
     7
     8        Using Mock has caused us more pain than help.
     9        It's possible that there was a cleaner way to use it
     10        (maybe Mock(class) instead of inheriting from it?).
     11        But for now, I've removed all uses of Mock from mocktool.py.
     12
     13        I also moved run_command into the only 3 files which call it
     14        instead of leaving the deprecated method in executive.py.
     15
     16        I changed various direct calls to os.* to use filesystem instead.
     17
     18        * Scripts/webkitpy/common/checkout/checkout.py:
     19        * Scripts/webkitpy/common/checkout/checkout_unittest.py:
     20        * Scripts/webkitpy/common/checkout/scm/git.py:
     21        * Scripts/webkitpy/common/checkout/scm/scm.py:
     22        * Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
     23        * Scripts/webkitpy/common/checkout/scm/svn.py:
     24        * Scripts/webkitpy/common/system/executive.py:
     25        * Scripts/webkitpy/common/system/executive_unittest.py:
     26        * Scripts/webkitpy/tool/mocktool.py:
     27        * Scripts/webkitpy/tool/steps/cleanworkingdirectory_unittest.py:
     28        * Scripts/webkitpy/tool/steps/ensurelocalcommitifneeded.py:
     29
    1302011-07-13  Eric Seidel  <eric@webkit.org>
    231
  • trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py

    r90968 r90978  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
    29 import os
    3029import StringIO
    3130
     
    3635from webkitpy.common.checkout.deps import DEPS
    3736from webkitpy.common.memoized import memoized
    38 from webkitpy.common.system.executive import run_command, ScriptError
     37from webkitpy.common.system.executive import ScriptError
    3938from webkitpy.common.system.deprecated_logging import log
    4039
     
    4443# NOTE: All paths returned from this class should be absolute.
    4544class Checkout(object):
    46     def __init__(self, scm):
     45    def __init__(self, scm, executive=None, filesystem=None):
    4746        self._scm = scm
     47        # FIXME: We shouldn't be grabbing at private members on scm.
     48        self._executive = executive or self._scm._executive
     49        self._filesystem = filesystem or self._scm._filesystem
    4850
    4951    def is_path_to_changelog(self, path):
    50         return os.path.basename(path) == "ChangeLog"
     52        return self._filesystem.basename(path) == "ChangeLog"
    5153
    5254    def _latest_entry_for_changelog_at_revision(self, changelog_path, revision):
     
    112114        if not changed_files:
    113115            changed_files = self._scm.changed_files(git_commit)
    114         absolute_paths = [os.path.join(self._scm.checkout_root, path) for path in changed_files]
    115         return [path for path in absolute_paths if predicate(path)]
     116        return filter(predicate, map(self._scm.absolute_path, changed_files))
    116117
    117118    def modified_changelogs(self, git_commit, changed_files=None):
     
    148149
    149150    def chromium_deps(self):
    150         return DEPS(os.path.join(self._scm.checkout_root, "Source", "WebKit", "chromium", "DEPS"))
     151        return DEPS(self._scm.absolute_path("Source", "WebKit", "chromium", "DEPS"))
    151152
    152153    def apply_patch(self, patch, force=False):
     
    159160        if force:
    160161            args.append('--force')
    161         self._scm._executive.run_command(args, input=patch.contents())
     162        self._executive.run_command(args, input=patch.contents())
    162163
    163164    def apply_reverse_diff(self, revision):
  • trunk/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py

    r90968 r90978  
    3939from .scm import detect_scm_system, CommitMessage
    4040from webkitpy.common.system.executive import Executive, ScriptError
     41from webkitpy.common.system.filesystem_mock import MockFileSystem
     42from webkitpy.tool.mocktool import MockSCM, MockExecutive
    4143from webkitpy.thirdparty.mock import Mock
    4244
     
    130132        real_scm = detect_scm_system(self.old_cwd)
    131133
    132         mock_scm = Mock()
     134        mock_scm = MockSCM()
    133135        mock_scm.run = mock_run
    134136        mock_scm.script_path = real_scm.script_path
     
    141143
    142144class CheckoutTest(unittest.TestCase):
     145    def _make_checkout(self):
     146        return Checkout(scm=MockSCM(), filesystem=MockFileSystem(), executive=MockExecutive())
     147
    143148    def test_latest_entry_for_changelog_at_revision(self):
    144         scm = Mock()
    145149        def mock_contents_at_revision(changelog_path, revision):
    146150            self.assertEqual(changelog_path, "foo")
     
    151155            invalid_utf8 = "\255"
    152156            return _changelog1.encode("utf-8") + invalid_utf8
    153         scm.contents_at_revision = mock_contents_at_revision
    154         checkout = Checkout(scm)
     157        checkout = self._make_checkout()
     158        checkout._scm.contents_at_revision = mock_contents_at_revision
    155159        entry = checkout._latest_entry_for_changelog_at_revision("foo", "bar")
    156160        self.assertEqual(entry.contents(), _changelog1entry1)
     
    161165    # recover from those and still return the other ChangeLog entries.
    162166    def test_changelog_entries_for_revision(self):
    163         scm = Mock()
    164         scm.changed_files_for_revision = lambda revision: ['foo/ChangeLog', 'bar/ChangeLog']
    165         checkout = Checkout(scm)
     167        checkout = self._make_checkout()
     168        checkout._scm.changed_files_for_revision = lambda revision: ['foo/ChangeLog', 'bar/ChangeLog']
    166169
    167170        def mock_latest_entry_for_changelog_at_revision(path, revision):
     
    178181
    179182    def test_commit_info_for_revision(self):
    180         scm = Mock()
    181         scm.changed_files_for_revision = lambda revision: ['path/to/file', 'another/file']
    182         scm.committer_email_for_revision = lambda revision, changed_files=None: "committer@example.com"
    183         checkout = Checkout(scm)
     183        checkout = self._make_checkout()
     184        checkout._scm.changed_files_for_revision = lambda revision: ['path/to/file', 'another/file']
     185        checkout._scm.committer_email_for_revision = lambda revision, changed_files=None: "committer@example.com"
    184186        checkout.changelog_entries_for_revision = lambda revision, changed_files=None: [ChangeLogEntry(_changelog1entry1)]
    185187        commitinfo = checkout.commit_info_for_revision(4)
     
    206208
    207209    def test_bug_id_for_revision(self):
    208         scm = Mock()
    209         scm.committer_email_for_revision = lambda revision: "committer@example.com"
    210         checkout = Checkout(scm)
     210        checkout = self._make_checkout()
     211        checkout._scm.committer_email_for_revision = lambda revision: "committer@example.com"
    211212        checkout.changelog_entries_for_revision = lambda revision, changed_files=None: [ChangeLogEntry(_changelog1entry1)]
    212213        self.assertEqual(checkout.bug_id_for_revision(4), 36629)
    213214
    214215    def test_bug_id_for_this_commit(self):
    215         scm = Mock()
    216         checkout = Checkout(scm)
     216        checkout = self._make_checkout()
    217217        checkout.commit_message_for_this_commit = lambda git_commit, changed_files=None: CommitMessage(ChangeLogEntry(_changelog1entry1).contents().splitlines())
    218218        self.assertEqual(checkout.bug_id_for_this_commit(git_commit=None), 36629)
    219219
    220220    def test_modified_changelogs(self):
    221         scm = Mock()
    222         scm.checkout_root = "/foo/bar"
    223         scm.changed_files = lambda git_commit: ["file1", "ChangeLog", "relative/path/ChangeLog"]
    224         checkout = Checkout(scm)
     221        checkout = self._make_checkout()
     222        checkout._scm.checkout_root = "/foo/bar"
     223        checkout._scm.changed_files = lambda git_commit: ["file1", "ChangeLog", "relative/path/ChangeLog"]
    225224        expected_changlogs = ["/foo/bar/ChangeLog", "/foo/bar/relative/path/ChangeLog"]
    226225        self.assertEqual(checkout.modified_changelogs(git_commit=None), expected_changlogs)
     
    237236            return [4, 8]
    238237
    239         scm = Mock()
    240         scm.checkout_root = "/foo/bar"
    241         scm.changed_files = lambda git_commit: ["file1", "file2", "relative/path/ChangeLog"]
    242         scm.revisions_changing_file = mock_revisions_changing_file
    243         checkout = Checkout(scm)
     238        checkout = self._make_checkout()
     239        checkout._scm.checkout_root = "/foo/bar"
     240        checkout._scm.changed_files = lambda git_commit: ["file1", "file2", "relative/path/ChangeLog"]
     241        checkout._scm.revisions_changing_file = mock_revisions_changing_file
    244242        checkout.changelog_entries_for_revision = mock_changelog_entries_for_revision
    245243        reviewers = checkout.suggested_reviewers(git_commit=None)
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py

    r90967 r90978  
    3333from webkitpy.common.memoized import memoized
    3434from webkitpy.common.system.deprecated_logging import log
    35 from webkitpy.common.system.executive import Executive, run_command, ScriptError
     35from webkitpy.common.system.executive import Executive, ScriptError
     36from webkitpy.common.system import ospath
    3637
    3738from .commitmessage import CommitMessage
    3839from .scm import AuthenticationError, SCM, commit_error_handler
    3940from .svn import SVN, SVNRepository
     41
     42
     43def run_command(*args, **kwargs):
     44    # FIXME: This should not be a global static.
     45    # New code should use Executive.run_command directly instead
     46    return Executive().run_command(*args, **kwargs)
    4047
    4148
     
    96103        # "git rev-parse --show-cdup" would be another way to get to the root
    97104        (checkout_root, dot_git) = os.path.split(run_command(['git', 'rev-parse', '--git-dir'], cwd=(path or "./")))
    98         # If we were using 2.6 # checkout_root = os.path.relpath(checkout_root, path)
    99105        if not os.path.isabs(checkout_root):  # Sometimes git returns relative paths
    100106            checkout_root = os.path.join(path, checkout_root)
     
    103109    @classmethod
    104110    def to_object_name(cls, filepath):
    105         root_end_with_slash = os.path.join(cls.find_checkout_root(os.path.dirname(filepath)), '')
     111        root_end_with_slash = self._filesystem.join(cls.find_checkout_root(self._filesystem.dirname(filepath)), '')
    106112        return filepath.replace(root_end_with_slash, '')
    107113
     
    126132
    127133    def rebase_in_progress(self):
    128         return os.path.exists(os.path.join(self.checkout_root, '.git/rebase-apply'))
     134        return self._filesystem.exists(self.absolute_path('.git', 'rebase-apply'))
    129135
    130136    def working_directory_is_clean(self):
     
    335341        # trunk.  Move up to the top of the tree so that git commands that expect a
    336342        # valid CWD won't fail after we check out the merge branch.
    337         os.chdir(self.checkout_root)
     343        # FIXME: We should never be using chdir! We can instead pass cwd= to run_command/self.run!
     344        self._filesystem.chdir(self.checkout_root)
    338345
    339346        # Stuff our change into the merge branch.
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py

    r90967 r90978  
    3131
    3232import logging
    33 import os
    3433import re
    35 import sys
    36 import shutil
    3734
    3835from webkitpy.common.system.deprecated_logging import error, log
    3936from webkitpy.common.system.executive import Executive, ScriptError
    40 from webkitpy.common.system import ospath
     37from webkitpy.common.system.filesystem import FileSystem
    4138
    4239
     
    6259# SCM methods are expected to return paths relative to self.checkout_root.
    6360class SCM:
    64     def __init__(self, cwd, executive=None):
     61    def __init__(self, cwd, executive=None, filesystem=None):
    6562        self.cwd = cwd
    6663        self.checkout_root = self.find_checkout_root(self.cwd)
    6764        self.dryrun = False
    6865        self._executive = executive or Executive()
     66        self._filesystem = filesystem or FileSystem()
    6967
    7068    # A wrapper used by subclasses to create processes.
     
    8280    # absolute paths to pass to rm, etc.
    8381    def absolute_path(self, repository_relative_path):
    84         return os.path.join(self.checkout_root, repository_relative_path)
     82        return self._filesystem.join(self.checkout_root, repository_relative_path)
    8583
    8684    # FIXME: This belongs in Checkout, not SCM.
    8785    def scripts_directory(self):
    88         return os.path.join(self.checkout_root, "Tools", "Scripts")
     86        return self._filesystem.join(self.checkout_root, "Tools", "Scripts")
    8987
    9088    # FIXME: This belongs in Checkout, not SCM.
    9189    def script_path(self, script_name):
    92         return os.path.join(self.scripts_directory(), script_name)
     90        return self._filesystem.join(self.scripts_directory(), script_name)
    9391
    9492    def ensure_clean_working_directory(self, force_clean):
     
    9694            return
    9795        if not force_clean:
    98             # FIXME: Shouldn't this use cwd=self.checkout_root?
     96            # FIXME: Shouldn't this use cwd=self.checkout_root?  (Git definitely would want that, unclear if SVN would.)
    9997            print self.run(self.status_command(), error_handler=Executive.ignore_error)
    10098            raise ScriptError(message="Working directory has modifications, pass --force-clean or --no-clean to continue.")
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py

    r90967 r90978  
    5050from webkitpy.common.config.committers import Committer  # FIXME: This should not be needed
    5151from webkitpy.common.net.bugzilla import Attachment # FIXME: This should not be needed
    52 from webkitpy.common.system.executive import Executive, run_command, ScriptError
     52from webkitpy.common.system.executive import Executive, ScriptError
    5353from webkitpy.common.system.outputcapture import OutputCapture
    5454from webkitpy.tool.mocktool import MockExecutive
     
    7979# Eventually we will want to write tests which work for both scms. (like update_webkit, changed_files, etc.)
    8080# Perhaps through some SCMTest base-class which both SVNTest and GitTest inherit from.
     81
     82
     83def run_command(*args, **kwargs):
     84    # FIXME: This should not be a global static.
     85    # New code should use Executive.run_command directly instead
     86    return Executive().run_command(*args, **kwargs)
     87
    8188
    8289# FIXME: This should be unified into one of the executive.py commands!
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py

    r90967 r90978  
    3636from webkitpy.common.memoized import memoized
    3737from webkitpy.common.system.deprecated_logging import log
    38 from webkitpy.common.system.executive import Executive, run_command, ScriptError
     38from webkitpy.common.system.executive import Executive, ScriptError
    3939from webkitpy.common.system import ospath
    4040
     
    9393    def value_from_svn_info(cls, path, field_name):
    9494        svn_info_args = ['svn', 'info', path]
    95         # FIXME: This should use an Executive.
    96         info_output = run_command(svn_info_args).rstrip()
     95        # FIXME: This method should use a passed in executive or be made an instance method and use self._executive.
     96        info_output = Executive().run_command(svn_info_args).rstrip()
    9797        match = re.search("^%s: (?P<value>.+)$" % field_name, info_output, re.MULTILINE)
    9898        if not match:
  • trunk/Tools/Scripts/webkitpy/common/system/executive.py

    r90826 r90978  
    9797
    9898
    99 def run_command(*args, **kwargs):
    100     # FIXME: This should not be a global static.
    101     # New code should use Executive.run_command directly instead
    102     return Executive().run_command(*args, **kwargs)
    103 
    104 
    10599class Executive(object):
    106100    PIPE = subprocess.PIPE
  • trunk/Tools/Scripts/webkitpy/common/system/executive_unittest.py

    r89843 r90978  
    3434import unittest
    3535
    36 from webkitpy.common.system.executive import Executive, run_command, ScriptError
     36from webkitpy.common.system.executive import Executive, ScriptError
    3737from webkitpy.common.system.filesystem_mock import MockFileSystem
    3838from webkitpy.test import cat, echo
     
    9696    def test_run_command_with_bad_command(self):
    9797        def run_bad_command():
    98             run_command(["foo_bar_command_blah"], error_handler=Executive.ignore_error, return_exit_code=True)
     98            Executive().run_command(["foo_bar_command_blah"], error_handler=Executive.ignore_error, return_exit_code=True)
    9999        self.failUnlessRaises(OSError, run_bad_command)
    100100
  • trunk/Tools/Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests_unittest.py

    r90520 r90978  
    360360        # *) 2 files in /tmp for the image diffs for the two ports
    361361        # *) 1 file in /tmp for the rebaseline results html file
     362        # FIXME: These numbers depend on MockSCM.exists() returning True for all files.
    362363        self.assertEqual(res, 0)
    363364        self.assertEqual(len(filesystem.written_files), 38)
  • trunk/Tools/Scripts/webkitpy/tool/mocktool.py

    r90968 r90978  
    2828
    2929import os
     30import StringIO
    3031import threading
    3132
     
    3738from webkitpy.common.system.executive import ScriptError
    3839from webkitpy.common.system.filesystem_mock import MockFileSystem
    39 from webkitpy.thirdparty.mock import Mock
    4040
    4141
     
    208208
    209209
    210 # FIXME: This should not inherit from Mock
    211 class MockBugzillaQueries(Mock):
     210class MockBugzillaQueries(object):
    212211
    213212    def __init__(self, bugzilla):
    214         Mock.__init__(self)
    215213        self._bugzilla = bugzilla
    216214
     
    249247        return [self._bugzilla.fetch_bug(78), self._bugzilla.fetch_bug(77)]
    250248
     249
    251250_mock_reviewer = Reviewer("Foo Bar", "foo@bar.com")
    252251
     
    255254#        class we should mock that instead.
    256255# Most of this class is just copy/paste from Bugzilla.
    257 # FIXME: This should not inherit from Mock
    258 class MockBugzilla(Mock):
     256class MockBugzilla(object):
    259257
    260258    bug_server_url = "http://example.com"
     
    271269
    272270    def __init__(self):
    273         Mock.__init__(self)
    274271        self.queries = MockBugzillaQueries(self)
    275272        self.committers = CommitterList(reviewers=[_mock_reviewer])
     
    378375            log("-- End comment --")
    379376
     377    def add_cc_to_bug(self, bug_id, ccs):
     378        pass
     379
     380    def obsolete_attachment(self, attachment_id, message=None):
     381        pass
     382
     383    def reopen_bug(self, bug_id, message):
     384        pass
     385
     386    def close_bug_as_fixed(self, bug_id, message):
     387        pass
     388
     389    def clear_attachment_flags(self, attachment_id, message):
     390        pass
     391
    380392
    381393class MockBuilder(object):
     
    464476
    465477
    466 # FIXME: This should not inherit from Mock
    467 class MockSCM(Mock):
     478class MockSCM(object):
    468479
    469480    fake_checkout_root = os.path.realpath("/tmp") # realpath is needed to allow for Mac OS X's /private/tmp
    470481
    471     def __init__(self, filesystem=None):
    472         Mock.__init__(self)
     482    def __init__(self, filesystem=None, executive=None):
    473483        # FIXME: We should probably use real checkout-root detection logic here.
    474484        # os.getcwd() can't work here because other parts of the code assume that "checkout_root"
     
    476486        self.checkout_root = self.fake_checkout_root
    477487        self.added_paths = set()
    478         self._filesystem = filesystem
     488        self._filesystem = filesystem or MockFileSystem()
     489        self._executive = executive or MockExecutive()
    479490
    480491    def add(self, destination_path, return_exit_code=False):
     
    483494            return 0
    484495
     496    def ensure_clean_working_directory(self, force_clean):
     497        pass
     498
     499    def supports_local_commits(self):
     500        return True
     501
     502    def ensure_no_local_commits(self, force_clean):
     503        pass
     504
     505    def exists(self, path):
     506        # TestRealMain.test_real_main (and several other rebaseline tests) are sensitive to this return value.
     507        # We should make those tests more robust, but for now we just return True always (since no test needs otherwise).
     508        return True
     509
     510    def absolute_path(self, *comps):
     511        return self._filesystem.join(self.checkout_root, *comps)
     512
    485513    def changed_files(self, git_commit=None):
    486514        return ["MockFile1"]
    487515
     516    def changed_files_for_revision(self, revision):
     517        return ["MockFile1"]
     518
     519    def head_svn_revision(self):
     520        return 1234
     521
    488522    def create_patch(self, git_commit, changed_files=None):
    489523        return "Patch1"
     
    491525    def commit_ids_from_commitish_arguments(self, args):
    492526        return ["Commitish1", "Commitish2"]
     527
     528    def committer_email_for_revision(self, revision):
     529        return "mock@webkit.org"
     530
     531    def commit_locally_with_message(self, message):
     532        pass
     533
     534    def commit_with_message(self, message, username=None, password=None, git_commit=None, force_squash=False, changed_files=None):
     535        pass
     536
     537    def merge_base(self, git_commit):
     538        return None
    493539
    494540    def commit_message_for_local_commit(self, commit_id):
     
    505551
    506552    def diff_for_revision(self, revision):
    507         return "DiffForRevision%s\n" \
    508                "http://bugs.webkit.org/show_bug.cgi?id=12345" % revision
     553        return "DiffForRevision%s\nhttp://bugs.webkit.org/show_bug.cgi?id=12345" % revision
    509554
    510555    def show_head(self, path):
     
    528573        log("MOCK: MockDEPS.write_variable(%s, %s)" % (name, value))
    529574
     575
     576class MockCommitMessage(object):
     577    def message(self):
     578        return "This is a fake commit message that is at least 50 characters."
    530579
    531580class MockCheckout(object):
     
    565614
    566615    def commit_message_for_this_commit(self, git_commit, changed_files=None):
    567         commit_message = Mock()
    568         commit_message.message = lambda:"This is a fake commit message that is at least 50 characters."
    569         return commit_message
     616        return MockCommitMessage()
    570617
    571618    def chromium_deps(self):
     
    667714
    668715
    669 # FIXME: This should not inherit from Mock
    670716# FIXME: Unify with common.system.executive_mock.MockExecutive.
    671 class MockExecutive(Mock):
     717class MockExecutive(object):
    672718    def __init__(self, should_log=False, should_throw=False):
    673719        self._should_log = should_log
     
    707753
    708754
    709 class MockPort(Mock):
     755class MockPort(object):
    710756    def name(self):
    711757        return "MockPort"
     
    719765    def update_webkit_command(self):
    720766        return ["mock-update-webkit"]
     767
     768    def build_webkit_command(self, build_style=None):
     769        return ["mock-build-webkit"]
     770
     771    def run_bindings_tests_command(self):
     772        return ["mock-run-bindings-tests"]
     773
     774    def prepare_changelog_command(self):
     775        return ['mock-prepare-ChangeLog']
     776
     777    def run_python_unittests_command(self):
     778        return ['mock-test-webkitpy']
     779
     780    def run_perl_unittests_command(self):
     781        return ['mock-test-webkitperl']
     782
     783    def run_javascriptcore_tests_command(self):
     784        return ['mock-run-javacriptcore-tests']
     785
     786    def run_webkit_tests_command(self):
     787        return ['mock-run-webkit-tests']
    721788
    722789
     
    765832        self.executive = MockExecutive(should_log=log_executive)
    766833        self.web = MockWeb()
    767         self.filesystem = MockFileSystem()
    768834        self.workspace = MockWorkspace()
    769835        self._irc = None
    770836        self.user = MockUser()
    771837        self._scm = MockSCM()
     838        # Various pieces of code (wrongly) call filesystem.chdir(checkout_root).
     839        # Making the checkout_root exist in the mock filesystem makes that chdir not raise.
     840        self.filesystem = MockFileSystem(dirs=set([self._scm.checkout_root]))
    772841        self._port = MockPort()
    773842        self._checkout = MockCheckout()
     
    810879
    811880    def submit(self):
    812         return Mock(file)
     881        return StringIO.StringIO()
  • trunk/Tools/Scripts/webkitpy/tool/steps/cleanworkingdirectory.py

    r74639 r90978  
    4848        if not self._options.clean:
    4949            return
    50         # FIXME: This chdir should not be necessary and can be removed as
    51         # soon as ensure_no_local_commits and ensure_clean_working_directory
    52         # are known to set the CWD to checkout_root when calling run_command.
    53         os.chdir(self._tool.scm().checkout_root)
    5450        if not self._allow_local_commits:
    5551            self._tool.scm().ensure_no_local_commits(self._options.force_clean)
  • trunk/Tools/Scripts/webkitpy/tool/steps/cleanworkingdirectory_unittest.py

    r73733 r90978  
    3737    def test_run(self):
    3838        tool = MockTool()
     39        tool._scm = Mock()
     40        tool._scm.checkout_root = '/mock'
    3941        step = CleanWorkingDirectory(tool, MockOptions(clean=True, force_clean=False))
    4042        step.run({})
     
    4446    def test_no_clean(self):
    4547        tool = MockTool()
     48        tool._scm = Mock()
    4649        step = CleanWorkingDirectory(tool, MockOptions(clean=False))
    4750        step.run({})
  • trunk/Tools/Scripts/webkitpy/tool/steps/ensurelocalcommitifneeded.py

    r58328 r90978  
    4141    def run(self, state):
    4242        if self._options.local_commit and not self._tool.scm().supports_local_commits():
    43             error("--local-commit passed, but %s does not support local commits" % self._tool.scm.display_name())
     43            error("--local-commit passed, but %s does not support local commits" % self._tool.scm().display_name())
Note: See TracChangeset for help on using the changeset viewer.